[FIX] Force safer ondelete=restrict on the `alias_id` _inherits FK on models with a mail.alias parent
The delete-rule was initially set to `cascade` in revision 6897.16.13 revid:odo@openerp.com-20120705141706-5gm5mmqode3bvkuc because the ORM would not allow anything else for the FK of an _inherits relationship. This constraint was later lifted in 7.0 server at revision 4681 revid:odo@openerp.com-20121212210247-emrz5rf9ewcwdggu so we can now switch to the intended default behavior: when deleting mail aliases we never want to cascade delete the child records, as that could lead to unwanted deletions. On the other hand the aliases are automatically deleted when the record they belong to is deleted, as a kind of internal dependency. This is the intended safe way to delete them. There is a special case when the same alias is manually set on multiple records, in which case you will not be able to delete any of those records. This is an acceptable exception and should be manually handled if ever needed, by temporarily linking the records to delete to new dummy aliases. bzr revid: odo@openerp.com-20130827150708-62hqk8p7twd527n0
This commit is contained in:
parent
f9a01a68a1
commit
baef4d3d92
|
@ -125,7 +125,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', 'Alias', ondelete="cascade", required=True,
|
||||
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True,
|
||||
help="The email address associated with this team. New emails received will automatically "
|
||||
"create new leads assigned to the team."),
|
||||
}
|
||||
|
|
|
@ -496,7 +496,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', 'Alias', ondelete="cascade", required=True,
|
||||
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True,
|
||||
help="Email alias for this job position. New emails will automatically "
|
||||
"create new applicants for this job position."),
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class mail_group(osv.Model):
|
|||
help="Small-sized photo of the group. It is automatically "\
|
||||
"resized as a 64x64px image, with aspect ratio preserved. "\
|
||||
"Use this field anywhere a small image is required."),
|
||||
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True,
|
||||
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True,
|
||||
help="The email address associated with this group. New emails received will automatically "
|
||||
"create new topics."),
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class res_users(osv.Model):
|
|||
_inherits = {'mail.alias': 'alias_id'}
|
||||
|
||||
_columns = {
|
||||
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True,
|
||||
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True,
|
||||
help="Email address internally associated with this user. Incoming "\
|
||||
"emails will appear in the user's notifications."),
|
||||
}
|
||||
|
|
|
@ -281,7 +281,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', 'Alias', ondelete="cascade", required=True,
|
||||
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True,
|
||||
help="Internal email associated with this project. Incoming emails are automatically synchronized"
|
||||
"with Tasks (or optionally Issues if the Issue Tracker module is installed)."),
|
||||
'alias_model': fields.selection(_alias_models, "Alias Model", select=True, required=True,
|
||||
|
|
Loading…
Reference in New Issue