From e01620ce02f775957832ce0e1e6c7e08076754d8 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Thu, 9 Aug 2018 13:12:09 +0200 Subject: [PATCH] [IMP] stock: quant_package owner and company When all quants in a package have the same owner and/or company, the field owner and/or company on quant_package will have the same value as the one on quants. TASK-60709 --- addons/stock/models/stock_quant.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index fbc0832a516..52f91dd424d 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -353,6 +353,10 @@ class QuantPackage(models.Model): values = {'location_id': False, 'company_id': self.env.user.company_id.id, 'owner_id': False} if package.quant_ids: values['location_id'] = package.quant_ids[0].location_id + if all(q.owner_id == package.quant_ids[0].owner_id for q in package.quant_ids): + values['owner_id'] = package.quant_ids[0].owner_id + if all(q.company_id == package.quant_ids[0].company_id for q in package.quant_ids): + values['company_id'] = package.quant_ids[0].company_id package.location_id = values['location_id'] package.company_id = values['company_id'] package.owner_id = values['owner_id']