From 7c19d7bea3a5ac0144b33da9deef61604da517f6 Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Mon, 16 Jan 2023 15:06:19 +0630 Subject: [PATCH] [ADD] sale_order_invoicing_policy: add tests --- sale_order_invoicing_policy/__manifest__.py | 2 +- sale_order_invoicing_policy/tests/__init__.py | 1 + .../tests/test_sale_order_invoicing_policy.py | 55 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 sale_order_invoicing_policy/tests/__init__.py create mode 100644 sale_order_invoicing_policy/tests/test_sale_order_invoicing_policy.py diff --git a/sale_order_invoicing_policy/__manifest__.py b/sale_order_invoicing_policy/__manifest__.py index c22baeb..c2d6874 100644 --- a/sale_order_invoicing_policy/__manifest__.py +++ b/sale_order_invoicing_policy/__manifest__.py @@ -5,7 +5,7 @@ "summary": "", "version": "12.0.1.0.0", "category": "Sale", - "website": "https://www.quartile.co/", + "website": "https://www.quartile.co", "author": "Quartile Limited", "license": "AGPL-3", "installable": True, diff --git a/sale_order_invoicing_policy/tests/__init__.py b/sale_order_invoicing_policy/tests/__init__.py new file mode 100644 index 0000000..7efd191 --- /dev/null +++ b/sale_order_invoicing_policy/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sale_order_invoicing_policy diff --git a/sale_order_invoicing_policy/tests/test_sale_order_invoicing_policy.py b/sale_order_invoicing_policy/tests/test_sale_order_invoicing_policy.py new file mode 100644 index 0000000..c5b49b7 --- /dev/null +++ b/sale_order_invoicing_policy/tests/test_sale_order_invoicing_policy.py @@ -0,0 +1,55 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestSaleOrderInvoicingPolicy(TransactionCase): + def setUp(self): + super(TestSaleOrderInvoicingPolicy, self).setUp() + self.partner = self.env.ref("base.res_partner_2") + self.product1 = self.env["product.product"].create( + {"name": "Test Product", "type": "consu"} + ) + + def test_sale_order_invoicing_policy_order(self): + sale_order = self.env["sale.order"].create( + { + "partner_id": self.partner.id, + "invoice_policy": "order", + "order_line": [ + ( + 0, + 0, + { + "product_id": self.product1.id, + "product_uom_qty": 2, + "price_unit": 100, + }, + ) + ], + } + ) + sale_order.action_confirm() + self.assertEqual(sale_order.order_line.qty_to_invoice, 2) + + def test_sale_order_invoicing_policy_delivery(self): + sale_order = self.env["sale.order"].create( + { + "partner_id": self.partner.id, + "invoice_policy": "delivery", + "order_line": [ + ( + 0, + 0, + { + "product_id": self.product1.id, + "product_uom_qty": 2, + "price_unit": 100, + }, + ) + ], + } + ) + sale_order.action_confirm() + self.assertEqual(sale_order.order_line.qty_to_invoice, 0)