From b39173a8ffc4ef5dd5524e027a9f0ad746b07bd8 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Tue, 16 Jul 2019 07:08:58 +0000 Subject: [PATCH] [FIX] stock: edit quant without company id Some quant can have no company_id (quant for partner locations). But when user edit a quant, the stock move `company_id` is based on the quant's one. As the `company_id` is required for a stock move, we force to take the `company_id` of the user in case the quant don't have one. Task #2035465 --- addons/stock/models/stock_quant.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 34d6a20afc9..a0298b4fdbd 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -538,7 +538,7 @@ class StockQuant(models.Model): 'product_id': self.product_id.id, 'product_uom': self.product_uom_id.id, 'product_uom_qty': qty, - 'company_id': self.company_id.id, + 'company_id': self.company_id.id or self.env.user.company_id.id, 'state': 'confirmed', 'location_id': location_id.id, 'location_dest_id': location_dest_id.id, @@ -548,7 +548,7 @@ class StockQuant(models.Model): 'qty_done': qty, 'location_id': location_id.id, 'location_dest_id': location_dest_id.id, - 'company_id': self.company_id.id, + 'company_id': self.company_id.id or self.env.user.company_id.id, 'lot_id': self.lot_id.id, 'package_id': out and self.package_id.id or False, 'result_package_id': (not out) and self.package_id.id or False,