跳至內容
選單
此問題已被標幟
4 回覆
2460 瀏覽次數

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
4月 25
1150
0
2月 25
1203
0
9月 17
2916
1
3月 15
6460
1
7月 23
1850