跳至內容
選單
此問題已被標幟
6 回覆
11885 瀏覽次數

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
1600
1
2月 19
6129
1
6月 22
13452
0
2月 21
15
1
10月 23
7800