[IMP] improved code
bzr revid: tpa@tinyerp.com-20120315091149-6ah2tqrzlldiddrk
This commit is contained in:
parent
905f24a2df
commit
1f0916cc69
|
@ -46,11 +46,10 @@ class project_claim_mail_configuration(osv.osv_memory):
|
|||
def get_default_claim_server(self, cr, uid, ids, context=None):
|
||||
context.update({'type':'claim'})
|
||||
res = self.get_default_email_configurations(cr, uid, ids, context)
|
||||
|
||||
return res
|
||||
|
||||
def set_default_claim_server(self, cr, uid, ids, context=None):
|
||||
context.update({'type':'claim','obj':'crm.claim'})
|
||||
res = self.set_email_configurations(cr, uid, ids, context)
|
||||
self.set_email_configurations(cr, uid, ids, context)
|
||||
|
||||
project_claim_mail_configuration()
|
|
@ -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:
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
|
||||
class project_configuration(osv.osv_memory):
|
||||
_inherit = 'project.config.settings'
|
||||
|
|
|
@ -43,13 +43,13 @@ class project_issue_mail_configuration(osv.osv_memory):
|
|||
}
|
||||
|
||||
def get_default_issue_server(self, cr, uid, ids, context=None):
|
||||
context = {'type':'issue'}
|
||||
context.update({'type':'issue'})
|
||||
res = self.get_default_email_configurations(cr, uid, ids, context)
|
||||
return res
|
||||
|
||||
def set_default_issue_server(self, cr, uid, ids, context=None):
|
||||
context = {'type':'issue','obj':'project.issue'}
|
||||
res = self.set_email_configurations(cr, uid, ids, context)
|
||||
context.update({'type':'issue','obj':'project.issue'})
|
||||
self.set_email_configurations(cr, uid, ids, context)
|
||||
|
||||
|
||||
project_issue_mail_configuration()
|
Loading…
Reference in New Issue