[FIX] Mail alias unlink suport for the inheriting mdoels
bzr revid: jam@tinyerp.com-20120705125417-nw0shanp3a756vmy
This commit is contained in:
parent
39d57c0b79
commit
0416c757fa
|
@ -122,7 +122,7 @@ class crm_case_section(osv.osv):
|
|||
'note': fields.text('Description'),
|
||||
'working_hours': fields.float('Working Hours', digits=(16,2 )),
|
||||
'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'),
|
||||
'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="restrict", required=True,
|
||||
'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True,
|
||||
help="This Unique Mail Box Alias of the Sales Team allows to manage the Seamless email communication between Mail Box and OpenERP,"
|
||||
"This Alias MailBox also create and Manage the new Email Leads for this Sales Team and also manage the existing Lead email communication."),
|
||||
}
|
||||
|
@ -167,12 +167,20 @@ class crm_case_section(osv.osv):
|
|||
name = vals.get('alias_name') or vals['name']
|
||||
alias_id = alias_pool.create_unique_alias(cr, uid,
|
||||
{'alias_name': "sales_team_"+name,
|
||||
'alias_model_id': self._name}, context=context)
|
||||
'alias_model_id': "crm.lead"}, context=context)
|
||||
alias = alias_pool.read(cr, uid, alias_id, ['alias_name'],context)
|
||||
vals.update({'alias_id': alias_id, 'alias_name': alias['alias_name']})
|
||||
res = super(crm_case_section, self).create(cr, uid, vals, context)
|
||||
alias_pool.write(cr, uid, [vals['alias_id']],{'alias_defaults':{'section_id': res,'type':'lead'}},context)
|
||||
return res
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
#Will extract the linked Mail Alias 'alias_id' and unlink it explictly.
|
||||
alias_pool = self.pool.get('mail.alias')
|
||||
alias_ids =[ record.alias_id.id for record in self.browse(cr, uid, ids, context=context) if record.alias_id ]
|
||||
res = super(crm_case_section, self).unlink(cr, uid, ids, context=context)
|
||||
alias_pool.unlink(cr, uid, alias_ids, context=context)
|
||||
return res
|
||||
|
||||
class crm_case_categ(osv.osv):
|
||||
""" Category of Case """
|
||||
|
|
|
@ -545,7 +545,7 @@ class hr_job(osv.osv):
|
|||
_inherits = {'mail.alias': 'alias_id'}
|
||||
_columns = {
|
||||
'survey_id': fields.many2one('survey', 'Interview Form', help="Choose an interview form for this job position and you will be able to print/answer this interview from all applicants who apply for this job"),
|
||||
'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="restrict", required=True,
|
||||
'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True,
|
||||
help="This Unique Mail Box Alias of the Job allows to manage the Seamless email communication between Mail Box and OpenERP,"
|
||||
"This Alias MailBox also create and Manage the new Email applicant for this job and also manage the existing applicant email communication."),
|
||||
}
|
||||
|
@ -556,12 +556,20 @@ class hr_job(osv.osv):
|
|||
name = vals.get('alias_name') or vals['name']
|
||||
alias_id = alias_pool.create_unique_alias(cr, uid,
|
||||
{'alias_name': "job_"+name,
|
||||
'alias_model_id': self._name}, context=context)
|
||||
'alias_model_id': "hr.applicant"}, context=context)
|
||||
alias = alias_pool.read(cr, uid, alias_id, ['alias_name'],context)
|
||||
vals.update({'alias_id': alias_id, 'alias_name': alias['alias_name']})
|
||||
res = super( hr_job, self).create(cr, uid, vals, context)
|
||||
alias_pool.write(cr, uid, [vals['alias_id']], {"alias_defaults": {'job_id': res}}, context)
|
||||
return res
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
#Will extract the linked Mail Alias 'alias_id' and unlink it explictly.
|
||||
alias_pool = self.pool.get('mail.alias')
|
||||
alias_ids =[record.alias_id.id for record in self.browse(cr, uid, ids, context=context) if record.alias_id]
|
||||
res = super(hr_job, self).unlink(cr, uid, ids, context=context)
|
||||
alias_pool.unlink(cr, uid, alias_ids, context=context)
|
||||
return res
|
||||
|
||||
def action_print_survey(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
|
|
|
@ -130,7 +130,7 @@ class mail_group(osv.osv):
|
|||
'member_count': fields.function(get_member_ids, type='integer', string='Member count', multi='get_member_ids'),
|
||||
'is_subscriber': fields.function(get_member_ids, type='boolean', string='Joined', multi='get_member_ids'),
|
||||
'last_month_msg_nbr': fields.function(get_last_month_msg_nbr, type='integer', string='Messages count for last month'),
|
||||
'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="restrict", required=True,
|
||||
'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True,
|
||||
help="This Unique Mail Box Alias of the Group allows to manage the Seamless email communication between Mail Box and OpenERP,"
|
||||
"This Alias MailBox manage the Group email communication.")
|
||||
}
|
||||
|
@ -154,3 +154,11 @@ class mail_group(osv.osv):
|
|||
alias_pool.write(cr, uid, [vals['alias_id']], {"alias_force_thread_id": res}, context)
|
||||
return res
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
#Will extract the linked Mail Alias 'alias_id' and unlink it explictly.
|
||||
alias_pool = self.pool.get('mail.alias')
|
||||
alias_ids =[record.alias_id.id for record in self.browse(cr, uid, ids, context=context) if record.alias_id]
|
||||
res = super(mail_group, self).unlink(cr, uid, ids, context=context)
|
||||
alias_pool.unlink(cr, uid, alias_ids, context=context)
|
||||
return res
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class res_users(osv.osv):
|
|||
('none', 'Never')
|
||||
], 'Receive Feeds by Email', required=True,
|
||||
help="Choose in which case you want to receive an email when you receive new feeds."),
|
||||
'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="restrict", required=True,
|
||||
'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True,
|
||||
help="This Unique Mail Box Alias of the User allows to manage the Seamless email communication between Mail Box and OpenERP,"
|
||||
"This Alias MailBox manage the Users email communication."),
|
||||
}
|
||||
|
@ -84,6 +84,13 @@ class res_users(osv.osv):
|
|||
self.pool.get('mail.alias').write(cr, uid, [user.alias_id.id], {'alias_name': vals['login']}, context=context)
|
||||
return super(res_users, self).write(cr, uid, ids, vals, context=context)
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
#Will extract the linked Mail Alias 'alias_id' and unlink it explictly.
|
||||
alias_pool = self.pool.get('mail.alias')
|
||||
alias_ids =[record.alias_id.id for record in self.browse(cr, uid, ids, context=context) if record.alias_id]
|
||||
res = super(res_users, self).unlink(cr, uid, ids, context=context)
|
||||
alias_pool.unlink(cr, uid, alias_ids, context=context)
|
||||
return res
|
||||
|
||||
def message_load_ids(self, cr, uid, ids, limit=100, offset=0, domain=[], ascent=False, root_ids=[False], context=None):
|
||||
""" Override of message_load_ids
|
||||
|
|
|
@ -153,10 +153,16 @@ class project(osv.osv):
|
|||
return res
|
||||
|
||||
def unlink(self, cr, uid, ids, *args, **kwargs):
|
||||
alias_ids = []
|
||||
alias_pool = self.pool.get('mail.alias')
|
||||
for proj in self.browse(cr, uid, ids):
|
||||
if proj.tasks:
|
||||
raise osv.except_osv(_('Operation Not Permitted !'), _('You cannot delete a project containing tasks. I suggest you to desactivate it.'))
|
||||
return super(project, self).unlink(cr, uid, ids, *args, **kwargs)
|
||||
elif proj.alias_id:
|
||||
alias_ids.append(proj.alias_id.id)
|
||||
res = super(project, self).unlink(cr, uid, ids, *args, **kwargs)
|
||||
alias_pool.unlink(cr, uid, alias_ids, *args, **kwargs)
|
||||
return res
|
||||
|
||||
def _task_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(ids, 0)
|
||||
|
@ -217,7 +223,7 @@ class project(osv.osv):
|
|||
'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),
|
||||
'task_count': fields.function(_task_count, type='integer', string="Open Tasks"),
|
||||
'color': fields.integer('Color Index'),
|
||||
'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="restrict", required=True,
|
||||
'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True,
|
||||
help="This Unique Mail Box Alias of the Project allows to manage the Seamless email communication between Mail Box and OpenERP,"
|
||||
"This Alias MailBox also create and Manage the new Email Tasks/Issues for this Project and also manage the existing Task/Issue email communication."),
|
||||
'alias_model': fields.selection(_get_alias_model, "Alias Model",select="1", required=True,
|
||||
|
@ -503,7 +509,7 @@ def Project():
|
|||
name = vals.get('alias_name') or vals['name']
|
||||
alias_id = alias_pool.create_unique_alias(cr, uid,
|
||||
{'alias_name': "project_"+name,
|
||||
'alias_model_id': self._name}, context=context)
|
||||
'alias_model_id': vals.get('alias_model', 'project.task')}, context=context)
|
||||
alias = alias_pool.read(cr, uid, alias_id, ['alias_name'],context)
|
||||
vals.update({'alias_id': alias_id, 'alias_name': alias['alias_name']})
|
||||
res = super( project, self).create(cr, uid, vals, context)
|
||||
|
|
Loading…
Reference in New Issue