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.

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