diff --git a/models/pos_order.py b/models/pos_order.py index cff0b76..226d94f 100644 --- a/models/pos_order.py +++ b/models/pos_order.py @@ -1,19 +1,10 @@ -from odoo import models, fields +from odoo import models, fields, api class PosOrder(models.Model): _inherit = 'pos.order' - creator_id = fields.Many2one('hr.employee', string='Order Taker', help='Employee who took the order') payer_id = fields.Many2one('hr.employee', string='Cashier', help='Employee who processed the payment') - employee_id = fields.Many2one('hr.employee', string='Cash Open by', help='Employee who opened the cash register') - - def _export_for_ui(self, order): - result = super()._export_for_ui(order) - result['creator_id'] = order.creator_id.id - result['payer_id'] = order.payer_id.id - return result - - def _get_fields_for_draft_order(self): - fields = super()._get_fields_for_draft_order() - fields.extend(['creator_id', 'payer_id']) - return fields + + # Existing Odoo/POS fields renamed for clarity + user_id = fields.Many2one('res.users', string='Order Taker', help='Odoo user who opened the session') + employee_id = fields.Many2one('hr.employee', string='Order Taker', help='Employee who uses the cash register') diff --git a/static/src/app/models/pos_order.js b/static/src/app/models/pos_order.js deleted file mode 100644 index cded56a..0000000 --- a/static/src/app/models/pos_order.js +++ /dev/null @@ -1,16 +0,0 @@ -import { patch } from "@web/core/utils/patch"; -import { PosOrder } from "@point_of_sale/app/models/pos_order"; - -patch(PosOrder.prototype, { - setup(vals) { - super.setup(...arguments); - this.creator_id = vals.creator_id || false; - this.payer_id = vals.payer_id || false; - }, - serializeForORM() { - const result = super.serializeForORM(...arguments); - result.creator_id = this.creator_id; - result.payer_id = this.payer_id; - return result; - }, -}); diff --git a/static/src/app/screens/product_screen/action_pad/action_pad.js b/static/src/app/screens/product_screen/action_pad/action_pad.js deleted file mode 100644 index 0456175..0000000 --- a/static/src/app/screens/product_screen/action_pad/action_pad.js +++ /dev/null @@ -1,15 +0,0 @@ -import { ActionpadWidget } from "@point_of_sale/app/screens/product_screen/action_pad/action_pad"; -import { patch } from "@web/core/utils/patch"; - -patch(ActionpadWidget.prototype, { - async onClickPay() { - if (this.currentOrder.lines.length === 0) { - return; - } - const cashier = this.pos.getCashier(); - if (cashier) { - this.currentOrder.payer_id = cashier.id; - } - await this.pos.pay(); - } -}); diff --git a/static/src/app/screens/product_screen/action_pad/action_pad.xml b/static/src/app/screens/product_screen/action_pad/action_pad.xml index 4288f51..5baaf78 100644 --- a/static/src/app/screens/product_screen/action_pad/action_pad.xml +++ b/static/src/app/screens/product_screen/action_pad/action_pad.xml @@ -2,14 +2,12 @@ - () => this.onClickPay() pos.canPay - () => this.onClickPay() !pos.scanning and pos.canPay diff --git a/static/src/app/screens/product_screen/product_screen.js b/static/src/app/screens/product_screen/product_screen.js deleted file mode 100644 index 4510c64..0000000 --- a/static/src/app/screens/product_screen/product_screen.js +++ /dev/null @@ -1,15 +0,0 @@ -import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; -import { patch } from "@web/core/utils/patch"; - -patch(ProductScreen.prototype, { - async onClickPay() { - if (this.currentOrder.lines.length === 0) { - return; - } - const cashier = this.pos.getCashier(); - if (cashier) { - this.currentOrder.payer_id = cashier.id; - } - await this.pos.pay(); - } -}); diff --git a/static/src/app/screens/ticket_screen/ticket_screen.xml b/static/src/app/screens/ticket_screen/ticket_screen.xml new file mode 100644 index 0000000..9c6fd74 --- /dev/null +++ b/static/src/app/screens/ticket_screen/ticket_screen.xml @@ -0,0 +1,26 @@ + + + + + +
+ +
+
+ +
+
+ Unpaid +
+ +
+ +
+ Taker: +
+
+ Cashier: +
+
+
+
diff --git a/static/src/app/services/pos_store.js b/static/src/app/services/pos_store.js index 3d76f11..5a2f2d1 100644 --- a/static/src/app/services/pos_store.js +++ b/static/src/app/services/pos_store.js @@ -20,11 +20,38 @@ patch(PosStore.prototype, { await super.setTableFromUi(...arguments); const order = this.getOrder(); - if (order && !order.creator_id) { - order.creator_id = cashier.id; + if (order) { + order.uiState.is_authorized = true; } }, + async pay() { + if (this.selectedOrder.lines.length === 0) { + return; + } + + if (!this.canPay) { + this.notification.add(_t("You do not have permission to process payments."), { + type: "danger", + }); + return; + } + + if (!this.selectedOrder.uiState.is_authorized) { + const cashier = await this._selectCashierByPin(); + if (!cashier) { + return; + } + + this.setCashier(cashier); + this.selectedOrder.uiState.is_authorized = true; + } + + this.selectedOrder.update({ payer_id: this.getCashier() }); + + return super.pay(); + }, + async _selectCashierByPin() { if (!this.config.module_pos_hr) { return this.getCashier(); diff --git a/views/pos_order_views.xml b/views/pos_order_views.xml index 3a4eccb..250aa3e 100644 --- a/views/pos_order_views.xml +++ b/views/pos_order_views.xml @@ -6,8 +6,7 @@ - - +