Odoo Help


Constraint, domain or onchange function ?

Evolutis Employee
on 11/25/16, 3:43 AM 1,329 views


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.

Juan Vicente Pascual
On 11/25/16, 11:32 AM

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)



def _compute_change_release_id(self):

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

Kind regards,


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/25/16, 3:43 AM
Seen: 1329 times
Last updated: 11/28/16, 3:16 AM