Try this code please :)
from odoo import models, api, fields, SUPERUSER_ID, _
class ProjectTaskType(models.Model):
_inherit = 'project.task.type'
# Step specific code to identify it
code = fields.Char('Code')
_sql_constraints = [
('code_uniq', 'unique (code)', "Stage code already exists!"),
]
class Project(models.Model):
_inherit = 'project.project'
@api.model
def _read_group_stage_ids(self, stages, domain, order):
# Call Super Function
response = super(Task, self)._read_group_stage_ids(stages, domain, order)
search_domain = [('id', 'in', response.ids)]
# Append my specifik stages [Stages whose code is equal to todo or inprogress or done or canceled]
search_domain = ['|', ('code', 'in', ['todo', 'inprogress', 'done', 'canceled'])] + search_domain
stage_ids = stages._search(search_domain, order=order, access_rights_uid=SUPERUSER_ID)
return stages.browse(stage_ids)