-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TA#66483 [IMP] project_stage: Fold kanban column by stage (#401)
* TA#66483 [FIX] Folded kanban on load * TA#66483 [IMP] project_stage: Fold kanban by stage --------- Co-authored-by: Majda EL MARIOULI <majdaelmariouli@gmail.com>
- Loading branch information
1 parent
8e6f4ce
commit d9df5aa
Showing
2 changed files
with
32 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,50 @@ | ||
# © 2022 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import fields, models | ||
from odoo import api, fields, models, SUPERUSER_ID | ||
|
||
|
||
class ProjectStage(models.Model): | ||
_name = 'project.stage' | ||
_description = 'Project Stage' | ||
_order = 'sequence' | ||
_name = "project.stage" | ||
_description = "Project Stage" | ||
_order = "sequence, id" | ||
|
||
name = fields.Char(required=True, translate=True) | ||
sequence = fields.Integer() | ||
description = fields.Text(translate=True) | ||
active = fields.Boolean(default=True) | ||
fold = fields.Boolean( | ||
string='Folded in Kanban', | ||
string="Folded in Kanban", | ||
help="""This stage is folded in the kanban view when there are | ||
no records in that stage to display.""" | ||
no records in that stage to display.""", | ||
) | ||
|
||
|
||
class ProjectWithStage(models.Model): | ||
_inherit = 'project.project' | ||
class ProjectProject(models.Model): | ||
_inherit = "project.project" | ||
|
||
def compute_default_stage(self): | ||
return self.env['project.stage'].search( | ||
[('fold', '=', False)], order='sequence', limit=1).id | ||
def _get_default_stage_id(self): | ||
return ( | ||
self.env["project.stage"] | ||
.search([("fold", "=", False)], order="sequence", limit=1) | ||
.id | ||
) | ||
|
||
@api.model | ||
def _read_group_stage_ids(self, stages, domain, order): | ||
search_domain = [("id", "in", stages.ids)] | ||
stage_ids = stages._search( | ||
search_domain, order=order, access_rights_uid=SUPERUSER_ID | ||
) | ||
return stages.browse(stage_ids) | ||
|
||
stage_id = fields.Many2one( | ||
'project.stage', 'Stage', ondelete='restrict', index=True, | ||
default=compute_default_stage, | ||
tracking=True) | ||
"project.stage", | ||
string="Stage", | ||
ondelete="restrict", | ||
index=True, | ||
default=_get_default_stage_id, | ||
group_expand="_read_group_stage_ids", | ||
tracking=True, | ||
copy=False | ||
) |