跳至內容
選單
此問題已被標幟
1 回覆
6912 瀏覽次數

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

頭像
捨棄
最佳答案

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

頭像
捨棄
作者

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?

作者

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

相關帖文 回覆 瀏覽次數 活動
2
2月 25
1294
2
1月 24
1546
2
12月 23
1554
1
12月 23
1431
1
6月 23
1843