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.

34 lines
1.3 KiB

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