Skip to Content
Menu
This question has been flagged

Hi


I have the following model :

class Project(models.Model):  
    _inherit = 'project.project'
    releases_ids= fields.Many2many('project_extension.release')
sprint_ids= fields.Many2many('project_extension.sprint')
class Release(models.Model):
_name = 'project_extension.release'
     project_id = fields.Many2one('project.project', string="Project")
class Sprint(models.Model):
    _name = 'project_extension.sprint'
    project_id = fields.Many2one('project.project')
    release_id = fields.Many2one('project_extension.release')


I want my sprints to be in the same project as there parent release (and the other way), but I don't know the better way to express it.

Should I make it with python constraint, domain filter, computed field (with get and inverse set function) or with a onchange ?


Thanks for your help.

Avatar
Discard
Best Answer

make project_id (from class project_extension.sprint) readonly, then in the onchange function of the release, write the project in the sprint.


class Sprint(models.Model):
    _name = 'project_extension.sprint'   

project_id = fields.Many2one('project.project')   

release_id = fields.Many2one('project_extension.release', readonly=True)


@api.multi   

@api.onchange('release_id')   

def _compute_change_release_id(self):

     if self.release_id:
        self.project_id = self.release_id.project_id

Kind regards,

Juanvi


Avatar
Discard
Related Posts Replies Views Activity
1
Jul 21
9514
2
May 20
4502
1
Nov 23
1110
1
Sep 18
3725
1
Jan 17
4031