콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
8978 화면

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/

아바타
취소
관련 게시물 답글 화면 활동
1
11월 24
2761
3
10월 22
22233
0
6월 21
2805
1
10월 15
7485
2
11월 24
3187