Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
6870 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

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?

Autore

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 correlati Risposte Visualizzazioni Attività
2
feb 25
1261
2
gen 24
1502
2
dic 23
1521
1
dic 23
1405
1
giu 23
1810