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.

45 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.product_product_1')
  10. cls.product_so.invoice_policy = 'order'
  11. cls.sale_order = cls.env['sale.order'].create({
  12. 'partner_id': cls.partner.id,
  13. 'partner_invoice_id': cls.partner.id,
  14. 'partner_shipping_id': cls.partner.id,
  15. 'order_line': [(0, 0, {'name': cls.product_so.name,
  16. 'product_id': cls.product_so.id,
  17. 'product_uom_qty': 2,
  18. 'product_uom': cls.product_so.uom_id.id,
  19. 'price_unit': cls.product_so.list_price})],
  20. 'pricelist_id': cls.partner.property_product_pricelist.id,
  21. 'analytic_account_id': cls.contract.id,
  22. 'date_order': '2016-02-15',
  23. })
  24. def test_not_sale_invoicing(self):
  25. self.contract.invoicing_sales = False
  26. self.sale_order.action_confirm()
  27. self.contract.recurring_create_invoice()
  28. self.assertEqual(self.sale_order.invoice_status, 'to invoice')
  29. def test_sale_invoicing(self):
  30. self.contract.invoicing_sales = True
  31. self.sale_order.action_confirm()
  32. self.contract.recurring_create_invoice()
  33. self.assertEqual(self.sale_order.invoice_status, 'invoiced')
  34. def test_contract_sale_invoicing_without(self):
  35. self.contract.invoicing_sales = True
  36. self.sale_order.analytic_account_id = False
  37. self.sale_order.action_confirm()
  38. self.contract.recurring_create_invoice()
  39. self.assertEqual(self.sale_order.invoice_status, 'to invoice')