From 1ad72def2a83b2553a49495683dc226ee41bd2c6 Mon Sep 17 00:00:00 2001 From: Shweta Goltar Date: Mon, 28 Jun 2021 13:09:41 +0000 Subject: [PATCH] [IMP] product: improve for the pricelist report PURPOSE ------ In the new pricelist report, showing the resulting price of a product in the situation of a pricelist or another, for certain quantities, the specified quantities are shown as "X Units". This can be misleading when using multiple Unit of Measure, because the quantites are expressed in the products unit of measures, thus not always in "Units". We should probably either group the products by UoM, to display adequates column titles, or we should update the display to make sure the user understands clearly that the prices are /unit in the product uom. users should be able to 'hide' pricelist name on the PDF. TaskID-2360597 --- .../product/report/product_pricelist_report.py | 8 ++++++-- .../product_pricelist_report_templates.xml | 16 ++++++++++++++-- .../static/src/js/product_pricelist_report.js | 16 +++++++++++++++- .../product/static/src/xml/pricelist_report.xml | 8 +++++++- addons/product/views/product_template_views.xml | 2 +- 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/addons/product/report/product_pricelist_report.py b/addons/product/report/product_pricelist_report.py index 9a0e1ba7148..789fc411626 100644 --- a/addons/product/report/product_pricelist_report.py +++ b/addons/product/report/product_pricelist_report.py @@ -9,22 +9,24 @@ class report_product_pricelist(models.AbstractModel): _description = 'Pricelist Report' def _get_report_values(self, docids, data): + is_visible_title = data['is_visible_title'] and bool(data['is_visible_title']) or False product_ids = [int(i) for i in data['active_ids'].split(',')] pricelist_id = data['pricelist_id'] and int(data['pricelist_id']) or None quantities = [int(i) for i in data['quantities'].split(',')] or [1] - return self._get_report_data(data['active_model'], product_ids, pricelist_id, quantities, 'pdf') + return self._get_report_data(data['active_model'], product_ids, is_visible_title, pricelist_id, quantities, 'pdf') @api.model def get_html(self): render_values = self._get_report_data( self.env.context.get('active_model'), self.env.context.get('active_ids'), + self.env.context.get('is_visible_title'), self.env.context.get('pricelist_id'), self.env.context.get('quantities') or [1] ) return self.env.ref('product.report_pricelist_page')._render(render_values) - def _get_report_data(self, active_model, active_ids, pricelist_id, quantities, report_type='html'): + def _get_report_data(self, active_model, active_ids, is_visible_title, pricelist_id, quantities, report_type='html'): products = [] is_product_tmpl = active_model == 'product.template' @@ -55,6 +57,7 @@ class report_product_pricelist(models.AbstractModel): 'quantities': quantities, 'is_product_tmpl': is_product_tmpl, 'is_html_type': report_type == 'html', + 'is_visible_title': is_visible_title, } def _get_product_data(self, is_product_tmpl, product, pricelist, quantities): @@ -62,6 +65,7 @@ class report_product_pricelist(models.AbstractModel): 'id': product.id, 'name': is_product_tmpl and product.name or product.display_name, 'price': dict.fromkeys(quantities, 0.0), + 'uom': product.uom_id.name, } for qty in quantities: data['price'][qty] = pricelist.get_product_price(product, qty, False) diff --git a/addons/product/report/product_pricelist_report_templates.xml b/addons/product/report/product_pricelist_report_templates.xml index 9a394764cdb..3b13ed591c4 100644 --- a/addons/product/report/product_pricelist_report_templates.xml +++ b/addons/product/report/product_pricelist_report_templates.xml @@ -4,7 +4,7 @@