From d44b95fd45df0ee96bd2afcc8d3405f2dfe5c7f5 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Thu, 10 Sep 2020 14:43:03 +0000 Subject: [PATCH] [FIX] stock: empty reusable package When using reusable package in chained transfers, indicates the package should not be propagated for the next moves `result_package_id`. This change has no effect by itself, but it's used in enterprise by https://github.com/odoo/enterprise/pull/13146/commits/611b2c0b188ab9906eb21feab087a1794bd2d015 when Picking Batch is enabled and barcode app is installed. task-2333834 X-original-commit: 6677f501d5a1717af8da08a7e235d87aeb85f862 --- addons/stock/models/stock_picking.py | 8 +++++--- addons/stock/models/stock_quant.py | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 42c4eeea620..85cd74b2651 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -848,9 +848,11 @@ class Picking(models.Model): 'move_line_ids': [(6, 0, move_lines_to_pack.ids)], 'company_id': picking.company_id.id, }) - move_lines_to_pack.write({ - 'result_package_id': pack.id, - }) + # TODO: in master, move package field in `stock` and clean code. + if pack._allowed_to_move_between_transfers(): + move_lines_to_pack.write({ + 'result_package_id': pack.id, + }) else: move_lines_in_package_level = move_lines_to_pack.filtered(lambda ml: ml.move_id.package_level_id) move_lines_without_package_level = move_lines_to_pack - move_lines_in_package_level diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 1403f08a1ef..ef7e966f9cb 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -729,3 +729,6 @@ class QuantPackage(models.Model): def _get_contained_quants(self): return self.env['stock.quant'].search([('package_id', 'in', self.ids)]) + + def _allowed_to_move_between_transfers(self): + return True