From d519082137db819cd3779142c4996a4f194704ca Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Thu, 26 Jul 2018 02:01:35 +0200 Subject: [PATCH] [FIX] stock: fix module installation In case there are multiple companies that need to call create_transit_location() at the installation of module, orm was crashing because expecting a singleton when doing self.partner_id or self.id --- addons/stock/models/res_company.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/stock/models/res_company.py b/addons/stock/models/res_company.py index 58c61be714f..28a10509d52 100644 --- a/addons/stock/models/res_company.py +++ b/addons/stock/models/res_company.py @@ -28,11 +28,11 @@ class Company(models.Model): location.sudo().write({'company_id': company.id}) company.write({'internal_transit_location_id': location.id}) - warehouses = self.env['stock.warehouse'].search([('partner_id', '=', self.partner_id.id)]) - warehouses.mapped('partner_id').with_context(force_company=self.id).write({ - 'property_stock_customer': location.id, - 'property_stock_supplier': location.id, - }) + warehouses = self.env['stock.warehouse'].search([('partner_id', '=', company.partner_id.id)]) + warehouses.mapped('partner_id').with_context(force_company=company.id).write({ + 'property_stock_customer': location.id, + 'property_stock_supplier': location.id, + }) @api.model def create(self, vals):