You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.3 KiB

  1. # Copyright 2017 LasLabs Inc.
  2. # Copyright 2018 ACSONE SA/NV.
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo.tests.common import TransactionCase
  5. from odoo.exceptions import ValidationError
  6. class TestProductTemplate(TransactionCase):
  7. def setUp(self):
  8. super(TestProductTemplate, self).setUp()
  9. self.service_product = self.env.ref('product.product_product_1')
  10. self.consu_product = self.env.ref('product.product_product_5')
  11. self.contract = self.env['contract.template'].create(
  12. {'name': 'Test'}
  13. )
  14. def test_change_is_contract(self):
  15. """ It should verify that the contract_template_id is removed
  16. when is_contract is False """
  17. self.service_product.is_contract = True
  18. self.service_product.contract_template_id = self.contract.id
  19. self.service_product.is_contract = False
  20. self.service_product.product_tmpl_id._change_is_contract()
  21. self.assertEquals(len(self.service_product.contract_template_id), 0)
  22. def test_check_contract_product_type(self):
  23. """
  24. It should raise ValidationError on change of is_contract to True
  25. for consu product
  26. """
  27. with self.assertRaises(ValidationError):
  28. self.consu_product.is_contract = True