From 2851fbdb4d01099723d55e52da98ebbea3dd7c96 Mon Sep 17 00:00:00 2001 From: Thierry Ducrest Date: Thu, 2 Feb 2023 16:32:16 +0100 Subject: [PATCH] Fix stock_release_channel_auto_release backward port to 14 --- .../models/stock_picking.py | 9 +++++++++ .../migrations/{16.0.1.0.1 => 14.0.1.3.0}/pre-migrate.py | 0 .../views/stock_release_channel_views.xml | 1 + stock_release_channel_auto_release/__manifest__.py | 2 +- .../models/stock_release_channel.py | 2 +- .../tests/test_channel_release_auto.py | 2 +- 6 files changed, 13 insertions(+), 3 deletions(-) rename stock_release_channel/migrations/{16.0.1.0.1 => 14.0.1.3.0}/pre-migrate.py (100%) diff --git a/stock_available_to_promise_release/models/stock_picking.py b/stock_available_to_promise_release/models/stock_picking.py index c6406152199..e2d9bd53b56 100644 --- a/stock_available_to_promise_release/models/stock_picking.py +++ b/stock_available_to_promise_release/models/stock_picking.py @@ -31,6 +31,15 @@ class StockPicking(models.Model): city = fields.Char(related="partner_id.city", store=True) last_release_date = fields.Datetime() + set_printed_at_release = fields.Boolean(compute="_compute_set_printed_at_release") + + @api.depends("move_lines") + def _compute_set_printed_at_release(self): + for picking in self: + picking.set_printed_at_release = not ( + any(picking.move_lines.mapped("rule_id.no_backorder_at_release")) + ) + @api.depends("move_lines.need_release") def _compute_need_release(self): data = self.env["stock.move"].read_group( diff --git a/stock_release_channel/migrations/16.0.1.0.1/pre-migrate.py b/stock_release_channel/migrations/14.0.1.3.0/pre-migrate.py similarity index 100% rename from stock_release_channel/migrations/16.0.1.0.1/pre-migrate.py rename to stock_release_channel/migrations/14.0.1.3.0/pre-migrate.py diff --git a/stock_release_channel/views/stock_release_channel_views.xml b/stock_release_channel/views/stock_release_channel_views.xml index aca1558cd9a..5bfba064bff 100644 --- a/stock_release_channel/views/stock_release_channel_views.xml +++ b/stock_release_channel/views/stock_release_channel_views.xml @@ -181,6 +181,7 @@ create="0" > + diff --git a/stock_release_channel_auto_release/__manifest__.py b/stock_release_channel_auto_release/__manifest__.py index 59d41a2fb3d..3108faac7f5 100644 --- a/stock_release_channel_auto_release/__manifest__.py +++ b/stock_release_channel_auto_release/__manifest__.py @@ -5,7 +5,7 @@ "name": "Stock Release Channel Auto Release", "summary": """ Add an automatic release mode to the release channel""", - "version": "16.0.1.0.0", + "version": "14.0.1.0.0", "license": "AGPL-3", "author": "ACSONE SA/NV,Odoo Community Association (OCA)", "website": "https://github.com/OCA/wms", diff --git a/stock_release_channel_auto_release/models/stock_release_channel.py b/stock_release_channel_auto_release/models/stock_release_channel.py index 19458212b89..f7c13b576f1 100644 --- a/stock_release_channel_auto_release/models/stock_release_channel.py +++ b/stock_release_channel_auto_release/models/stock_release_channel.py @@ -58,7 +58,7 @@ def write(self, vals): res = super().write(vals) release_mode = vals.get("release_mode") if release_mode == "auto": - self.invalidate_recordset(["is_auto_release_allowed"]) + self.invalidate_cache(["is_auto_release_allowed"]) self.auto_release_all() return res diff --git a/stock_release_channel_auto_release/tests/test_channel_release_auto.py b/stock_release_channel_auto_release/tests/test_channel_release_auto.py index 73e7e0009c6..16c53273289 100644 --- a/stock_release_channel_auto_release/tests/test_channel_release_auto.py +++ b/stock_release_channel_auto_release/tests/test_channel_release_auto.py @@ -18,7 +18,7 @@ def setUpClass(cls): cls._update_qty_in_location(cls.loc_bin1, cls.product2, 1000.0) # invalidate cache for computed fields bases on qty in stock - cls.env.invalidate_all() + cls.env["product.product"].invalidate_cache() @contextmanager def assert_release_job_enqueued(self, channel):