[FIX] website_sale_aplicoop: precio por kg/litro con IVA y granel por litro
El precio por unidad de las tarjetas usaba el campo nativo base_unit_price
(list_price sin impuestos), mostrando un importe distinto al precio
principal de la tarjeta, que sí incluye IVA. Ahora se calcula a partir del
precio ya impositado. Además se extiende el sufijo de precio por unidad
("/L") a productos vendidos por litro, que ya tenían el step de 0.1 pero
no el indicador visual.
This commit is contained in:
parent
31d53c428c
commit
5a6d9c9894
2 changed files with 13 additions and 4 deletions
|
|
@ -54,6 +54,10 @@ def _prepare_product_display_info(self, product, product_price_info, request_obj
|
|||
uom_category_name = ""
|
||||
quantity_step = 1
|
||||
price_unit_suffix = ""
|
||||
bulk_unit_suffixes = {
|
||||
"uom.product_uom_categ_kgm": "/Kg",
|
||||
"uom.product_uom_categ_vol": "/L",
|
||||
}
|
||||
|
||||
if product.uom_id:
|
||||
uom = product.uom_id.sudo()
|
||||
|
|
@ -82,8 +86,7 @@ def _prepare_product_display_info(self, product, product_price_info, request_obj
|
|||
full_xmlid = f"{external_id.module}.{external_id.name}"
|
||||
if full_xmlid in fractional_categories:
|
||||
quantity_step = 0.1
|
||||
if full_xmlid == "uom.product_uom_categ_kgm":
|
||||
price_unit_suffix = "/Kg"
|
||||
price_unit_suffix = bulk_unit_suffixes.get(full_xmlid, "")
|
||||
except Exception as e:
|
||||
_logger.warning(
|
||||
"_prepare_product_display_info: Error detecting UoM category XML ID for product %s: %s",
|
||||
|
|
@ -91,6 +94,10 @@ def _prepare_product_display_info(self, product, product_price_info, request_obj
|
|||
str(e),
|
||||
)
|
||||
|
||||
base_unit_price = 0.0
|
||||
if product.base_unit_count and price_safe:
|
||||
base_unit_price = price_safe / product.base_unit_count
|
||||
|
||||
try:
|
||||
req = request_obj or request
|
||||
tr_env = req.env
|
||||
|
|
@ -106,6 +113,7 @@ def _prepare_product_display_info(self, product, product_price_info, request_obj
|
|||
"safe_uom_category": uom_category_name,
|
||||
"quantity_step": quantity_step,
|
||||
"price_unit_suffix": price_unit_suffix,
|
||||
"base_unit_price": base_unit_price,
|
||||
"out_of_stock_label": out_of_stock_label,
|
||||
"add_to_cart_label": add_to_cart_label,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -693,9 +693,10 @@
|
|||
</small>
|
||||
</t>
|
||||
</h6>
|
||||
<t t-if="product.base_unit_price and product.base_unit_name">
|
||||
<t t-set="tax_incl_base_unit_price" t-value="product_display_info.get(product.id, {}).get('base_unit_price', 0.0)" />
|
||||
<t t-if="tax_incl_base_unit_price and product.base_unit_name">
|
||||
<p class="product-unit-price text-muted" style="font-size: 0.85rem; margin-top: 0.25rem; margin-bottom: 0;">
|
||||
<t t-esc="'%.2f' % product.base_unit_price" /> € / <t t-esc="product.base_unit_name" />
|
||||
<t t-esc="'%.2f' % tax_incl_base_unit_price" /> € / <t t-esc="product.base_unit_name" />
|
||||
</p>
|
||||
</t>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue