test_create.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. # coding: utf-8
  2. # © 2015 David BEAL @ Akretion
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp.tests.common import TransactionCase
  5. class CreatePriceItemCase(TransactionCase):
  6. def test_create_from_product(self):
  7. """ Check if price item created from product template has:
  8. - price_discount = -1
  9. - base = 1
  10. """
  11. versions = self.env['product.pricelist.version'].search(
  12. [('pricelist_id.price_grid', '=', True)])
  13. version_values = {
  14. 'price_version_id': versions[0].id, 'price_surcharge': 7}
  15. vals = {'name': 'Test from pricelist per product',
  16. 'type': 'consu',
  17. 'list_price': 10,
  18. 'pricelist_item_ids': [(0, 0, version_values)]}
  19. product = self.env['product.template'].create(vals)
  20. item = self.env['product.pricelist.item'].search([
  21. ('product_tmpl_id', '=', product.id)])
  22. self.assertEqual(item.price_discount, -1.0)
  23. self.assertEqual(item.base, 1)
  24. self.assertEqual(versions[0].tmpl_in_count, 2)