From 7bc0f90a65ebc32f326f6f5b6885b1ec94d99df1 Mon Sep 17 00:00:00 2001 From: luis Date: Thu, 2 Jan 2025 16:21:34 +0100 Subject: [PATCH] product_print_category_supermarket take prices from 2 configurable pricelist: public and members. include taxes in calculations --- .../models/product_template.py | 13 +++++++++--- .../models/res_config.py | 7 +++++++ .../views/report_pricetag_normal.xml | 20 ++++++++++++++----- .../views/res_config.xml | 4 ++++ .../models/product_template.py | 6 ------ 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/product_print_category_supermarket/models/product_template.py b/product_print_category_supermarket/models/product_template.py index fe667f1..6539b1c 100644 --- a/product_print_category_supermarket/models/product_template.py +++ b/product_print_category_supermarket/models/product_template.py @@ -18,10 +18,17 @@ class ProductTemplate(models.Model): ) pricelist = self.env["product.pricelist"].browse(int(param_value)) price = pricelist._get_product_price(self, 1) - return price + taxes = self.taxes_id.compute_all(price, quantity=1, product=self) + return taxes["total_included"] @api.model def get_price_public(self): - pricelist = self.env.ref("product.list0") + param_value = ( + self.env["ir.config_parameter"] + .sudo() + .get_param("report_label_supermarket.label_public_pricelist") + ) + pricelist = self.env["product.pricelist"].browse(int(param_value)) price = pricelist._get_product_price(self, 1) - return price + taxes = self.taxes_id.compute_all(price, quantity=1, product=self) + return taxes["total_included"] diff --git a/product_print_category_supermarket/models/res_config.py b/product_print_category_supermarket/models/res_config.py index a5d8220..df5aa4d 100644 --- a/product_print_category_supermarket/models/res_config.py +++ b/product_print_category_supermarket/models/res_config.py @@ -10,3 +10,10 @@ class ResConfigSettings(models.TransientModel): string="Pricelist for members", config_parameter="report_label_supermarket.label_pricelist", ) + + label_public_pricelist = fields.Many2one( + required=False, + comodel_name="product.pricelist", + string="Pricelist for public", + config_parameter="report_label_supermarket.label_public_pricelist", + ) diff --git a/product_print_category_supermarket/views/report_pricetag_normal.xml b/product_print_category_supermarket/views/report_pricetag_normal.xml index ac15d03..7e8b672 100644 --- a/product_print_category_supermarket/views/report_pricetag_normal.xml +++ b/product_print_category_supermarket/views/report_pricetag_normal.xml @@ -26,13 +26,23 @@
- - - Socia + + PVS +
- - No socia € + + PVP + + €
diff --git a/product_print_category_supermarket/views/res_config.xml b/product_print_category_supermarket/views/res_config.xml index bd0e752..947743b 100644 --- a/product_print_category_supermarket/views/res_config.xml +++ b/product_print_category_supermarket/views/res_config.xml @@ -16,6 +16,10 @@