Hi,
I'm working on adding a new field in opportunites view and I want to override the on_change event of the parent_id field to use my new custom field. I've changed the view crm.crm_case_form_view_oppor of crm.lead object as follow>
Original: \< field name="partner_id" on_change="onchange_partner_id(partner_id, email_from)" string="Customer" context="{'default_name': partner_name, 'default_email': email_from, 'default_phone': phone}" />
Changed: \, field name="partner_id" on_change="onchange_partner_id(partner_id, email_from)" string="Customer" context="{'default_name': partner_name, 'default_email': email_from, 'default_phone': phone, 'new_partner_field' : new_partner_field_value}" />
But now, I can't find the onchange_partner_id method!
I noticed that in crm.lead, there are 2 onchange methods for partner_id: - on_change_partner ( I used this in the lead view ) - onchange_partner_id (defined in base_stage)
The first one is called when changing the partner_id in the lead form. The second one when changing the partner_id in the opportunity form. The methods seem to be almost identical, except that the second one does an address_get for 'contact'.
On Opportunity view the method receives the parameters ( parent_id and email ) and context, however, in base_stage the method doesn't seems to receive the context and I can't override it in order to use my new custom field :
def onchange_partner_id(self, cr, uid, ids, part, email=False):
""" This function returns value of partner address based on partner
:param part: Partner's id
:param email: Partner's email ID
"""
data={}
if part:
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['contact'])
data.update(self.onchange_partner_address_id(cr, uid, ids, addr['contact'])['value'])
return {'value': data}
I want to override this method in Opportunity view. Someone has coped with this task?
Thank you all.