hi
I want add a function in customer payment form that when I select a partner, a field withe name 'section_id' be automatically selected.
for this I add a field with name 'section_id'(many2one) with relation crm_case_section table.
and in account_voucher module, I add this code in onchange_partner_id function:
------------------------------------------------
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date,section_id, context=None):
section_id = False
if not journal_id:
return {}
res = self.recompute_voucher_lines(cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date, context=context)
vals = self.recompute_payment_rate(cr, uid, ids, res, currency_id, date, ttype, journal_id, amount, context=context)
for key in vals.keys():
res[key].update(vals[key])
return res
if partner_id:
partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
value['section_id'] = partner.section_id.name
return {'value': value}
---------------------------------------------------------------
but when I select a partner, 'section_id' field does not select. I don't know what is problem?
Thanks
you had taken partner.section_id.name so that not working please use this one: partner.section_id and partner.section_id.id or False or you can use code from my answer.