Skip to content
Snippets Groups Projects
Commit 74a81354 authored by Vandan Shah's avatar Vandan Shah Committed by Christophe Matthieu
Browse files

[IMP] note: Use first stage as default stage_id if is stage_id empty

UI improvement:
If there is no stage then there will be no button(no status bar) but there will be stages but task or note etc.. will not be in any stage then there will be 'undefined' so by click on that ('undefined') user can move to any stages. To avoid this behavior we add a default stage in note.
parent 476d125b
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,7 @@ class Note(models.Model):
memo = fields.Html('Note Content')
sequence = fields.Integer('Sequence')
stage_id = fields.Many2one('note.stage', compute='_compute_stage_id',
inverse='_inverse_stage_id', string='Stage')
inverse='_inverse_stage_id', string='Stage', default=_get_default_stage_id)
stage_ids = fields.Many2many('note.stage', 'note_stage_rel', 'note_id', 'stage_id',
string='Stages of Users', default=_get_default_stage_id)
open = fields.Boolean(string='Active', default=True)
......@@ -62,9 +62,13 @@ class Note(models.Model):
@api.multi
def _compute_stage_id(self):
first_user_stage = self.env['note.stage'].search([('user_id', '=', self.env.uid)], limit=1)
for note in self:
for stage in note.stage_ids.filtered(lambda stage: stage.user_id == self.env.user):
note.stage_id = stage
# note without user's stage
if not note.stage_id:
note.stage_id = first_user_stage
@api.multi
def _inverse_stage_id(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment