Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
2515 Vues

I have a many2many checkboxes widget.

I want all checkboxes to be checked by default.

How can i do this?


Avatar
Ignorer
Meilleure réponse

Hi, Josef,

you should define the many2Many field with the default option.

service_ids = fields.Many2many('sale.order.service.type.line', 'service_type_line_tag_rel', 'order_id', 'order_service_type_id', string = 'service_ids', tracking = True, default = lambda self: self.env['sale.order.service.type.line'].search([('id', '=', 2)]))

Attention to the default option in the above example and modify it to your own requirement.

Thanks.

----------

Update:

Josef, for details you can refer to:

https://www.odoo.com/zh_CN/forum/bang-zhu-1/how-create-a-check-box-field-in-custom-module-94390

Thanks.

Avatar
Ignorer
Auteur

Hey, I tried this
event_booth_ids = fields.Many2many('event.booth', string='Stände', default=lambda self: self.env['event.booth'].search([('id', '=', 2)]))

but it does not work

Auteur

what am i doing wrong?

Publications associées Réponses Vues Activité
0
juin 22
2423
2
déc. 23
2231
1
déc. 23
2674
1
févr. 24
2236
2
août 23
2338