product_print_category_supermarket take prices from 2 configurable pricelist: public and members. include taxes in calculations

This commit is contained in:
Luis 2025-01-02 16:21:34 +01:00
parent 0db766645c
commit 7bc0f90a65
5 changed files with 36 additions and 14 deletions

View file

@ -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"]

View file

@ -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",
)

View file

@ -26,13 +26,23 @@
</t>
</div>
<div class="product_member_price" >
<t t-set="members_price_wo_tax" t-value="round(product.list_price - (product.list_price * 0.15), 2)" />
<t t-set="members_price" t-value="round(members_price_wo_tax * (1 + product.taxes_id[0].amount / 100), 2)" />
<strong>Socia <span t-esc="members_price"/></strong>
<t t-set="members_price" t-value="product.get_price_member()" />
<span>PVS</span>
<strong><span
t-out="members_price"
t-options='{"widget": "float", "precision": 2}'
/> €</strong>
</div>
<div class="product_public_price" >
<t t-set="public_price" t-value="round(product.list_price * (1 + product.taxes_id[0].amount / 100), 2)" />
<span>No socia</span> <span t-esc="public_price"/>
<t
t-set="public_price"
t-value="round(product.get_price_public(), 2)"
/>
<span>PVP</span>
<strong><span
t-out="public_price" t-options='{"widget": "float", "precision": 2}'
/>
</strong>
</div>
</div>
</t>

View file

@ -16,6 +16,10 @@
<label for="label_pricelist" string="Members Pricelist" />
<field name="label_pricelist" />
</div>
<div class="o_setting_right_pane">
<label for="label_public_pricelist" string="Public Pricelist" />
<field name="label_public_pricelist" />
</div>
</div>
</xpath>
</field>

View file

@ -9,12 +9,6 @@ class ProductTemplate(models.Model):
_inherit = "product.template"
margin_state = fields.Selection(store=True)
# to_print_label = fields.Boolean(
# string="To print label",
# help="""The sale price has been updated on this product
# and needs to be updated on the shelf.""",
# default=False,
# )
last_purchase_price_received = fields.Float(
string="Last purchase price",