From f5bac7a41dad3f40ede6dfe7d961977db0267d3b Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Fri, 19 Mar 2010 16:31:15 +0530 Subject: [PATCH] [IMP]: crm: Improvement in default_get for opportunity and phonecall to phonecall wizards bzr revid: rpa@tinyerp.com-20100319110115-ieufxtyu7yipkxzk --- .../crm/wizard/crm_opportunity_to_phonecall.py | 11 +++++++---- addons/crm/wizard/crm_phonecall_to_phonecall.py | 16 ++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/addons/crm/wizard/crm_opportunity_to_phonecall.py b/addons/crm/wizard/crm_opportunity_to_phonecall.py index f816f51a89b..148ec3aec6e 100644 --- a/addons/crm/wizard/crm_opportunity_to_phonecall.py +++ b/addons/crm/wizard/crm_opportunity_to_phonecall.py @@ -49,11 +49,14 @@ class crm_opportunity2phonecall(osv.osv_memory): opp_obj = self.pool.get('crm.opportunity') record_ids = context and context.get('active_ids', []) or [] - res = {} + res = super(crm_opportunity2phonecall, self).default_get(cr, uid, fields, context=context) for opp in opp_obj.browse(cr, uid, record_ids, context=context): - res['name'] = opp.name - res['user_id'] = opp.user_id and opp.user_id.id or False - res['section_id'] = opp.section_id and opp.section_id.id or False + if 'name' in fields: + res.update({'name': opp.name}) + if 'user_id' in fields: + res.update({'user_id': opp.user_id and opp.user_id.id or False}) + if 'section_id' in fields: + res.update({'section_id': opp.section_id and opp.section_id.id or False}) return res def action_cancel(self, cr, uid, ids, context=None): diff --git a/addons/crm/wizard/crm_phonecall_to_phonecall.py b/addons/crm/wizard/crm_phonecall_to_phonecall.py index 60c05e3d6ed..e925d9ef330 100644 --- a/addons/crm/wizard/crm_phonecall_to_phonecall.py +++ b/addons/crm/wizard/crm_phonecall_to_phonecall.py @@ -115,15 +115,19 @@ class crm_phonecall2phonecall(osv.osv_memory): @return : default values of fields. """ + res = super(crm_phonecall2phonecall, self).default_get(cr, uid, fields, context=context) record_id = context and context.get('active_id', False) or False if record_id: phonecall = self.pool.get('crm.phonecall').browse(cr, uid, record_id, context=context) - res = { - 'name': phonecall.name, - 'user_id': phonecall.user_id and phonecall.user_id.id or False, - 'date': phonecall.date, - 'section_id': phonecall.section_id and phonecall.section_id.id or False - } + if 'name' in fields: + res.update({'name': phonecall.name}) + if 'user_id' in fields: + res.update({'user_id': phonecall.user_id and phonecall.user_id.id or False}) + if 'date' in fields: + res.update({'date': phonecall.date}) + if 'section_id' in fields: + res.update({'section_id': phonecall.section_id and phonecall.section_id.id or False}) + return res crm_phonecall2phonecall()