From 7e48298d7c9cf4e3ae2a10d202b634ee311d81d0 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Wed, 2 Aug 2023 11:45:59 +0200 Subject: [PATCH] [MIG] stock_warehouse_flow: Migration to 16.0 --- stock_warehouse_flow/__manifest__.py | 4 +- .../demo/stock_warehouse_flow.xml | 2 +- .../migrations/14.0.1.0.1/pre-migrate.py | 23 --------- stock_warehouse_flow/models/__init__.py | 2 +- ...stock_location_route.py => stock_route.py} | 4 +- .../models/stock_warehouse_flow.py | 7 ++- stock_warehouse_flow/tests/common.py | 6 +-- ...ock_location_route.xml => stock_route.xml} | 2 +- .../views/stock_warehouse_flow.xml | 47 ++++++++++--------- 9 files changed, 39 insertions(+), 58 deletions(-) delete mode 100644 stock_warehouse_flow/migrations/14.0.1.0.1/pre-migrate.py rename stock_warehouse_flow/models/{stock_location_route.py => stock_route.py} (91%) rename stock_warehouse_flow/views/{stock_location_route.xml => stock_route.xml} (91%) diff --git a/stock_warehouse_flow/__manifest__.py b/stock_warehouse_flow/__manifest__.py index 96f9af4e44..2ea0ca9f77 100644 --- a/stock_warehouse_flow/__manifest__.py +++ b/stock_warehouse_flow/__manifest__.py @@ -6,7 +6,7 @@ "author": "Camptocamp, BCIM, Odoo Community Association (OCA)", "website": "https://github.com/OCA/wms", "category": "Warehouse Management", - "version": "14.0.2.0.0", + "version": "16.0.1.0.0", "license": "AGPL-3", "depends": [ # core @@ -20,7 +20,7 @@ ], "data": [ "security/ir.model.access.csv", - "views/stock_location_route.xml", + "views/stock_route.xml", "views/stock_warehouse_flow.xml", "views/stock_warehouse.xml", "views/delivery_carrier.xml", diff --git a/stock_warehouse_flow/demo/stock_warehouse_flow.xml b/stock_warehouse_flow/demo/stock_warehouse_flow.xml index 0cb0792b49..6467296d58 100644 --- a/stock_warehouse_flow/demo/stock_warehouse_flow.xml +++ b/stock_warehouse_flow/demo/stock_warehouse_flow.xml @@ -31,7 +31,7 @@ NORMAL diff --git a/stock_warehouse_flow/migrations/14.0.1.0.1/pre-migrate.py b/stock_warehouse_flow/migrations/14.0.1.0.1/pre-migrate.py deleted file mode 100644 index 06e4a629fe..0000000000 --- a/stock_warehouse_flow/migrations/14.0.1.0.1/pre-migrate.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2022 Camptocamp SA -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) - - -def migrate(cr, installed_version): - if not installed_version: - return - # 'output_stock_loc_id' became a related+readonly field and has been - # replaced by 'to_output_stock_loc_id' - queries = [ - """ - ALTER TABLE stock_warehouse_flow - ADD COLUMN to_output_stock_loc_id INT - REFERENCES stock_location(id) - ON DELETE RESTRICT; - """, - """ - UPDATE stock_warehouse_flow - SET to_output_stock_loc_id = output_stock_loc_id; - """, - ] - for query in queries: - cr.execute(query) diff --git a/stock_warehouse_flow/models/__init__.py b/stock_warehouse_flow/models/__init__.py index c99144f97d..81ef39aad3 100644 --- a/stock_warehouse_flow/models/__init__.py +++ b/stock_warehouse_flow/models/__init__.py @@ -1,5 +1,5 @@ from . import stock_warehouse_flow from . import stock_warehouse from . import stock_move -from . import stock_location_route +from . import stock_route from . import delivery_carrier diff --git a/stock_warehouse_flow/models/stock_location_route.py b/stock_warehouse_flow/models/stock_route.py similarity index 91% rename from stock_warehouse_flow/models/stock_location_route.py rename to stock_warehouse_flow/models/stock_route.py index 859b705d8b..f5185927ea 100644 --- a/stock_warehouse_flow/models/stock_location_route.py +++ b/stock_warehouse_flow/models/stock_route.py @@ -4,8 +4,8 @@ from odoo import api, fields, models -class StockLocationRoute(models.Model): - _inherit = "stock.location.route" +class StockRoute(models.Model): + _inherit = "stock.route" flow_id = fields.Many2one( comodel_name="stock.warehouse.flow", diff --git a/stock_warehouse_flow/models/stock_warehouse_flow.py b/stock_warehouse_flow/models/stock_warehouse_flow.py index 938995b849..e7932464c1 100644 --- a/stock_warehouse_flow/models/stock_warehouse_flow.py +++ b/stock_warehouse_flow/models/stock_warehouse_flow.py @@ -99,7 +99,7 @@ class StockWarehouseFlow(models.Model): ) ) delivery_route_id = fields.Many2one( - comodel_name="stock.location.route", + comodel_name="stock.route", string="Delivery Route", ondelete="set null", readonly=True, @@ -111,7 +111,7 @@ class StockWarehouseFlow(models.Model): string="Rules", ) impacted_route_ids = fields.One2many( - comodel_name="stock.location.route", + comodel_name="stock.route", compute="_compute_impacted_route_ids", string="Impacted Routes", ) @@ -144,7 +144,6 @@ class StockWarehouseFlow(models.Model): ), ) qty = fields.Float( - "Qty", default=0, help="If a qty is set the flow can be applied on moves " "where the move's qty >= the qty set on the flow\n", @@ -366,7 +365,7 @@ def _generate_delivery_route(self): "sequence": 1000, } ) - self.delivery_route_id = self.env["stock.location.route"].create(vals) + self.delivery_route_id = self.env["stock.route"].create(vals) # Subscribe the route to the warehouse if self.delivery_route_id.warehouse_selectable: self.warehouse_id.route_ids |= self.delivery_route_id diff --git a/stock_warehouse_flow/tests/common.py b/stock_warehouse_flow/tests/common.py index 45e68e5994..a804529ae8 100644 --- a/stock_warehouse_flow/tests/common.py +++ b/stock_warehouse_flow/tests/common.py @@ -3,10 +3,10 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) from odoo import fields -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase -class CommonFlow(SavepointCase): +class CommonFlow(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -67,7 +67,7 @@ def _run_procurement(self, product, qty, carrier=None): def _validate_picking(self, picking): for move_line in picking.move_line_ids: - move_line.qty_done = move_line.product_uom_qty + move_line.qty_done = move_line.reserved_uom_qty picking._action_done() def _prepare_split_test(self, qty=None): diff --git a/stock_warehouse_flow/views/stock_location_route.xml b/stock_warehouse_flow/views/stock_route.xml similarity index 91% rename from stock_warehouse_flow/views/stock_location_route.xml rename to stock_warehouse_flow/views/stock_route.xml index e32f8edfc9..f2802dc786 100644 --- a/stock_warehouse_flow/views/stock_location_route.xml +++ b/stock_warehouse_flow/views/stock_route.xml @@ -5,7 +5,7 @@ stock.location.route.tree.inherit - stock.location.route + stock.route diff --git a/stock_warehouse_flow/views/stock_warehouse_flow.xml b/stock_warehouse_flow/views/stock_warehouse_flow.xml index 909377a1da..d54d53efc8 100644 --- a/stock_warehouse_flow/views/stock_warehouse_flow.xml +++ b/stock_warehouse_flow/views/stock_warehouse_flow.xml @@ -16,18 +16,24 @@ attrs="{'invisible': [('active', '=', True)]}" />
-
- - - - - + + + + + + + + + @@ -35,11 +41,10 @@ colspan="2" attrs="{'invisible': [('from_picking_type_id', '=', False)]}" > - - => - - to - + => + + to +
- - - + @@ -195,18 +200,18 @@ - - -