[REF] website_sale_aplicoop: price through website_sale instead of privately

Eskaera carried its own pricing path: a `website_sale_aplicoop.pricelist_id`
setting resolved inside the Eskaera controllers, plus a local reimplementation
of the tax and discount maths. The pricelist part meant /shop and Eskaera could
quote different prices on the same website, and the maths part had drifted from
the original it was copied from.

Pricing is now the standard one. The setting is gone (a migration drops the
parameter, which would otherwise linger looking like live configuration) and
`_resolve_pricelist` is `request.website.pricelist_id`. Scoping a pricelist to
a website is already core's job through `product.pricelist.website_id`, so
running the plain shop on one website and the co-op on another needs no code
here.

Taxes are applied by `product.template._apply_taxes_to_price`, which fixes a
real defect: it calls `_get_tax_included_unit_price_from_price` first, and this
module did not. With a fiscal position remapping a tax-included tax, a product
at 121 (100 + 21%) was displayed at 121 instead of 110, because the price was
handed to the mapped tax as if it were already that tax's gross amount. The
helper is a no-op without a remapping, so ordinary pricing is untouched. It
also means the website's `show_line_subtotals_tax_selection` is respected
rather than overridden with a hardcoded tax-included display.

Listing a page now costs one `_compute_price_rule` call instead of one per
product, which matters on the lazy-loading path.

Two smaller things found on the way. `_get_product_price_rule` was being passed
`target_currency=`, which is not one of its arguments: it fell into **kwargs
and was ignored, so the conversion never happened. And `_compute_price_info`
resolved `product.product_variant_ids[0]`, but it receives variants, so a
multi-variant template was priced from its first variant rather than the one
asked for.

The delivery display price loses its hardcoded 5.74 fallback and reuses the
same helpers as everything else.

Kept local, because none of it is pricing: the /Kg and /L suffixes, the 0.1
quantity step for bulk goods, the base unit price and the supplier name.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
GitHub Copilot 2026-08-17 17:28:51 +02:00
parent 3e4bd5e5db
commit 817ff31d39
10 changed files with 496 additions and 202 deletions

View file

@ -25,6 +25,7 @@ from .exceptions import GroupOrderUnavailable
_logger = logging.getLogger(__name__)
class AplicoopWebsiteSale(WebsiteSale):
"""Controlador personalizado para website_sale de Aplicoop.
@ -54,7 +55,12 @@ class AplicoopWebsiteSale(WebsiteSale):
# ========== PHASE 1: HELPER METHODS FOR VALIDATION AND CONFIGURATION ==========
def _resolve_pricelist(self):
return _pricing._resolve_pricelist(self, request)
"""The pricelist to quote in: whatever website_sale resolved.
Eskaera used to carry its own pricelist setting; it now prices with the
standard one, so the shop, the cart and these pages cannot drift apart.
"""
return request.website.pricelist_id
def _prepare_product_display_info(self, product, product_price_info):
return _pricing._prepare_product_display_info(
@ -64,13 +70,12 @@ class AplicoopWebsiteSale(WebsiteSale):
request,
)
def _get_pricing_info(self, product, pricelist, quantity=1.0, partner=None):
def _get_pricing_info(self, product, pricelist, quantity=1.0):
return _pricing._get_pricing_info(
self,
product,
pricelist,
quantity=quantity,
partner=partner,
request_obj=request,
)
@ -176,7 +181,6 @@ class AplicoopWebsiteSale(WebsiteSale):
"""
sale_order_lines = []
pricelist = pricelist or self._resolve_pricelist()
partner = request.env.user.partner_id
for item in items:
try:
@ -198,7 +202,6 @@ class AplicoopWebsiteSale(WebsiteSale):
product,
pricelist,
quantity=quantity,
partner=partner,
)
line_data = {
@ -1657,13 +1660,11 @@ class AplicoopWebsiteSale(WebsiteSale):
# Extract items from the draft order
items = []
pricelist = self._resolve_pricelist()
partner = current_user.partner_id
for line in draft_order.order_line:
pricing = self._get_pricing_info(
line.product_id,
pricelist,
quantity=line.product_uom_qty,
partner=partner,
)
items.append(
{