diff options
| author | Turkesh Patel (Open ERP) <tpa@tinyerp.com> | 2012-03-15 14:41:49 +0530 |
|---|---|---|
| committer | Turkesh Patel (Open ERP) <tpa@tinyerp.com> | 2012-03-15 14:41:49 +0530 |
| commit | 1f0916cc697fefeda9f0d9e1306e4f80299676ef (patch) | |
| tree | 7417054ebbf5ef703937a58adc1f43d1f4dcc495 /addons/fetchmail/res_config.py | |
| parent | 905f24a2df654b76fd7a528a465680315bb2f272 (diff) | |
[IMP] improved code
bzr revid: tpa@tinyerp.com-20120315091149-6ah2tqrzlldiddrk
Diffstat (limited to 'addons/fetchmail/res_config.py')
| -rw-r--r-- | addons/fetchmail/res_config.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/addons/fetchmail/res_config.py b/addons/fetchmail/res_config.py index 226ac869092..4543e566d3a 100644 --- a/addons/fetchmail/res_config.py +++ b/addons/fetchmail/res_config.py @@ -28,11 +28,13 @@ class project_configuration(osv.osv_memory): _inherit = 'project.config.settings' def get_default_email_configurations(self, cr, uid, ids, context=None): + fetchmail_obj = self.pool.get('fetchmail.server') result = {} - if context and context.get('type'): - type = context.get('type') - fetchmail_obj = self.pool.get('fetchmail.server') - server_ids = fetchmail_obj.search(cr, uid, [('name','=',type),('state','!=','done')]) + if not context: + context = {} + type = context.get('type') + if type: + server_ids = fetchmail_obj.search(cr, uid, [('name','=',type),('state','=','done')]) if server_ids: result.update({'project_'+type: True}) server_id = fetchmail_obj.browse(cr, uid, server_ids[0]) @@ -46,12 +48,14 @@ class project_configuration(osv.osv_memory): return result def set_email_configurations(self, cr, uid, ids, context=None): - if context and context.get('type'): - model_obj = self.pool.get('ir.model') - fetchmail_obj = self.pool.get('fetchmail.server') - ir_values_obj = self.pool.get('ir.values') - model = context.get('obj') - type = context.get('type') + model_obj = self.pool.get('ir.model') + fetchmail_obj = self.pool.get('fetchmail.server') + ir_values_obj = self.pool.get('ir.values') + if not context: + context = {} + type = context.get('type') + model = context.get('obj') + if type and model: object_id = model_obj.search(cr, uid, [('model','=',model)]) vals = self.read(cr, uid, ids[0], [], context=context) if vals.get('project_'+type) and object_id: |
