[IMP] crm, project,...: Prevent stage deletion when there's a linked record
Purpose ======= Avoid having people getting some tasks lost in the "undefined" column. Because they won't understand what it means an how they achieve it. Specification ============= Add an "ondelete='restrict'" on the stage field definition.
This commit is contained in:
committed by
Yannick Tivisse
parent
b2d4238246
commit
89c07862d5
@@ -89,7 +89,7 @@ class Lead(models.Model):
|
||||
priority = fields.Selection(crm_stage.AVAILABLE_PRIORITIES, string='Priority', index=True, default=crm_stage.AVAILABLE_PRIORITIES[0][0])
|
||||
date_closed = fields.Datetime('Closed Date', readonly=True, copy=False)
|
||||
|
||||
stage_id = fields.Many2one('crm.stage', string='Stage', track_visibility='onchange', index=True,
|
||||
stage_id = fields.Many2one('crm.stage', string='Stage', ondelete='restrict', track_visibility='onchange', index=True,
|
||||
domain="['|', ('team_id', '=', False), ('team_id', '=', team_id)]",
|
||||
group_expand='_read_group_stage_ids', default=lambda self: self._default_stage_id())
|
||||
user_id = fields.Many2one('res.users', string='Salesperson', index=True, track_visibility='onchange', default=lambda self: self.env.user)
|
||||
|
||||
@@ -121,7 +121,7 @@ class Applicant(models.Model):
|
||||
partner_id = fields.Many2one('res.partner', "Contact")
|
||||
create_date = fields.Datetime("Creation Date", readonly=True, index=True)
|
||||
write_date = fields.Datetime("Update Date", readonly=True)
|
||||
stage_id = fields.Many2one('hr.recruitment.stage', 'Stage', track_visibility='onchange',
|
||||
stage_id = fields.Many2one('hr.recruitment.stage', 'Stage', ondelete='restrict', track_visibility='onchange',
|
||||
domain="['|', ('job_id', '=', False), ('job_id', '=', job_id)]",
|
||||
copy=False, index=True,
|
||||
group_expand='_read_group_stage_ids',
|
||||
|
||||
@@ -294,7 +294,7 @@ class MaintenanceRequest(models.Model):
|
||||
category_id = fields.Many2one('maintenance.equipment.category', related='equipment_id.category_id', string='Category', store=True, readonly=True)
|
||||
equipment_id = fields.Many2one('maintenance.equipment', string='Equipment', index=True)
|
||||
technician_user_id = fields.Many2one('res.users', string='Owner', track_visibility='onchange', oldname='user_id')
|
||||
stage_id = fields.Many2one('maintenance.stage', string='Stage', track_visibility='onchange',
|
||||
stage_id = fields.Many2one('maintenance.stage', string='Stage', ondelete='restrict', track_visibility='onchange',
|
||||
group_expand='_read_group_stage_ids', default=_default_stage)
|
||||
priority = fields.Selection([('0', 'Very Low'), ('1', 'Low'), ('2', 'Normal'), ('3', 'High')], string='Priority')
|
||||
color = fields.Integer('Color Index')
|
||||
|
||||
@@ -216,7 +216,7 @@ class MassMailingCampaign(models.Model):
|
||||
_rec_name = "campaign_id"
|
||||
_inherits = {'utm.campaign': 'campaign_id'}
|
||||
|
||||
stage_id = fields.Many2one('mail.mass_mailing.stage', string='Stage', required=True,
|
||||
stage_id = fields.Many2one('mail.mass_mailing.stage', string='Stage', ondelete='restrict', required=True,
|
||||
default=lambda self: self.env['mail.mass_mailing.stage'].search([], limit=1))
|
||||
user_id = fields.Many2one(
|
||||
'res.users', string='Responsible',
|
||||
|
||||
@@ -469,7 +469,7 @@ class Task(models.Model):
|
||||
], default='0', index=True, string="Priority")
|
||||
sequence = fields.Integer(string='Sequence', index=True, default=10,
|
||||
help="Gives the sequence order when displaying a list of tasks.")
|
||||
stage_id = fields.Many2one('project.task.type', string='Stage', track_visibility='onchange', index=True,
|
||||
stage_id = fields.Many2one('project.task.type', string='Stage', ondelete='restrict', track_visibility='onchange', index=True,
|
||||
default=_get_default_stage_id, group_expand='_read_group_stage_ids',
|
||||
domain="[('project_ids', '=', project_id)]", copy=False)
|
||||
tag_ids = fields.Many2many('project.tags', string='Tags', oldname='categ_ids')
|
||||
|
||||
@@ -58,7 +58,7 @@ class Survey(models.Model):
|
||||
title = fields.Char('Title', required=True, translate=True)
|
||||
page_ids = fields.One2many('survey.page', 'survey_id', string='Pages', copy=True)
|
||||
stage_id = fields.Many2one('survey.stage', string="Stage", default=_default_stage,
|
||||
ondelete="set null", copy=False, group_expand='_read_group_stage_ids')
|
||||
ondelete="restrict", copy=False, group_expand='_read_group_stage_ids')
|
||||
auth_required = fields.Boolean('Login required', help="Users with a public link will be requested to login before taking part to the survey",
|
||||
oldname="authenticate")
|
||||
users_can_go_back = fields.Boolean('Users can go back', help="If checked, users can go back to previous pages.")
|
||||
|
||||
@@ -65,7 +65,7 @@ class Track(models.Model):
|
||||
partner_biography = fields.Html('Speaker Biography')
|
||||
tag_ids = fields.Many2many('event.track.tag', string='Tags')
|
||||
stage_id = fields.Many2one(
|
||||
'event.track.stage', string='Stage',
|
||||
'event.track.stage', string='Stage', ondelete='restrict',
|
||||
index=True, copy=False, default=_get_default_stage_id,
|
||||
group_expand='_read_group_stage_ids',
|
||||
required=True, track_visibility='onchange')
|
||||
|
||||
@@ -8,7 +8,7 @@ class Post(models.Model):
|
||||
|
||||
documentation_toc_id = fields.Many2one('forum.documentation.toc', string='Documentation ToC',
|
||||
ondelete='set null', group_expand='_read_group_stage_ids')
|
||||
documentation_stage_id = fields.Many2one('forum.documentation.stage', string='Documentation Stage',
|
||||
documentation_stage_id = fields.Many2one('forum.documentation.stage', string='Documentation Stage', ondelete='restrict',
|
||||
default=lambda self: self.env['forum.documentation.stage'].search([], limit=1))
|
||||
color = fields.Integer(string='Color Index')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user