Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
2126 Vistas

How to show new fields that are in account.move in the POS receipt.

Avatar
Descartar
Mejor respuesta

posted a new thread

Avatar
Descartar
Mejor respuesta

Hi,

class AccountMove(models.Model):

    _inherit = 'account.move'


    @api.model    def _load_pos_data_fields(self, config_id):

       result = super()._load_pos_data_fields(config_id)

       result.append('field name')

    return result


Hope it helps

Avatar
Descartar
Autor

I currently have the following:

.py:
from odoo import models, fields, api

class AccountMove(models.Model):
_inherit = 'account.move'

@api.model
def _load_pos_data_fields(self, config_id):
fields = super(AccountMove, self)._load_pos_data_fields(config_id)
fields.extend(['registry'])
return fields

.js

/** @odoo-module */

import { patch } from "@web/core/utils/patch";
import { PosStore } from "@point_of_sale/app/store/pos_store";

patch(PosStore.prototype, {
getReceiptHeaderData(order) {
const data = {
...super.getReceiptHeaderData(...arguments),
invoice: order.account_move,
};
console.log("Order Data:", order); // Verifica el contenido de order
console.log("Receipt Header Data:", data);
console.log("Mi Campo Personalizado:", data.invoice ? data.invoice.registry : "No definido");
return data;
},
});

xml:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="hn_akos_cp_pos_update.ReceiptHeader" t-inherit="point_of_sale.ReceiptHeader" t-inherit-mode="extension">
<xpath expr="//div[@t-if='props.data.cashier']" position="after">

<t t-if='props.data.invoice'>
<div style="text-align: justify;">Factura Relacionada:
<t t-esc='props.data.invoice.registry' style="text-decoration: underline;" />
</div>
</t>
</xpath>
</t>
</templates>

But it doesn't work for me, I don't know if it's the js I have wrong.

Publicaciones relacionadas Respuestas Vistas Actividad
1
jun 25
841
1
jun 25
1662
0
nov 21
1591
1
nov 19
6158
3
jun 25
657