From 33392f39e245a215313cc54cfa8ce7533278310b Mon Sep 17 00:00:00 2001 From: "Ioan Galan (Studio73)" Date: Thu, 9 May 2024 16:46:06 +0200 Subject: [PATCH] [MIG] account_invoice_production_lot: Migration to 17.0 --- .../__manifest__.py | 4 +-- .../models/__init__.py | 2 +- ...ccount_invoice.py => account_move_line.py} | 2 +- .../report/report_invoice.xml | 30 +++++++------------ .../tests/test_invoice_production_lot.py | 22 +++++--------- ...voice_views.xml => account_move_views.xml} | 0 6 files changed, 23 insertions(+), 37 deletions(-) rename account_invoice_production_lot/models/{account_invoice.py => account_move_line.py} (94%) rename account_invoice_production_lot/views/{account_invoice_views.xml => account_move_views.xml} (100%) diff --git a/account_invoice_production_lot/__manifest__.py b/account_invoice_production_lot/__manifest__.py index d78fae932..6e067ce49 100644 --- a/account_invoice_production_lot/__manifest__.py +++ b/account_invoice_production_lot/__manifest__.py @@ -7,14 +7,14 @@ { "name": "Invoice Production Lots", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "author": "Agile Business Group," "Tecnativa," "Odoo Community Association (OCA)", "summary": "Display delivered serial numbers in invoice", "website": "https://github.com/OCA/account-invoice-reporting", "license": "AGPL-3", "category": "Accounting & Finance", "depends": ["account", "stock_picking_invoice_link", "sale_management"], - "data": ["views/account_invoice_views.xml", "report/report_invoice.xml"], + "data": ["views/account_move_views.xml", "report/report_invoice.xml"], "demo": ["demo/sale.xml"], "installable": True, } diff --git a/account_invoice_production_lot/models/__init__.py b/account_invoice_production_lot/models/__init__.py index 6834786a7..4ac3c4794 100644 --- a/account_invoice_production_lot/models/__init__.py +++ b/account_invoice_production_lot/models/__init__.py @@ -1,3 +1,3 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from . import account_invoice +from . import account_move_line diff --git a/account_invoice_production_lot/models/account_invoice.py b/account_invoice_production_lot/models/account_move_line.py similarity index 94% rename from account_invoice_production_lot/models/account_invoice.py rename to account_invoice_production_lot/models/account_move_line.py index f9a712fe7..0f7bd6ff1 100644 --- a/account_invoice_production_lot/models/account_invoice.py +++ b/account_invoice_production_lot/models/account_move_line.py @@ -25,5 +25,5 @@ def lots_grouped_by_quantity(self): lot_dict = defaultdict(float) for sml in self.mapped("move_line_ids.move_line_ids"): if sml.lot_id: - lot_dict[sml.lot_id.name] += sml.qty_done + lot_dict[sml.lot_id.name] += sml.quantity return lot_dict diff --git a/account_invoice_production_lot/report/report_invoice.xml b/account_invoice_production_lot/report/report_invoice.xml index 3d5bae5ec..3d025d1c1 100644 --- a/account_invoice_production_lot/report/report_invoice.xml +++ b/account_invoice_production_lot/report/report_invoice.xml @@ -12,29 +12,21 @@ - - +
- - -
-
- Serial numbers -
+ Serial numbers + +
+
+ ()
- -
-
- () -
-
-
- - - +
+
+
diff --git a/account_invoice_production_lot/tests/test_invoice_production_lot.py b/account_invoice_production_lot/tests/test_invoice_production_lot.py index d004ea051..10a988187 100644 --- a/account_invoice_production_lot/tests/test_invoice_production_lot.py +++ b/account_invoice_production_lot/tests/test_invoice_production_lot.py @@ -66,18 +66,13 @@ def setUpClass(cls): "company_id": cls.user_company.id, } ) + cls.location = cls.env.ref("stock.stock_location_stock") def qty_on_hand(self, product, quantity, lot): """Update Product quantity.""" - res = product.action_update_quantity_on_hand() - stock_quant_form = Form( - self.env["stock.quant"].with_context(**res["context"]), - view="stock.view_stock_quant_tree_inventory_editable", + self.env["stock.quant"]._update_available_quantity( + product, self.location, lot_id=lot, quantity=quantity ) - stock_quant_form.inventory_quantity = quantity - stock_quant_form.lot_id = lot - quant = stock_quant_form.save() - quant.action_apply_inventory() def test_00_sale_stock_invoice_product_lot(self): # update quantities with their related lots @@ -89,9 +84,7 @@ def test_00_sale_stock_invoice_product_lot(self): picking = self.sale.picking_ids[:1] picking.action_confirm() picking.action_assign() - for sml in picking.move_ids.mapped("move_line_ids"): - sml.qty_done = sml.reserved_qty - picking._action_done() + picking.button_validate() # create invoice invoice = self.sale._create_invoices() self.assertEqual(len(invoice.invoice_line_ids), 2) @@ -115,7 +108,8 @@ def test_01_sale_stock_delivery_partial_invoice_product_lot(self): picking.action_confirm() picking.action_assign() # deliver partially only one lot - picking.move_ids[0].move_line_ids[0].write({"qty_done": 2.0}) + picking.move_ids[0].move_line_ids[0].write({"quantity": 2.0}) + picking.move_ids[0].move_line_ids[1].write({"quantity": 0.0}) backorder_wizard_dict = picking.button_validate() backorder_wiz = Form( self.env[backorder_wizard_dict["res_model"]].with_context( @@ -145,8 +139,8 @@ def test_02_sale_stock_delivery_partial_invoice_product_lot(self): picking.action_confirm() picking.action_assign() # deliver partially both lots - picking.move_ids[0].move_line_ids[0].write({"qty_done": 1.0}) - picking.move_ids[0].move_line_ids[1].write({"qty_done": 1.0}) + picking.move_ids[0].move_line_ids[0].write({"quantity": 1.0}) + picking.move_ids[0].move_line_ids[1].write({"quantity": 1.0}) backorder_wizard_dict = picking.button_validate() backorder_wiz = Form( self.env[backorder_wizard_dict["res_model"]].with_context( diff --git a/account_invoice_production_lot/views/account_invoice_views.xml b/account_invoice_production_lot/views/account_move_views.xml similarity index 100% rename from account_invoice_production_lot/views/account_invoice_views.xml rename to account_invoice_production_lot/views/account_move_views.xml