From ee1ea10c8cc35c13439ef455a0eef454b7abaf85 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Thu, 8 Nov 2018 15:26:07 +0000 Subject: [PATCH] [IMP] stock, mrp, repair: production location for each company Each company should have its own production location to allow specific account on it. TASK-ID: 1882269 --- addons/mrp/models/stock_warehouse.py | 4 +--- addons/mrp/report/report_stock_rule.py | 2 +- addons/repair/data/repair_demo.xml | 6 +++--- addons/repair/tests/test_repair.py | 4 ++-- addons/stock/data/stock_data.xml | 14 +++---------- addons/stock/models/res_company.py | 27 ++++++++++++++++++++++++++ 6 files changed, 37 insertions(+), 20 deletions(-) diff --git a/addons/mrp/models/stock_warehouse.py b/addons/mrp/models/stock_warehouse.py index 7496236882b..a03ab6ddc36 100644 --- a/addons/mrp/models/stock_warehouse.py +++ b/addons/mrp/models/stock_warehouse.py @@ -59,9 +59,7 @@ class StockWarehouse(models.Model): @api.model def _get_production_location(self): - location = self.env.ref('stock.location_production', raise_if_not_found=False) - if not location: - location = self.env['stock.location'].search([('usage', '=', 'production')], limit=1) + location = self.env['stock.location'].with_context(force_company=self.company_id.id).search([('usage', '=', 'production'), ('company_id', '=', self.company_id.id)], limit=1) if not location: raise UserError(_('Can\'t find any production location.')) return location diff --git a/addons/mrp/report/report_stock_rule.py b/addons/mrp/report/report_stock_rule.py index d25960d1183..2f25ca6a6bd 100644 --- a/addons/mrp/report/report_stock_rule.py +++ b/addons/mrp/report/report_stock_rule.py @@ -13,5 +13,5 @@ class ReportStockRule(models.AbstractModel): """ res = super(ReportStockRule, self)._get_rule_loc(rule, product_id) if rule.action == 'manufacture': - res['source'] = product_id.property_stock_production or self.env.ref('stock.location_production') + res['source'] = product_id.property_stock_production return res diff --git a/addons/repair/data/repair_demo.xml b/addons/repair/data/repair_demo.xml index 60616df3fb2..173c86f863b 100644 --- a/addons/repair/data/repair_demo.xml +++ b/addons/repair/data/repair_demo.xml @@ -9,7 +9,7 @@ procurement - - Production - - production - - Vendors @@ -97,11 +91,6 @@ - - property_stock_production - - -