Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
2751 Weergaven

Hello there, it's possible to make a many2many field required ?

Thanks you !

Avatar
Annuleer
Auteur

The only thing I see for my problem is :

Redefine create and write et add constrains. It's the only thing I can do ?

Auteur

Hello, it doesn't work for me, it's that for this reason I have created this request. :'(

Thanks anyway.

Beste antwoord

try fields_to_use = fields.Many2many('model.model', 'field_names_model', required=True)

Avatar
Annuleer
Beste antwoord

You Can Use len() function in pythin, 

Eg: 

if len(self.Many2mnay_filed) == 0:
raise UserError(_('Please Add Many2many Field'))

Avatar
Annuleer