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.

38 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 LasLabs Inc.
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from mock import MagicMock
  5. from odoo.tests.common import TransactionCase
  6. class TestSaleOrder(TransactionCase):
  7. def setUp(self):
  8. super(TestSaleOrder, self).setUp()
  9. self.product = self.env.ref('product.product_product_1')
  10. self.sale = self.env.ref('sale.sale_order_2')
  11. self.contract = self.env['account.analytic.contract'].create({
  12. 'name': 'Test',
  13. })
  14. self.product.product_tmpl_id.is_contract = True
  15. self.product.product_tmpl_id.contract_template_id = self.contract.id
  16. def tearDown(self):
  17. self.env['account.analytic.account']._revert_method(
  18. 'create',
  19. )
  20. super(TestSaleOrder, self).tearDown()
  21. def test_action_done(self):
  22. """ It should create a contract when the sale for a contract is set
  23. to done for the first time """
  24. self.env['account.analytic.account']._patch_method(
  25. 'create', MagicMock()
  26. )
  27. self.sale.action_confirm()
  28. self.env['account.analytic.account'].create.assert_called_once_with({
  29. 'name': '%s Contract' % self.sale.name,
  30. 'partner_id': self.sale.partner_id.id,
  31. 'contract_template_id': self.contract.id,
  32. })