Problem is very simple. I am using certain API which is called when I click a button and some of the fields are being filled from a widget that I created
I use that widget at multiple places in my system
The problem is that when those fields are filled I need
@api.onchange('exmplple')
method to trigger them, but it doesn't (I would say it's a bug).
What would be the workaround or solution to trigger that method when those fields change whenever my widget works?
Update:
Sorry for the confusion that my question caused. I will try to explain what exactly I was thinking and why I only have tried server side things so far. The problem is that in any other situation python code api.onechange would work completely fine.
@api.onchange
def do_smth_when_country_changes(self):
if country_id = 133
self.lang = 'pl_PL'
elif:
.......more ifs
But I have fields which are filled from google maps (JavaScript code that I wrote).
<field name='autocomplete' widget='gmap_autocomplete' country_id='country_id'>
<field name='country_id'>
Here when i search for address with autocomplete field, and i click on one, country_id field will be filled with country. And Also there are some other field has to change value whenever country_id changes (for example res.partner field lang).
<field name='lang'/>
Since Python onchange method doesn't trigger country_id field I though that JavaScript would probably only thing that would solve my problem. So What I want to do is to access field coutry_id in specific form view (let's say only in view_partner_form) and when it changes access value of lag field and change it as well.
new Model('your_addon.model_name').call('onchange_method_name',[args_here])
This was something interesting to look at, I would like to read about it more, for example how do I call that method only when I am at specific form and so on. Could you recommend any nice documentation or even tutorial about this? – enigmq Jun 22 '17 at 06:05