From 8496ffbc03cbb45ca8a676b8f563f8f1b79f9980 Mon Sep 17 00:00:00 2001 From: Wolfgang Taferner Date: Fri, 7 Feb 2020 20:00:58 +0000 Subject: [PATCH] [FIX] stock: filtered related product_id field will overwrite on create Assume a situation where you trigger a method which is going to create a nested picking with move_lines included and having a filter set which means that your context includes {'default_product_id': 20} { 'location_dest_id': 9, 'location_id': 19, 'move_lines': [(0, 0, {'location_dest_id': 1, 'location_id': 2, 'name': u'name', 'partner_id': 1, 'product_id': 10, 'product_uom': 1, 'product_uom_qty': 1.0})], 'origin': u'Origin', 'partner_id': 1, 'picking_type_id': 59 } Before the creation of the objects it will inject the default product in the top level of the dict which should create a picking with one or more move_lines. Based on this this injection will overwrite all product_id values of the created move lines as the picking is created last and the default value will write ALL move lines with this specific product from the context. closes odoo/odoo#45076 X-original-commit: 1da687b644e581081ce21687c5eb32285c872a2a Signed-off-by: Nicolas Martinelli (nim) --- addons/stock/models/stock_picking.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index fc6a3779da4..ba59869ea1e 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -363,7 +363,8 @@ class Picking(models.Model): is_locked = fields.Boolean(default=True, help='When the picking is not done this allows changing the ' 'initial demand. When the picking is done this allows ' 'changing the done quantities.') - product_id = fields.Many2one('product.product', 'Product', related='move_lines.product_id', readonly=False) + # Used to search on pickings + product_id = fields.Many2one('product.product', 'Product', related='move_lines.product_id', readonly=True) show_operations = fields.Boolean(compute='_compute_show_operations') show_reserved = fields.Boolean(related='picking_type_id.show_reserved') show_lots_text = fields.Boolean(compute='_compute_show_lots_text')