From 669cbe3c36ec4a31a7be834a60f2e85640c97d5e Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 18 Jul 2017 14:28:55 +0200 Subject: [PATCH] [REF] stock: quant's company_id A quant's company_id is now related to the company_id of its location. We make it store so that filters can work with it. We remove the default because the location's company_id has one, and it's possible that we introduce quants in some non-internal locations (like intercompany transit) that do not have a company_id set. --- addons/stock/models/stock_quant.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index fa8d12bb2b9..383b6bfedeb 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -19,11 +19,8 @@ class StockQuant(models.Model): product_uom_id = fields.Many2one( 'product.uom', 'Unit of Measure', readonly=True, related='product_id.uom_id') - company_id = fields.Many2one( - 'res.company', 'Company', - default=lambda self: self.env['res.company']._company_default_get('stock.quant'), - help='The company to which the quants belong', - readonly=True, required=True) + company_id = fields.Many2one(related='location_id.company_id', + string='Company', store=True, readonly=True) location_id = fields.Many2one( 'stock.location', 'Location', auto_join=True, ondelete='restrict', readonly=True, required=True)