Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
6834 Widoki

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)]}"/>

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
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

Powiązane posty Odpowiedzi Widoki Czynność
2
lut 25
1224
2
sty 24
1482
2
gru 23
1487
1
gru 23
1375
1
cze 23
1781