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.

30 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 LasLabs Inc.
  3. # Copyright 2019 Therp BV <https://therp.nl>.
  4. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  5. # pylint: disable=missing-docstring,protected-access,invalid-name
  6. from odoo.tests.common import TransactionCase
  7. class TestSaleOrder(TransactionCase):
  8. def setUp(self):
  9. super(TestSaleOrder, self).setUp()
  10. self.product = self.env.ref('product.product_product_1')
  11. self.sale = self.env.ref('sale.sale_order_2')
  12. self.contract = self.env['account.analytic.contract'].create({
  13. 'name': 'Test',
  14. 'recurring_rule_type': 'yearly',
  15. 'recurring_interval': 1})
  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_confirm(self):
  19. """Contract should be created when sale is confirmed."""
  20. self.sale.action_confirm()
  21. contract_model = self.env['account.analytic.account']
  22. product_contract = contract_model.search([
  23. ('recurring_invoices', '=', True),
  24. ('partner_id', '=', self.sale.partner_id.id),
  25. ('contract_template_id', '=', self.contract.id)], limit=1)
  26. self.assertTrue(product_contract)