feat: implement robust employee name lookup in receipt orderline and add pos_hr dependency

This commit is contained in:
Suherdy Yacob 2026-06-01 12:33:44 +07:00
parent eae922f1d2
commit b0c09d15f8
2 changed files with 16 additions and 2 deletions

View File

@ -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': [

View File

@ -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 "";