Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
8780 Переглядів

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.

Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити
Найкраща відповідь

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


Аватар
Відмінити

it's not working in odoo 12

Please help, Why

Найкраща відповідь

Hi Tai,

     I hope this will help you,check this link.

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
лист. 24
2520
3
жовт. 22
22051
0
черв. 21
2636
1
жовт. 15
7362
2
лист. 24
3024