Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
2082 Visualizações

I want to inherit from 

t-name="point_of_sale.PaymentScreenButtons"

<button class="button partner-button btn btn-light py-3 text-start rounded-0 border-bottom"

                t-att-class="{ 'highlight text-bg-primary': currentOrder.get_partner() }"

                t-on-click="() => this.selectPartner(false, [])">

                <i class="fa fa-user me-2" role="img" title="Customer" />

                <span class="partner-name">

                    <t t-if="currentOrder.get_partner()" t-esc="currentOrder.get_partner().name"/>

                    <t t-else="">Customer</t>

                </span>

            </button>



and i want to add rfid_balance field from my custom res.partner module

here is my attempt to inherit the view and js






<?xml version="1.0" encoding="utf-8"?>

<odoo>

    <templates id="mq_canteen_template" xml:space="preserve">

        <t t-name="mq_canteen_pos_order.MQPaymentScreenExtension"

           t-inherit="point_of_sale.PaymentScreenButtons" t-inherit-mode="extension" owl="1">

            <xpath expr="//div[@class='payment-buttons d-flex flex-column flex-wrap']" position="inside">

                <div class="rfid-balance py-2 px-3 text-end text-muted">

                    <span>RFID Balance:</span>

                    <span t-esc="currentOrder.get_partner() ? currentOrder.get_partner().rfid_balance : 'N/A'" />

                </div>

            </xpath>

        </t>

    </templates>

</odoo>





/** @odoo-module **/


import { PaymentScreen } from "../../../../../../../../odoo/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen";

import { patch } from "@web/core/utils/patch";


// Patch the PaymentScreen component

patch(PaymentScreen.prototype, "mq_canteen_pos_order.PaymentScreen", {

    getPartnerRFIDBalance() {

        const partner = this.currentOrder.get_partner();

        return partner ? partner.rfid_balance : "N/A";

    },

});



and i got this error from debug console

2024-12-09 13:04:17,400 16192 WARNING mq_test17 odoo.addons.web.controllers.binary: Parsing asset bundle point_of_sale.assets_prod.min.js has failed: Template name is missing in file '/mq_canteen_pos_order/static/src/xml/payment_screen/payment_screen.xml'. 


Avatar
Cancelar
Autor Melhor resposta

This works, thank you very much

Avatar
Cancelar
Melhor resposta

Hi,

1. Load rfid_balance from res partner in Point of Sale


odoo import models



class PosSession(models.Model):

    _inherit = 'pos.session'


    def _loader_params_res_partner(self):

        result = super()._loader_params_res_partner()

        result['search_params']['fields'].append('rfid_balance')

        return result

2. Inherit PaymentScreenButtons.

<?xml version="1.0" encoding="UTF-8"?>

<templates id="template" xml:space="preserve">

<t t-name="module_name.PaymentScreenButtons"

       t-inherit="point_of_sale.PaymentScreenButtons" t-inherit-mode="extension"

       owl="1">

        <xpath expr="//div[hasclass('payment-buttons')]" position="inside">

        <div class="rfid-balance py-2 px-3 text-end text-muted">

                    <span>RFID Balance:</span>

                    <span t-esc="currentOrder.get_partner() ? currentOrder.get_partner().rfid_balance : 'N/A'" />

                </div>

                </xpath>

                </t>

    </templates>

</odoo>

3.Add Required Files to the Asset Bundle.

'assets': {

        'point_of_sale._assets_pos': [

           // Add your file

        ],

    },

Hope it helps

Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
4
jul. 25
2590
0
mar. 25
909
0
jan. 25
1157
2
jan. 25
1891
0
jan. 25
1002