almost done for POS

This commit is contained in:
Matthias Lotz 2025-06-28 18:49:49 +02:00
parent 021d01efe6
commit 59e4b19dee
5 changed files with 25 additions and 50 deletions

View File

@ -18,7 +18,7 @@
'installable': True,
'assets': {
'web.assets_backend': [
'open_workshop/static/src/css/category_color.css',
'static/src/css/category_color.css',
],
'point_of_sale._assets_pos': [

View File

@ -3,7 +3,7 @@
import { Component, useState } from "@odoo/owl";
import { useBus } from "@web/core/utils/hooks";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { jsonrpc } from "@web/core/network/rpc_service";
import { rpc } from "@web/core/network/rpc";
export class OwsMachineAccessList extends Component {
static template = 'open_workshop.OwsMachineAccessList';
@ -43,8 +43,10 @@ export class OwsMachineAccessList extends Component {
}
try {
const data = await jsonrpc("/open_workshop/partner_access", {
partner_id: partner.id,
const data = await rpc("/open_workshop/partner_access", {
params: {
partner_id: partner.id,
},
});
this.state.grouped_accesses = data.access_by_area || [];
@ -60,5 +62,6 @@ export class OwsMachineAccessList extends Component {
this.state.rfid_card = '';
this.state.birthday = '';
}
}
}

View File

@ -4,7 +4,7 @@ import { Component } from "@odoo/owl";
import { useService } from "@web/core/utils/hooks";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { _t } from "@web/core/l10n/translation";
import { ConfirmPopup } from "@point_of_sale/app/utils/confirm_popup/confirm_popup";
import { ask } from "@web/core/confirmation_dialog/confirmation_dialog";
import { deserializeDateTime, formatDateTime, parseDateTime } from "@web/core/l10n/dates";
export class OwsPosCustomerSidebar extends Component {
@ -12,8 +12,7 @@ export class OwsPosCustomerSidebar extends Component {
setup() {
this.pos = usePos();
this.popup = useService("popup");
this.dialog = useService("dialog");
}
addOrder() {
@ -28,11 +27,12 @@ export class OwsPosCustomerSidebar extends Component {
if (!order) return;
// 🛑 Sicherheitsabfrage: Order enthält bereits Positionen
// Hinweis: Verhalten angelehnt an ticket_screen.js in Odoo 17.0
if (order.get_orderlines().length > 0) {
const { confirmed } = await this.popup.add(ConfirmPopup, {
const confirmed = await ask(this.dialog, {
title: _t("Order enthält Positionen"),
body: _t("Möchtest du diese Order wirklich löschen?"),
confirmText: _t("Löschen"),
cancelText: _t("Abbrechen"),
});
if (!confirmed) return;
}
@ -45,10 +45,9 @@ export class OwsPosCustomerSidebar extends Component {
// ✅ Wenn noch andere Orders existieren, eine davon aktivieren
if (remainingOrders.length > 0) {
this.pos.set_order(remainingOrders[remainingOrders.length - 1]); // z.B. letzte Order aktivieren
this.pos.set_order(remainingOrders[remainingOrders.length - 1]);
}
// Hinweis: Weitere Funktionen wie Sync mit Server (siehe ticket_screen.js) können hier ergänzt werden.
this.env.bus.trigger('partner-changed'); // ✅ korrektes Event feuern
}
@ -69,13 +68,12 @@ export class OwsPosCustomerSidebar extends Component {
return `${dd}.${mm}. ${hh}:${mi}`;
}
getPartner(order) {
return order.get_partner()?.name || "Kein Kunde";
}
selectOrder(order) {
this.pos.set_order(order);
this.env.bus.trigger('partner-changed'); // ✅ korrektes Event feuern
this.env.bus.trigger('partner-changed');
}
}

View File

@ -5,6 +5,8 @@ import { registry } from "@web/core/registry";
import { OwsPosCustomerSidebar } from "@open_workshop/js/ows_pos_customer_sidebar";
import { OwsMachineAccessList } from "@open_workshop/js/ows_machine_access_list";
console.log("🔍 product_screen_template_patch.js wurde geladen");
export class OwsProductScreen extends ProductScreen {
static template = "open_workshop.ProductScreen";
static components = {
@ -12,6 +14,11 @@ export class OwsProductScreen extends ProductScreen {
OwsPosCustomerSidebar,
OwsMachineAccessList,
};
setup() {
super.setup(); // wichtig!
console.log("📦 OwsProductScreen aktiv, Template:", this.constructor.template);
}
}
registry.category("pos_screens").remove("ProductScreen");

View File

@ -1,46 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="open_workshop.ProductScreen" owl="1">
<div class="product-screen d-flex h-100 bg-100" t-att-class="{ 'd-none': !props.isShown }">
<t t-name="open_workshop.ProductScreen" t-inherit="point_of_sale.ProductScreen" t-inherit-mode="extension">
<!-- Deine Sidebar vor dem linken Pane -->
<xpath expr="//div[contains(@class, 'leftpane')]" position="before">
<div class="custompane d-flex flex-column border-end bg-200">
<OwsPosCustomerSidebar />
<OwsMachineAccessList />
</div>
</xpath>
<div t-if="!ui.isSmall || pos.mobile_pane === 'left'"
t-att-class="{'flex-grow-1': ui.isSmall}"
class="leftpane d-flex flex-column border-end bg-200" >
<OrderWidget lines="currentOrder.orderlines" t-slot-scope="scope"
total="env.utils.formatCurrency(currentOrder.get_total_with_tax())"
tax="!env.utils.floatIsZero(currentOrder.get_total_tax()) and env.utils.formatCurrency(currentOrder.get_total_tax()) or ''">
<t t-set="line" t-value="scope.line" />
<Orderline line="line.getDisplayData()"
t-on-click="() => this.selectLine(line)"
class="{ ...line.getDisplayClasses(), 'selected' : line.selected }"/>
<t t-set-slot="details" />
</OrderWidget>
<div class="pads border-top">
<div class="control-buttons d-flex flex-wrap border-bottom overflow-hidden bg-300" t-if="!ui.isSmall">
<t t-foreach="controlButtons" t-as="cb" t-key="cb.name">
<t t-component="cb.component" t-key="cb.name"/>
</t>
</div>
<div class="subpads d-flex">
<ActionpadWidget partner="partner" actionName="constructor.numpadActionName" actionType="'payment'" onClickMore.bind="displayAllControlPopup" />
<Numpad buttons="getNumpadButtons()" onClick.bind="onNumpadClick" class="'w-100'"/>
</div>
</div>
</div>
<div class="rightpane overflow-auto d-flex flex-grow-1 flex-column bg-300 w-60" t-if="!ui.isSmall || pos.mobile_pane === 'right'">
<ProductsWidget />
<t t-if="ui.isSmall">
<div class="product-reminder d-flex justify-content-center align-items-center py-1 text-bg-warning bg-opacity-50 fw-bolder"
t-if="currentOrder.get_selected_orderline() and currentOrder.hasJustAddedProduct" t-key="animationKey" >
<span><t t-esc="selectedOrderlineQuantity"/> <t t-esc="selectedOrderlineDisplayName"/> <t t-esc="selectedOrderlineTotal"/></span>
</div>
</t>
</div>
</div>
</t>
</templates>