Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
2484 มุมมอง

Hi all!

I'm trying to add a custom button next to the "Print Full Receipt" button, but it's not showing up. Here's my implementation:


Structure:


test_app/

├── __init__.py  # Empty file

├── __manifest__.py

└── static/

    └── src/

        ├── js/

        │   └── receipt_screen.js

        └── xml/

            └── receipt_screen.xml



__manifest__.py


{

    'name': 'Test App',

    'version': '1.0',

    'category': 'Point of Sale',

    'depends': ['point_of_sale'],

    'assets': {

        'point_of_sale.assets': [

            '/test_app/static/src/js/receipt_screen.js',

            '/test_app/static/src/xml/receipt_screen.xml',

        ],

    },

    'installable': True,

    'license': 'LGPL-3',

}



receipt_screen.xml


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

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

    <t t-inherit="point_of_sale.ReceiptScreen" t-inherit-mode="extension">

        <xpath expr="//div[contains(@class, 'receipt-options')]//div[contains(@class, 'd-flex gap-1')][1]" position="inside">

            <button class="button print btn btn-lg btn-secondary w-100 py-3" t-on-click="onCustomButton">

                <i class="fa fa-upload me-1"/>

                Send

            </button>

        </xpath>

    </t>

</templates>


receipt_screen.js


/** @odoo-module **/


import { ReceiptScreen } from "@point_of_sale/app/screens/receipt_screen/receipt_screen";

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


patch(ReceiptScreen.prototype, {

    async onCustomButton() {

        console.log("Button clicked");

    }

});



The module installs without errors, but the button doesn't show up in the POS Receipt Screen. I've checked the browser's console and network tabs, and I don't see any errors.

What am I missing? Why isn't the button showing up? I've tried different xpath expressions but none seem to work. The module is properly installed and I can see it in the installed modules list.

Any help would be greatly appreciated!

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,


You should include the paths in the correct asset bundle as shown below:


'assets': {

        'point_of_sale._assets_pos': [

            'path/to/js/file',

             'path/to/xml/file',

        ],

    },


Hope it helps

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Hi Jainesh,

Thank you so much. Everything is working perfectly now! After initially testing that the button was functioning correctly with a simple implementation, I've now successfully integrated the complete code to handle the data transmission. The button is displaying correctly on the ticket screen, properly positioned below the print ticket button, and most importantly, it's now successfully sending all the ticket information to my server.

Thank you again for your help!

Best regards

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello David,


In Odoo version 17, when defining POS assets, you should use the format:

"point_of_sale._assets_pos": ['your_path']


Defining it the way you did, will not work as expected.


Hope this Helps,

If you need any help in customization feel free to contact us.


Thanks & Regards,

Email:  odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
เม.ย. 25
1168
0
ก.พ. 25
1224
0
ก.ย. 17
2926
1
มี.ค. 15
6468
1
ก.ค. 23
1855