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
4272 Widoki

I want in res.partner model make onchange event on field parent_id. this field already have onchange event by old api, so i changed it`s value on XML to on_change=1 and added .py code

 

@api.onchange('parent_id')
def onchange_parent_id(self, parent_id=None):
     old_res = super(res_partner, self).onchange_parent_id(self.parent_id.id)old_res = super(res_partner, self).onchange_parent_id(self.parent_id.id)
     if type(old_res) is dict and old_res.has_key('value'):
         for field, value in old_res.get('value').items():
             if hasattr(self, field):
                 setattr(self, field, value)setattr(self, field, value)
     if self.parent_id:
         self.category_id = self.parent_id.category_id
     return old_res
after update, then i open contact form and changing parent_id, everything works as i want, but when i press save error occurrs


File "/opt/odoo-vaimada/openerp/addons/base/res/res_partner.py", line 477, in _fields_sync    
context=context).get('value', {})
TypeError: onchange_parent_id() takes at most 2 arguments (6 given)


as i understand it occurrs becouse on create other method (_fields_sync) also calls this onchange_parent_id methot by 'old style'. Maybe someone can advice me how to fix this.

Thanks in advance

 

Awatar
Odrzuć
Autor Najlepsza odpowiedź

work arround for me was change beginning of function:


@api.model    
@api.onchange('parent_id')
def onchange_parent_id_new(self, parent_id=None):
.....
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lut 16
4052
1
gru 15
5977
1
sie 25
363
2
lip 25
2810
3
lip 25
630