Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2659 Lượt xem

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'. 


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

This works, thank you very much

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
1800
4
thg 7 25
3040
0
thg 3 25
1128
2
thg 1 25
2278
0
thg 1 25
1222