POS: Preislistenabhängige Preisanzeige auf Produktkarten
- Fügt reaktive Preisanzeige auf POS-Produktkarten hinzu - Preis wird basierend auf der Preisliste des aktuellen Kunden berechnet - Automatische Aktualisierung bei Kundenwechsel/Preislistenänderung - Unterstützt Maßeinheiten für gewichtsbasierte Produkte
This commit is contained in:
parent
21b0d6305f
commit
5d1faa7b5b
|
|
@ -42,6 +42,7 @@ Autor: HobbyHimmel
|
|||
'open_workshop_pos/static/src/js/ows_order_patch.js',
|
||||
'open_workshop_pos/static/src/js/ows_receipt_header_patch.js',
|
||||
'open_workshop_pos/static/src/js/ows_control_buttons_patch.js',
|
||||
'open_workshop_pos/static/src/js/ows_product_card_patch.js',
|
||||
|
||||
# XML Templates
|
||||
'open_workshop_pos/static/src/xml/ows_pos_sidebar.xml',
|
||||
|
|
|
|||
36
open_workshop_pos/static/src/js/ows_product_card_patch.js
Normal file
36
open_workshop_pos/static/src/js/ows_product_card_patch.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { ProductCard } from "@point_of_sale/app/generic_components/product_card/product_card";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(ProductCard.prototype, {
|
||||
/**
|
||||
* Gibt den formatierten Preis des Produkts zurück, basierend auf der aktuellen Preisliste.
|
||||
* Dieser Getter wird automatisch neu berechnet, wenn sich die Preisliste ändert.
|
||||
*/
|
||||
get productPrice() {
|
||||
if (!this.props.product) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Hole die aktuelle Bestellung, um auf deren Preisliste zuzugreifen
|
||||
const order = this.env.services.pos.get_order();
|
||||
if (!order) {
|
||||
return this.env.services.pos.getProductPriceFormatted(this.props.product);
|
||||
}
|
||||
|
||||
// Zugriff auf die Preisliste der Bestellung, damit Owl Änderungen tracken kann
|
||||
const pricelist = order.pricelist_id;
|
||||
|
||||
// Berechne den Preis mit der Preisliste
|
||||
const price = this.props.product.get_price(pricelist, 1);
|
||||
const formattedPrice = this.env.utils.formatCurrency(price);
|
||||
|
||||
// Füge Maßeinheit hinzu, wenn das Produkt nach Gewicht verkauft wird
|
||||
if (this.props.product.to_weight) {
|
||||
return `${formattedPrice}/${this.props.product.uom_id.name}`;
|
||||
}
|
||||
|
||||
return formattedPrice;
|
||||
}
|
||||
});
|
||||
|
|
@ -12,10 +12,10 @@
|
|||
<attribute name="class">overflow-hidden lh-sm product-name mb-1</attribute>
|
||||
</xpath>
|
||||
|
||||
<!-- Füge den Preis nach dem Produktnamen hinzu -->
|
||||
<!-- Füge den Preis nach dem Produktnamen hinzu (preislistenabhängig) -->
|
||||
<xpath expr="//div[hasclass('product-name')]" position="after">
|
||||
<div t-if="props.product?.lst_price" class="product-price text-primary fw-bold fs-6 mb-2">
|
||||
<t t-esc="env.utils.formatCurrency(props.product.lst_price)"/>
|
||||
<div t-if="props.product" class="product-price text-primary fw-bold fs-6 mb-2">
|
||||
<t t-esc="productPrice"/>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user