Skip to Content
Menú
This question has been flagged
3 Respostes
8611 Vistes

I have 3 objects : students, score and subject

class Student(osv.osv):
     _name= "astudent"
     _columns={
     'name': fields.char(string='Name',size=32),
     'subject' : fields.many2many('asubject', 'table', 'stu', 'subj', 'Subject'),
'score' : fields.one2many('ascore','student','Score'),
}
class subject(osv.osv):
     _name = "asubject"
     _columns={
     'name': fields.char('Subject Name'),
    'score' : fields.one2many('ascore','subject','Score'),
}

class score(osv.osv):
     _name = "ascore"
     _columns={
     'score': fields.float('Diem', required=True),

     'student' : fields.many2one('astudent', string='Student', delegate=True, required=True), 'subject' : fields.many2one('asubject', string='Subject', delegate=True, required=True,),
}

In xml file of "astudent", I chose the subject, and after, I will set the "score". I want when I set the "score", I just can chose the "object" (inside "ascore") between the "object" are chosed.

I think I must use "related" or "domain" but I can't do that

Sorry for my bad english, thanks for any help.

Avatar
Descartar
Best Answer

I don't understand your problem but i think you should use domain

ex: Add domain in `subject` field on your tree view in `astudent` form

[('subject', 'in', parent.subject)]

Note: You shoud re-define name of your field

 - one2many, many2many field should end with _ids

 - many2one field should end with _id

Avatar
Descartar
Best Answer

How to create a dependent drop down (many2one) fields in Odoo. For example I have two many2one fields (campus_id and department_id), and we want to change the department on the basis of campus field.

1 @api.onchange('campus_id')
2 def _campus_onchange(self):
3 res = {}
4 res['domain']={'department_id':[('campus_id', '=', self.campus_id.id)]}
5 return res

Read more about domain: http://learnopenerp.blogspot.com/2016/10/onchange-many2one-filed-in-odoo.html


Avatar
Descartar

it's not working in odoo 12

Please help, Why

Best Answer

Hi Tai,

     I hope this will help you,check this link.

        http://www.odoo.gotodoo.com/field-type-reference-odoo-use/

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de nov. 24
2160
3
d’oct. 22
21899
0
de juny 21
2404
1
d’oct. 15
7213
2
de nov. 24
2826