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

I want to add a new button in the pos screen interface named waiter so I definded a class named waiter with it's views and when I try to add that button using this code in the pos.xml file it dosn't work so what to do any help would be greatful:

 

<button t-attf-class='button set-waiter #{ ( widget.pos.waiter.name and widget.pos.waiter.name.length > 10) ? "decentered" : "" }' >

<i class='fa fa-waiter' />

<t t-if="widget.pos.waiter">

<t t-esc="widget.pos.waiter.name" />

</t>

<t t-if="!widget.pos.waiter">

Waiter

</t>

</button>

and here is the class:

class waiter(osv.osv) :

_name = "pos.waiter"

_description = "Waiter"

_columns = {

'name': fields.char('Nom serveur', required=True, translate=True),

'adrs': fields.char('Address'),

'tel': fields.integer('Téléphone'),

}

waiter()

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

Hi,

To add a new button to the POS screen interface in Odoo, you need to define a new widget and then add it to the POS view. The code you provided is incomplete, but it appears that you have defined a class named "waiter" with its views, but you have not added it to the POS view.

To add the button, you can follow the steps in this blog post:

https://www.cybrosys.com/blog/how-to-add-a-custom-button-in-the-pos-screen-odoo-16. 

It provides a step-by-step guide on how to add a custom button to the POS screen using a widget.

In summary, you need to create a new widget for your button, which will contain the HTML code for the button and the JavaScript code to handle its click event. Then, you need to add the widget to the POS view by extending the "pos" model and adding the new widget to its "template" attribute. Finally, you need to define a new action for the button in the "pos.config" model.

Refer to the blog post for detailed instructions and code samples.

Regards

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

I added this but it seems not to be working the pos screen interface dosn't show for me ,what am I missing please?

{

model: 'pos.waiter',

fields: ['name'],

domain: null,

loaded: function(self, waiter){

self.waiter = waiter;

self.db.add_waiter(waiter);

}

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

"widget.pos.waiter"  <-- How can your 'waiter' get into 'widget.pos'?

Everything needs to be loaded before using. Please take a look at point_of_sale/static/src/js/models.js to see how data is fetched.

อวตาร
ละทิ้ง