From 9e0f8c04d3ac95e16e790e6b963165e09ad9ada0 Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" <tic@odoo.com> Date: Mon, 22 Feb 2021 12:46:45 +0000 Subject: [PATCH] [FIX] stock: make package level package consistent v2 Commit e5ab8cf9623bc436f43706926bc6ee596c549244 missed a use case. Steps to reproduce: - Activiate "Packages" setting in Inventory - Configure an operation type to "Move Entire Packages" - Create a "Planned Transfer" picking with that operation type and add a package to be moved - Turn off "Move Entire Packages" and try set the destination package of the move line to nothing (False). Expected result: Move line has no destination package + package level is deleted as expected. Another bug will still exist due to the design of package_level where if in addition to the above use case, if a different package is used instead of deleting it and "Move Entire Packages" is reactived => final package shown in the Detailed Operations will show all move lines as being part of the same package even though they are not. Data appears to be correct in the database otherwise and a reasonable fix doesn't seem feasible for now so we leave this bug as is. Related to Task: 2418907 closes odoo/odoo#66619 Fixes: odoo/odoo#66542 Fixes: odoo/odoo#66517 X-original-commit: a73505ddafe9ce6f4f3e9896494900d419a815bd Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com> --- addons/stock/models/stock_package_level.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/stock_package_level.py b/addons/stock/models/stock_package_level.py index 120ba40edd69..49f9cbc677bb 100644 --- a/addons/stock/models/stock_package_level.py +++ b/addons/stock/models/stock_package_level.py @@ -156,7 +156,7 @@ class StockPackageLevel(models.Model): return result def unlink(self): - self.mapped('move_ids').unlink() + self.mapped('move_ids').write({'package_level_id': False}) self.mapped('move_line_ids').write({'result_package_id': False}) return super(StockPackageLevel, self).unlink() -- GitLab