[FIX] website_sale_aplicoop: evitar sobrecálculo en precio de envío
- Ajusta _get_delivery_product_display_price para calcular envío con list_price + impuestos - Evita aplicar reglas de pricelist al envío (recargos/descuentos no deseados) - Mantiene fallback seguro a list_price ante errores Resultado esperado: para PVP 5.74 con IVA 21% => 6.95
This commit is contained in:
parent
cfde009b64
commit
5dbea009c0
1 changed files with 36 additions and 12 deletions
|
|
@ -542,25 +542,49 @@ class AplicoopWebsiteSale(WebsiteSale):
|
|||
return product_supplier_info
|
||||
|
||||
def _get_delivery_product_display_price(self, delivery_product, pricelist=None):
|
||||
"""Return delivery product price for display (tax included)."""
|
||||
"""Return delivery product price for display (list_price + taxes).
|
||||
|
||||
Important: delivery cost must be based on product list_price and taxes,
|
||||
not on commercial pricelist rules (discounts/markups), to avoid inflating
|
||||
shipping price unexpectedly.
|
||||
"""
|
||||
if not delivery_product:
|
||||
return 5.74
|
||||
|
||||
pricelist = pricelist or self._resolve_pricelist()
|
||||
if not pricelist:
|
||||
return float(delivery_product.list_price or 0.0)
|
||||
|
||||
try:
|
||||
pricing = self._get_pricing_info(
|
||||
delivery_product,
|
||||
pricelist,
|
||||
quantity=1.0,
|
||||
partner=request.env.user.partner_id,
|
||||
base_price = float(delivery_product.list_price or 0.0)
|
||||
website = request.website
|
||||
partner = request.env.user.partner_id
|
||||
company = (
|
||||
website.company_id or delivery_product.company_id or request.env.company
|
||||
)
|
||||
return float(pricing.get("price", delivery_product.list_price) or 0.0)
|
||||
|
||||
product_taxes = delivery_product.sudo().taxes_id._filter_taxes_by_company(
|
||||
company
|
||||
)
|
||||
fiscal_position = website.fiscal_position_id.sudo()
|
||||
taxes = (
|
||||
fiscal_position.map_tax(product_taxes)
|
||||
if product_taxes
|
||||
else product_taxes
|
||||
)
|
||||
|
||||
if not taxes:
|
||||
return base_price
|
||||
|
||||
# Use website currency for display computation.
|
||||
currency = website.currency_id
|
||||
totals = taxes.compute_all(
|
||||
base_price,
|
||||
currency=currency,
|
||||
quantity=1.0,
|
||||
product=delivery_product,
|
||||
partner=partner,
|
||||
)
|
||||
return float(totals.get("total_included", base_price) or 0.0)
|
||||
except Exception as e:
|
||||
_logger.warning(
|
||||
"_get_delivery_product_display_price: Error getting delivery price for product %s (id=%s): %s. Using list_price fallback.",
|
||||
"_get_delivery_product_display_price: Error computing delivery display price for product %s (id=%s): %s. Using list_price fallback.",
|
||||
delivery_product.name,
|
||||
delivery_product.id,
|
||||
str(e),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue