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

Hello all,

I have this new field defined :

partner_territory = fields.Many2one(comodel_name='res.territory', string='Partner\'s territory', required=True)


In this line, can we choose a domain for the 'required=True'? For example, could apply the 'required=True' only if self.division = True (division is an other field of the same model)?

Thanks to comment!


EDIT #1

May be the only way to manage this kind of conditionnal 'Required' for a field is in the XML of the views with this kind of code :

<field name="partner_territory" attrs="{'required':[('division','=',True)]}" />

May be we can't manage it in Python?




아바타
취소
작성자

But is it a kind of thing we can achieve directly in the python field declaration? Is it possible?

As far as I know this is not possible.

베스트 답변

In my opinion the solution of the problem in XML is appropriate.

아바타
취소
작성자

Thanks Zbik!

베스트 답변

Could you try: `required=lambda self: [('division', '=', True)]`

Edit: I haven't tested that though, but it's worth a try

아바타
취소
관련 게시물 답글 화면 활동
2
9월 24
1841
1
2월 19
6352
1
6월 22
13646
0
2월 21
15
1
10월 23
8062