From b0c09d15f81b53263c1a26b36d975fb4c0386f31 Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Mon, 1 Jun 2026 12:33:44 +0700 Subject: [PATCH] feat: implement robust employee name lookup in receipt orderline and add pos_hr dependency --- __manifest__.py | 2 +- static/src/js/orderline.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/__manifest__.py b/__manifest__.py index 52fdc72..5837c07 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -19,7 +19,7 @@ Key Features: - **Odoo Branding**: Removes the "Powered by Odoo" text in the receipt footer. - **Print Margin**: Removes the top, right, and bottom margins from the print page, ensuring the content aligns closely with the paper edges while keeping the default left margin. """, - 'depends': ['point_of_sale', 'pos_restaurant'], + 'depends': ['point_of_sale', 'pos_restaurant', 'pos_hr'], 'data': [], 'assets': { 'point_of_sale._assets_pos': [ diff --git a/static/src/js/orderline.js b/static/src/js/orderline.js index f76946c..31fba7a 100644 --- a/static/src/js/orderline.js +++ b/static/src/js/orderline.js @@ -22,7 +22,21 @@ patch(Orderline.prototype, { patch(PosOrder.prototype, { getCashierName() { - const employee = this.employee_id || this.original_employee_id || this.user_id; + const pos = this.pos || this.models?.env?.services?.pos; + let employee = this.employee_id || this.original_employee_id || this.user_id || null; + + // If employee is just an ID/number, look up the record from the POS store models + if (employee && (typeof employee === 'number' || typeof employee === 'string')) { + const empId = parseInt(employee); + if (pos && pos.models && pos.models['hr.employee']) { + employee = pos.models['hr.employee'].get(empId) || { name: `Employee ${empId}` }; + } else if (pos && pos.employees) { + employee = pos.employees.find(e => e.id === empId) || { name: `Employee ${empId}` }; + } else { + employee = { name: `Employee ${empId}` }; + } + } + const name = employee ? (employee.name || "") : ""; if (!name) { return "";