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.

44 lines
1.9 KiB

  1. # Copyright 2018 Tecnativa - Carlos Dauden
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. from odoo.addons.contract.tests.test_contract import TestContractBase
  4. class TestContractSaleInvoicing(TestContractBase):
  5. @classmethod
  6. def setUpClass(cls):
  7. super(TestContractSaleInvoicing, cls).setUpClass()
  8. cls.product_so = cls.env.ref(
  9. 'product.service_order_01_product_template')
  10. cls.sale_order = cls.env['sale.order'].create({
  11. 'partner_id': cls.partner.id,
  12. 'partner_invoice_id': cls.partner.id,
  13. 'partner_shipping_id': cls.partner.id,
  14. 'order_line': [(0, 0, {'name': cls.product_so.name,
  15. 'product_id': cls.product_so.id,
  16. 'product_uom_qty': 2,
  17. 'product_uom': cls.product_so.uom_id.id,
  18. 'price_unit': cls.product_so.list_price})],
  19. 'pricelist_id': cls.partner.property_product_pricelist.id,
  20. 'analytic_account_id': cls.contract.id,
  21. 'date_order': '2016-02-15',
  22. })
  23. def test_not_sale_invoicing(self):
  24. self.contract.invoicing_sales = False
  25. self.sale_order.action_confirm()
  26. self.contract.recurring_create_invoice()
  27. self.assertEqual(self.sale_order.invoice_status, 'to invoice')
  28. def test_sale_invoicing(self):
  29. self.contract.invoicing_sales = True
  30. self.sale_order.action_confirm()
  31. self.contract.recurring_create_invoice()
  32. self.assertEqual(self.sale_order.invoice_status, 'invoiced')
  33. def test_contract_sale_invoicing_without(self):
  34. self.contract.invoicing_sales = True
  35. self.sale_order.analytic_account_id = False
  36. self.sale_order.action_confirm()
  37. self.contract.recurring_create_invoice()
  38. self.assertEqual(self.sale_order.invoice_status, 'to invoice')