From d3ef8a958b83a4d54ba927d50b0e07c53be5ad68 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Mon, 26 Aug 2019 12:57:01 +0000 Subject: [PATCH] [FIX] stock: forecast quantity only on warehouse Before this commit, forecasted quantity in the product stat button and in graph/grid view wasn't always equals. The issue was the forecasted quantity is based on quant in location who is child of warehouse location, and the `report.inventory.quantity` used in graph/grid view didn't filter on warehouse location (took all internal location). So, completes the domain on `report.inventory.quantity` to get only quantity in the warehouse. Same change is applied to the Forecasted Inventory report. Task #2058665 --- addons/stock/models/product.py | 10 ++++++++-- addons/stock/report/report_stock_quantity.xml | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 5fa1a87e924..4ca409e225e 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -511,7 +511,10 @@ class Product(models.Model): def action_product_forecast_report(self): action = self.env.ref('stock.report_stock_quantity_action_product').read()[0] - action['domain'] = [('product_id', '=', self.id)] + action['domain'] = [ + ('product_id', '=', self.id), + ('warehouse_id', '!=', False), + ] return action @api.model @@ -779,7 +782,10 @@ class ProductTemplate(models.Model): def action_product_tmpl_forecast_report(self): action = self.env.ref('stock.report_stock_quantity_action').read()[0] - action['domain'] = [('product_id', 'in', self.product_variant_ids.ids)] + action['domain'] = [ + ('product_id', 'in', self.product_variant_ids.ids), + ('warehouse_id', '!=', False), + ] return action class ProductCategory(models.Model): diff --git a/addons/stock/report/report_stock_quantity.xml b/addons/stock/report/report_stock_quantity.xml index f9a2e1c00bb..868f9552105 100644 --- a/addons/stock/report/report_stock_quantity.xml +++ b/addons/stock/report/report_stock_quantity.xml @@ -48,6 +48,7 @@ Forecasted Inventory report.stock.quantity graph + [('warehouse_id', '!=', False)] { 'search_default_filter_forecast': 1, 'graph_groupbys': ['date:day', 'state', 'product_id'],