Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
2497 Переглядів

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
1176
0
лют. 25
1230
0
вер. 17
2928
1
бер. 15
6469
1
лип. 23
1860