Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
5517 Tampilan

I was trying to create a message box/dialog box that pops up when an option is selected. The message box should allow the user select 'Ok' to proceed to a form and 'Cancel' to quit the process. I tried with tkMeassageBox but I kept getting this error 'No protocol specified TclError: couldn't connect display ":0"'.
So, I thought it might be that Tkinter doesn't work well with openerp. Is there a way to go about achieving this?

Thanks in advance

Avatar
Buang

How to display confirmation display box / message box on button click.

Reference: https://goo.gl/6P7aR1

Penulis Jawaban Terbai

@Med, but how do I incorporate the javascript in openerp?

I changed from workflow to object.

Avatar
Buang

Tell us what you exactly want to do with this button.

Penulis

I am working on the HR Leave Module(hr_holidays). Based on the requirements i am working with, when a user puts in a leave request, At the point of selecting a leave type e.g. 'Annual Leave', the system should do a check if the user has allocated leave days left. If user doesn't have any allocated days left, a pop-up should be displayed with a message informing the user to either apply for extra allocation or abort the process. If user clicks on 'Ok' it should redirect the user to the allocation request form but if the user clicks on 'cancel' it should exit the process of leave request. So thats why i need to put up a message box. Thanks

For the case of 'type=object', you need to add a button in your .xml file (this is easy to do), the second step is to write a function in python to handle the action needed when clicking this button (this is the hard part !).

I will extend my answer later.

Jawaban Terbai

Use Javascript rather than Python.

Google for:  JS confirm method ,  alertify.js , jquery-confirm ...

examples: https://www.jquery-az.com/javascript-confirm-alert-box-fancy-and-simple-with-5-online-demos/

                  https://www.bitdegree.org/learn/javascript-alert-box/


A good places where to start in openERP Web dev: https://media.readthedocs.org/pdf/openerp-web-v7/latest/openerp-web-v7.pdf

http://frederic.vanderessen.com/client-side-development-with-openerp/

http://openerpbay.blogspot.com/2013/02/javascript-css-and-jquery-in-openerp-70.html

https://www.odoo.yenthevg.com/tag/javascript/

(Answer modified after comment).

In OpenERP you can create 3 types of Buttons (related to the Button's type attribute):

1_ Type object

2_ Type workflow

3_ Type action

Read te following links

https://openerp-server.readthedocs.io/en/latest/03_module_dev_03.html#button

http://blog.odoobiz.com/2014/10/openerpodoo-call-function-on-button.html 

https://www.odoo.com/es_ES/forum/ayuda-1/question/add-button-to-form-view-85350


I think in your case you are dealing with the type="workflow".


To watch attentively:  Workflow add button                                       Customize workflows in Odoo

The best at last (but in French - an example for HR_Leave workflow modification):  http://laboiteatice.fr/ecotice/diapo/co/modifier_processus.html?mode=html


WARNING:

When customizing a workflow, be sure you do not modify an existing node or arrow, but rather add new nodes or arrows. If you absolutly need to modify a node or arrow, you can only change fields that are empty or set to the default value. If you don't do that, your customization will be overwrited at the next update or upgrade to a future version of OpenERP.

To be continued ...

 



 


Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
0
Feb 16
3634
0
Agu 15
5478
1
Mar 15
458
3
Mar 15
437
1
Mar 15
4512