Hello community, I have been trying for several days to update the ticket generated from the POS at the end of the purchase so that it is printed on the thermal ticket machine, I need to add the invoice number, the code that I am implementing so far is the following:
# models/custom_pos.py # from odoo import models, fields
class PosOrder(models.Model): _inherit = 'pos.order'
invoice_id = fields.Many2one('account.move', string='Factura')
/* static/src/js/receipt_order.js */ odoo.define('custom_receipts_for_pos.receipt_order', function (require)
"use strict";
var models = require('point_of_sale.models');
var OrderSuper = models.Order.prototype;
models.Order = models.Order.extend({
initialize: function (attributes, options) {
OrderSuper.initialize.apply(this, arguments);
this.invoice_id = this.invoice_id || false;
},
export_for_printing: function () {
var result = OrderSuper.export_for_printing.apply(this, arguments);
result.invoice_id = this.invoice_id;
return result;
},
});
});
Since I have not been able to load the invoice_id in the JavaScript, I am not doing the xml view, but it should be something similar to this:
< !-- views/post_custom.xml-- >
< odoo>
< template id="pos_ticket_custom" inherit_id="point_of_sale.receipt">
< xpath expr="//div[@class='pos-receipt']" position="inside">
< t t-if="order.invoice_id">
< div>
< strong>Número de Factura:< /strong> < span t-esc="order.invoice_id.name"/>
< /div>
< /t>
< /xpath>
< /template>
< /odoo>
In case you didn't read the subject, the version is Odoo 17 and I'm testing in the Community and Enterprise version and it doesn't work