From b5e8f85eaa315ef59a20a13917542a160b959c13 Mon Sep 17 00:00:00 2001 From: Jinjiu Liu Date: Wed, 5 Oct 2022 07:55:49 +0000 Subject: [PATCH] [FIX] *: missing date filter for stat button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reproduction: 1. Install Sale, Inventory 2. Go to Sale->products, search for “Customizable Desk” 3. Hover the cursor on the stat button “Sold”, from its definition, the analysis should show the sold items in last 365 days 4. Click on the “Sold” button, no filter for “Order Date” Reason: in V14, the “time_ranges” feature is removed. Thus using it in the context won’t create any filter for searching Fix: We use a custom filter to replace the time range "last_365_days". We also make sure that the domain produced by that filter is the same as the one used to compute the button count server side (this was not the case in Odoo 13 when "last_365_days" was used). Similar fix is also done in mrp and l10n_ar. Mind the utc convert for correct results. opw-3000595 Related commits: Removal of time_ranges: https://github.com/odoo-dev/odoo/commit/be5a51a345b8986da0e19627260f64f984e11ae9 Date filter fix: https://github.com/odoo/enterprise/pull/10938 closes odoo/odoo#108951 X-original-commit: 03057029b210a59f3d7012aeea66cfa95790a8c8 Signed-off-by: Mathieu Duckerts-Antoine Signed-off-by: Liu Jinjiu (jili) --- addons/l10n_ar/report/invoice_report_view.xml | 5 +++-- addons/mrp/models/product.py | 2 +- addons/mrp/views/mrp_production_views.xml | 1 + addons/sale/models/product_product.py | 2 +- addons/sale/models/product_template.py | 2 +- addons/sale/report/sale_report_views.xml | 1 + 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/addons/l10n_ar/report/invoice_report_view.xml b/addons/l10n_ar/report/invoice_report_view.xml index 1f760c0be4f..8e74fa67d71 100644 --- a/addons/l10n_ar/report/invoice_report_view.xml +++ b/addons/l10n_ar/report/invoice_report_view.xml @@ -9,6 +9,7 @@ + @@ -21,7 +22,7 @@ IIBB - Sales by jurisdiction account.invoice.report pivot - {'search_default_current': 1, 'search_default_customer': 1, 'search_default_with_document': 1, 'search_default_company': 1, 'search_default_groupby_l10n_ar_state_id': 2, 'search_default_groupby_account_id': 3, 'time_ranges': {'field': 'date', 'range': 'this_year'}} + {'search_default_current': 1, 'search_default_customer': 1, 'search_default_with_document': 1, 'search_default_company': 1, 'search_default_groupby_l10n_ar_state_id': 2, 'search_default_groupby_account_id': 3, 'search_default_filter_accounting_date_this_year': 1} IIBB - Purchases by jurisdiction account.invoice.report pivot - {'search_default_current': 1, 'search_default_supplier': 1, 'search_default_with_document': 1, 'search_default_company': 1, 'search_default_groupby_l10n_ar_state_id': 2, 'search_default_groupby_account_id': 3, 'time_ranges': {'field': 'date', 'range': 'this_year'}} + {'search_default_current': 1, 'search_default_supplier': 1, 'search_default_with_document': 1, 'search_default_company': 1, 'search_default_groupby_l10n_ar_state_id': 2, 'search_default_groupby_account_id': 3, 'search_default_filter_accounting_date_this_year': 1} + diff --git a/addons/sale/models/product_product.py b/addons/sale/models/product_product.py index d512457656a..4a519537146 100644 --- a/addons/sale/models/product_product.py +++ b/addons/sale/models/product_product.py @@ -50,7 +50,7 @@ class ProductProduct(models.Model): 'active_id': self._context.get('active_id'), 'search_default_Sales': 1, 'active_model': 'sale.report', - 'time_ranges': {'field': 'date', 'range': 'last_365_days'}, + 'search_default_filter_order_date': 1, } return action diff --git a/addons/sale/models/product_template.py b/addons/sale/models/product_template.py index 7cd6b8e3dbc..f95ca313b61 100644 --- a/addons/sale/models/product_template.py +++ b/addons/sale/models/product_template.py @@ -88,7 +88,7 @@ class ProductTemplate(models.Model): 'active_id': self._context.get('active_id'), 'active_model': 'sale.report', 'search_default_Sales': 1, - 'time_ranges': {'field': 'date', 'range': 'last_365_days'} + 'search_default_filter_order_date': 1, } return action diff --git a/addons/sale/report/sale_report_views.xml b/addons/sale/report/sale_report_views.xml index 946c0cb6cf9..2a607f0f906 100644 --- a/addons/sale/report/sale_report_views.xml +++ b/addons/sale/report/sale_report_views.xml @@ -54,6 +54,7 @@ +