Hii,
Python – Extend pos.order and Session Loader
models/pos_order.py
from odoo import models, fields
class PosOrder(models.Model):
_inherit = 'pos.order'
qr_code = fields.Char(string="QR Code") # your custom field
models/pos_session.py
from odoo import models
class PosSession(models.Model):
_inherit = ['pos.session', 'evo.payments.session']
def _loader_params_pos_order(self):
result = super()._loader_params_pos_order()
result["search_params"]["fields"].append("qr_code") # <-- This is your CUSTOM_FIELD
return result
qr_code is the custom field you want in the receipt. Replace it with any field you need.
JavaScript – Pass Custom Field to Receipt
static/src/js/extend_order.js
/** @odoo -module **/
import { Order } from "@point_of_sale/app/store/models";
import { patch } from "@web/core/utils/patch";
patch(Order.prototype, {
export_for_printing() {
const result = super.export_for_printing();
result.qr_code = this.qr_code; // must match field in Python
return result;
},
});
XML – Add Field to POS Receipt
views/pos_receipt_template.xml
<odoo>
<template id="custom_pos_receipt_qr" inherit_id="point_of_sale.pos_ticket">
<xpath expr="//div[@class='pos-receipt-order-data']" position="inside">
<div>
<strong>QR Code:</strong> <t t-esc="receipt.qr_code"/>
</div>
</xpath>
</template>
</odoo>
4. Manifest File
__manifest__.py
{
"name": "POS Custom QR Receipt",
"depends": ["point_of_sale"],
"assets": {
"point_of_sale._assets_pos": [
"your_module_name/static/src/js/extend_order.js",
],
},
"data": [
"views/pos_receipt_template.xml",
],
}
i hope it is usefull
Hi mauricio,
Do you mean you want to add it to the POS receipt?
can you please send an image of the place you want to add the field?
Regards,