Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
8753 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ

it's not working in odoo 12

Please help, Why

Câu trả lời hay nhất

Hi Tai,

     I hope this will help you,check this link.

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 24
2486
3
thg 10 22
22025
0
thg 6 21
2611
1
thg 10 15
7351
2
thg 11 24
2993