[FIX] pos_self_order: show take away price
Steps to reproduce: - Activate "Eat in / Take away" (`pos_self_ordering_takeaway`) setting. - Set the alternative fiscal position. - ISSUE: When selecting take away in the app, the take away price is not shown. FIX: The issue is because during the loading of the products, only the default price is computed. In this PR, we are now computing the take away price as well. And in the ui, depending on the choice, we are showing the correct price. closes odoo/odoo#137653 Signed-off-by: Robin Heinz (rhe) <rhe@odoo.com>
This commit is contained in:
@@ -97,16 +97,34 @@ class ProductProduct(models.Model):
|
||||
self, qty, currency=pos_config.currency_id
|
||||
)
|
||||
|
||||
price_info = pos_config.default_fiscal_position_id.map_tax(self.taxes_id).compute_all(
|
||||
# Declare variables, will be the return values.
|
||||
display_price_default = price
|
||||
display_price_alternative = price
|
||||
|
||||
taxes_default = pos_config.default_fiscal_position_id.map_tax(self.taxes_id)
|
||||
taxes_alternative = pos_config.self_ordering_alternative_fp_id.map_tax(self.taxes_id)
|
||||
|
||||
all_prices_default = taxes_default.compute_all(
|
||||
price, pos_config.currency_id, qty, product=self
|
||||
)
|
||||
all_prices_alternative = taxes_alternative.compute_all(
|
||||
price, pos_config.currency_id, qty, product=self
|
||||
)
|
||||
|
||||
display_price = price_info["total_included"] if pos_config.iface_tax_included == "total" else price_info["total_excluded"]
|
||||
display_price = self.lst_price if self.combo_ids else display_price
|
||||
if self.combo_ids:
|
||||
display_price_default = self.lst_price
|
||||
display_price_alternative = self.lst_price
|
||||
else:
|
||||
if pos_config.iface_tax_included == 'total':
|
||||
display_price_default = all_prices_default["total_included"]
|
||||
display_price_alternative = all_prices_alternative["total_included"]
|
||||
else:
|
||||
display_price_default = all_prices_default["total_excluded"]
|
||||
display_price_alternative = all_prices_alternative["total_excluded"]
|
||||
|
||||
return {
|
||||
"display_price": display_price,
|
||||
"lst_price": self.lst_price
|
||||
'display_price_default': display_price_default,
|
||||
'display_price_alternative': display_price_alternative,
|
||||
}
|
||||
|
||||
def _get_product_for_ui(self, pos_config):
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<div class="product-infos d-flex flex-column justify-content-between text-start flex-grow-1 px-2 mt-3 mb-1">
|
||||
<span t-esc="props.product.name" class="fs-3 fw-bolder flex-grow-1 lh-sm" />
|
||||
<div class="d-flex justify-content-between align-items-end gap-3">
|
||||
<span t-esc="selfOrder.formatMonetary(props.product.prices)" class="fs-4 text-muted flex-grow-1" />
|
||||
<span t-esc="selfOrder.formatMonetary(selfOrder.getProductDisplayPrice(props.product))" class="fs-4 text-muted flex-grow-1" />
|
||||
<div class="text-center ms-2 fs-lighter">
|
||||
<div t-if="!props.product.self_order_available" class="fs-lighter bg-secondary rounded">Out of stock</div>
|
||||
</div>
|
||||
|
||||
@@ -40,10 +40,6 @@ export class Product extends Reactive {
|
||||
this.showPriceTaxIncluded = showPriceTaxIncluded;
|
||||
}
|
||||
|
||||
get prices() {
|
||||
return this.price_info.display_price;
|
||||
}
|
||||
|
||||
get isCombo() {
|
||||
return this.pos_combo_ids;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
class="o_self_order_main_desc flex-grow-1 pb-3 mb-3 bg-view text-muted "
|
||||
t-esc="product.description_sale"
|
||||
/>
|
||||
<span class="fs-3 fw-bolder" t-esc="selfOrder.formatMonetary(product.prices)"/>
|
||||
<span class="fs-3 fw-bolder" t-esc="selfOrder.formatMonetary(selfOrder.getProductDisplayPrice(product))"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -434,6 +434,14 @@ export class SelfOrder extends Reactive {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
getProductDisplayPrice(product) {
|
||||
if (this.currentOrder.take_away) {
|
||||
return product.price_info.display_price_alternative;
|
||||
} else {
|
||||
return product.price_info.display_price_default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const selfOrderService = {
|
||||
|
||||
Reference in New Issue
Block a user