Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
6841 Tampilan

In maintenance module there is a field with `statusbar` widget where you can change request stage (new request -> in progress -> etc...).

https://i.imgur.com/nr9NZDn.png

But it is very unintuitive and people often are unwittingly changing the request stage. It is simply very bad design and does not look like stage controls to an average user.

How do I add a confirmation pop-up so people would stop accidentally changing the request stages? I tried to add `confirm` to this field but I guess it works only with typical buttons.

<field name="stage_id" widget="statusbar" confirm="Are you sure?" options="{'clickable': '1'}" attrs="{'invisible': [('archive', '=', True)]}"/>

Avatar
Buang
Jawaban Terbai

Unfortunately, there is no option to open confirm dialog when clicking on a stage.
you need customization for it. 

ref: https://github.com/odoo/odoo/blob/12.0/addons/web/static/src/js/fields/relational_fields.js#L2329

it's very easy to implement follow this reference is you want to implement it

Avatar
Buang
Penulis

Thanks! I I overridden this "_onClickStage" method and added dialog and it is working now:

https://pastebin.com/1n4zNHhM

Great, happy to see it :)

Sorry, I am new to Odoo. How am I supposed to use the JS Script in the pastebin? Where should I put it and how do I include it?

Penulis

Do you have your custom module created? If yes there are couple steps to get it working. If you don't know how to create new module read the docs first: https://www.odoo.com/documentation/12.0/howtos/backend.html

1) Inside your module create new JS file and call it "relational_fields.js" paste the code from pastebin in there. The path of the file does not really matter but I prefer to put the files in similar way as in Odoo source code: "<your_module_name>/static/src/js/views/fields/relational_fields.js". It is easier to find later.

2) Now you have to tell Odoo to use that file. Create a new XML file (I'm calling it "header.xml") and put it inside "views" folder like this: "<your_module_name>/views/header.xml". The XML code is as follows: https://pastebin.com/Rap5hyuz

3) And lastly you have to attach this XML file inside "__manifest__.py" of your module: https://pastebin.com/1mQCEehH

Post Terkait Replies Tampilan Aktivitas
2
Feb 25
1233
2
Jan 24
1486
2
Des 23
1496
1
Des 23
1382
1
Jun 23
1787