Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odpovědi
2481 Zobrazení

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!

Avatar
Zrušit
Nejlepší odpověď

Thanks

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Autor Nejlepší odpověď

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

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
dub 25
1165
0
úno 25
1223
0
zář 17
2926
1
bře 15
6468
1
čvc 23
1855