From 8c64159b8847dc465a21415c085d6526d280be02 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 17 Apr 2018 18:23:30 +0200 Subject: [PATCH] [FIX] stock_account: valuation report needs company_owned in context When calculating the stock_value of a product, the system will take into account all the locations that have this company as company. (that way if owner_id is not set, the company_id on the location is the owner (virtual: not set)) The Qty on Hand field takes into account however the quantities that are in the warehouses. This could lead to weird situations where the Quantity On Hand is 0 and so the record is not shown, while the stock value is positive. (e.g. stock in Transit) In order to use the same logic for both fields, we pass company_owned=True in the context. --- addons/stock_account/views/product_views.xml | 2 +- addons/stock_account/wizard/stock_quantity_history.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock_account/views/product_views.xml b/addons/stock_account/views/product_views.xml index e6d14d02309..f029db4ce51 100644 --- a/addons/stock_account/views/product_views.xml +++ b/addons/stock_account/views/product_views.xml @@ -95,7 +95,7 @@ form [('type', '=', 'product'), ('qty_available', '!=', 0)] - {} + {'company_owned': True}

If there are products, you will see its name and valuation. diff --git a/addons/stock_account/wizard/stock_quantity_history.py b/addons/stock_account/wizard/stock_quantity_history.py index 6b244d13ac2..fe920a457bb 100644 --- a/addons/stock_account/wizard/stock_quantity_history.py +++ b/addons/stock_account/wizard/stock_quantity_history.py @@ -24,7 +24,7 @@ class StockQuantityHistory(models.TransientModel): 'name': _('Products'), 'res_model': 'product.product', 'domain': "[('type', '=', 'product'), ('qty_available', '!=', 0)]", - 'context': dict(self.env.context, to_date=self.date), + 'context': dict(self.env.context, to_date=self.date, company_owned=True), } return action else: