Skip to Content
Menu
This question has been flagged
1 Odpoveď
6867 Zobrazenia

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
Zrušiť
Best Answer

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
Zrušiť
Autor

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?

Autor

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

Related Posts Replies Zobrazenia Aktivita
2
feb 25
1261
2
jan 24
1501
2
dec 23
1519
1
dec 23
1405
1
jún 23
1807