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.

39 lines
1.4 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. 'recurring_rule_type': 'yearly',
  14. 'recurring_interval': 12345,
  15. })
  16. self.product.product_tmpl_id.is_contract = True
  17. self.product.product_tmpl_id.contract_template_id = self.contract.id
  18. def tearDown(self):
  19. self.env['account.analytic.account']._revert_method(
  20. 'create',
  21. )
  22. def test_action_done(self):
  23. """ It should create a contract when the sale for a contract is set
  24. to done for the first time """
  25. self.env['account.analytic.account']._patch_method(
  26. 'create', MagicMock()
  27. )
  28. self.sale.action_confirm()
  29. self.env['account.analytic.account'].create.assert_called_once_with({
  30. 'name': '%s Contract' % self.sale.name,
  31. 'partner_id': self.sale.partner_id.id,
  32. 'contract_template_id': self.contract.id,
  33. })