We are trying to add a way for customers to tip their wait staff with a LN-address. We added the LN-address as a new field to the employees model. The new fields are loaded to the POS session through pos_session.py and the POSGlobalState through a js file. But I cannot figure out how to pul the new js variable into the OrderReceipt.xml. What additional step is needed to get the new field to be displayed on the OrderReceipt.xml?
hr_employee,py
from odoo import models, fields
class custom_info(models.Model):
_inherit = 'hr.employee'
employee_ln_address = fields.Char(string="Employee lightning address : ", required=False)
employee_ln_qr_image = fields.Image(string="Employee lightning QR code")
pos_session.py
class PosSession(models.Model):
_inherit = 'pos.session'
def _loader_params_hr_employee(self):
result = super()._loader_params_hr_employee()
result['search_params']['fields'].append('employee_ln_address')
return result
def _pos_ui_models_to_load(self):
result = super()._pos_ui_models_to_load()
new_models_to_load = ['hr.employee']
result.extend(new_models_to_load)
return result
OrderReceipt.js
import { PosGlobalState } from 'point_of_sale.models';
import Registries from 'point_of_sale.Registries';
const HRPosGlobalState = (PosGlobalState) => class HRPosGlobalState extends PosGlobalState{
async _processData(loadedData) {
await super._processData(...arguments);
this.employees = loadedData['hr.employee'];
this.employee_by_id = loadedData['employee_by_id'];
this.employee_ln_address = loadedData['employee_ln_address'];
console.log(this.employees);
var employee_ln_address = this.employees[0].employee_ln_address;
console.log(employee_ln_address);
}}
Registries.Model.extend(PosGlobalState, HRPosGlobalState);
OrderReceipt.xml (removed < from each line so it will show here)
?xml version="1.0" encoding="UTF-8"?>
templates id="template" xml:space="preserve">
t t-name="OrderReceipt" t-inherit="point_of_sale.OrderReceipt" t-inherit-mode="extension" owl="1">
xpath expr="//div[hasclass('before-footer')]" position="after">
t t-if="props.isBill == False">
t t-if='receipt.cashier'>
div>Tip your waitstaff:
t t-esc='employee_ln_address'/>
/div>
/t>
/t>
/xpath>
/t>
/templates>