From 07da48216f20d9c4944d99bb7a7b41c679a5e770 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 13 Aug 2019 13:05:01 +0000 Subject: [PATCH] [FIX] stock_account: coherent field type In case `move_line_ids.location_id.company_id` or `move_line_ids.location_dest_id.company_id` is not set, the fallback value is `False`. Indeed: ``` >>> True and False or True True ``` This makes `company_from.id` or `company_to.id` crash. We keep the logic but change the condition: ``` >>> False if True else True False ``` opw-2045628 closes odoo/odoo#35695 Signed-off-by: Nicolas Martinelli (nim) --- addons/stock_account/models/stock.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index c744638bcff..c9ae09db69a 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -680,8 +680,8 @@ class StockMove(models.Model): location_from = self.location_id location_to = self.location_dest_id - company_from = self._is_out() and self.mapped('move_line_ids.location_id.company_id') or False - company_to = self._is_in() and self.mapped('move_line_ids.location_dest_id.company_id') or False + company_from = self.mapped('move_line_ids.location_id.company_id') if self._is_out() else False + company_to = self.mapped('move_line_ids.location_dest_id.company_id') if self._is_in() else False # Create Journal Entry for products arriving in the company; in case of routes making the link between several # warehouse of the same company, the transit location belongs to this company, so we don't need to create accounting entries