Skip to Content
Menú
This question has been flagged
6 Respostes
11769 Vistes

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?




Avatar
Descartar
Autor

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.

Best Answer

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

Avatar
Descartar
Autor

Thanks Zbik!

Best Answer

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

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

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de set. 24
1519
1
de febr. 19
6036
1
de juny 22
13362
0
de febr. 21
15
1
d’oct. 23
7698