From 5d1faa7b5befafcef7106064775d2e8e3780fe5d Mon Sep 17 00:00:00 2001 From: "matthias.lotz" Date: Fri, 9 Jan 2026 22:11:01 +0100 Subject: [PATCH] =?UTF-8?q?POS:=20Preislistenabh=C3=A4ngige=20Preisanzeige?= =?UTF-8?q?=20auf=20Produktkarten?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- open_workshop_pos/__manifest__.py | 1 + .../static/src/js/ows_product_card_patch.js | 36 +++++++++++++++++++ .../static/src/xml/ows_product_card_patch.xml | 6 ++-- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 open_workshop_pos/static/src/js/ows_product_card_patch.js diff --git a/open_workshop_pos/__manifest__.py b/open_workshop_pos/__manifest__.py index e79f4e1..f39bcd5 100644 --- a/open_workshop_pos/__manifest__.py +++ b/open_workshop_pos/__manifest__.py @@ -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', diff --git a/open_workshop_pos/static/src/js/ows_product_card_patch.js b/open_workshop_pos/static/src/js/ows_product_card_patch.js new file mode 100644 index 0000000..e702a6a --- /dev/null +++ b/open_workshop_pos/static/src/js/ows_product_card_patch.js @@ -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; + } +}); diff --git a/open_workshop_pos/static/src/xml/ows_product_card_patch.xml b/open_workshop_pos/static/src/xml/ows_product_card_patch.xml index f4361eb..705f268 100644 --- a/open_workshop_pos/static/src/xml/ows_product_card_patch.xml +++ b/open_workshop_pos/static/src/xml/ows_product_card_patch.xml @@ -12,10 +12,10 @@ overflow-hidden lh-sm product-name mb-1 - + -
- +
+