Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
2433 Представления

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

Аватар
Отменить
Лучший ответ

posted a new thread

Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Автор

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.

Related Posts Ответы Просмотры Активность
1
июн. 25
1093
1
июн. 25
2113
0
нояб. 21
1711
1
нояб. 19
6285
13
сент. 25
27119