From 71f1ca16aa6fc75745964e8669102778132c32bd Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 14 Dec 2022 16:19:50 +0100 Subject: [PATCH] [MIG] sale_force_invoiced to v16 The force_invoiced field is now tracked in the chatter and hidden on quotations --- sale_force_invoiced/__manifest__.py | 4 ++-- sale_force_invoiced/model/sale_order.py | 5 +++-- .../tests/test_sale_force_invoiced.py | 16 +--------------- .../view/{sale_view.xml => sale_order.xml} | 7 ++++++- .../odoo/addons/sale_force_invoiced | 1 + setup/sale_force_invoiced/setup.py | 6 ++++++ 6 files changed, 19 insertions(+), 20 deletions(-) rename sale_force_invoiced/view/{sale_view.xml => sale_order.xml} (60%) create mode 120000 setup/sale_force_invoiced/odoo/addons/sale_force_invoiced create mode 100644 setup/sale_force_invoiced/setup.py diff --git a/sale_force_invoiced/__manifest__.py b/sale_force_invoiced/__manifest__.py index 3796b8f674e1..b736e0701c3f 100644 --- a/sale_force_invoiced/__manifest__.py +++ b/sale_force_invoiced/__manifest__.py @@ -4,12 +4,12 @@ { "name": "Sale Force Invoiced", "summary": "Allows to force the invoice status of the sales order to Invoiced", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "author": "ForgeFlow, Odoo Community Association (OCA)", "category": "sale", "license": "AGPL-3", "website": "https://github.com/OCA/sale-workflow", "depends": ["sale"], - "data": ["view/sale_view.xml"], + "data": ["view/sale_order.xml"], "installable": True, } diff --git a/sale_force_invoiced/model/sale_order.py b/sale_force_invoiced/model/sale_order.py index 5cce6dc47f1c..a985b82d0fac 100644 --- a/sale_force_invoiced/model/sale_order.py +++ b/sale_force_invoiced/model/sale_order.py @@ -13,12 +13,13 @@ class SaleOrder(models.Model): "quantities pending to invoice.", readonly=True, states={"done": [("readonly", False)], "sale": [("readonly", False)]}, + tracking=20, copy=False, ) @api.depends("force_invoiced") - def _get_invoice_status(self): - res = super(SaleOrder, self)._get_invoice_status() + def _compute_invoice_status(self): + res = super()._compute_invoice_status() for order in self.filtered( lambda so: so.force_invoiced and so.state in ("sale", "done") ): diff --git a/sale_force_invoiced/tests/test_sale_force_invoiced.py b/sale_force_invoiced/tests/test_sale_force_invoiced.py index 62a26e5e8c13..5f198495b8c6 100644 --- a/sale_force_invoiced/tests/test_sale_force_invoiced.py +++ b/sale_force_invoiced/tests/test_sale_force_invoiced.py @@ -37,20 +37,6 @@ def _create_product(self, name, product_ctg): ) return product - def _create_invoice_from_sale(self, sale): - payment = self.env["sale.advance.payment.inv"].create( - {"advance_payment_method": "delivered"} - ) - sale_context = { - "active_id": sale.id, - "active_ids": sale.ids, - "active_model": "sale.order", - "open_invoices": True, - } - res = payment.with_context(**sale_context).create_invoices() - invoice_id = res["res_id"] - return invoice_id - def test_sales_order(self): so = self.sale_order_model.create({"partner_id": self.customer.id}) sol1 = self.sale_order_line_model.create( @@ -70,7 +56,7 @@ def test_sales_order(self): so.invoice_status, "to invoice", "The invoice status should be To Invoice" ) - self._create_invoice_from_sale(so) + so._create_invoices() self.assertEqual( so.invoice_status, "invoiced", "The invoice status should be Invoiced" ) diff --git a/sale_force_invoiced/view/sale_view.xml b/sale_force_invoiced/view/sale_order.xml similarity index 60% rename from sale_force_invoiced/view/sale_view.xml rename to sale_force_invoiced/view/sale_order.xml index e7c088f1ac7f..cc87d025a36b 100644 --- a/sale_force_invoiced/view/sale_view.xml +++ b/sale_force_invoiced/view/sale_order.xml @@ -6,7 +6,12 @@ - + diff --git a/setup/sale_force_invoiced/odoo/addons/sale_force_invoiced b/setup/sale_force_invoiced/odoo/addons/sale_force_invoiced new file mode 120000 index 000000000000..ebdbad1ebfbb --- /dev/null +++ b/setup/sale_force_invoiced/odoo/addons/sale_force_invoiced @@ -0,0 +1 @@ +../../../../sale_force_invoiced \ No newline at end of file diff --git a/setup/sale_force_invoiced/setup.py b/setup/sale_force_invoiced/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/sale_force_invoiced/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)