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. # 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 test_action_done(self):
  19. """ It should create a contract when the sale for a contract is set
  20. to done for the first time """
  21. self.env['account.analytic.account']._patch_method(
  22. 'create', MagicMock()
  23. )
  24. self.sale.action_confirm()
  25. self.env['account.analytic.account'].create.assert_called_once_with({
  26. 'name': '%s Contract' % self.sale.name,
  27. 'partner_id': self.sale.partner_id.id,
  28. 'contract_template_id': self.contract.id,
  29. })