跳至内容
菜单
此问题已终结
1 回复
2484 查看

I have a many2many checkboxes widget.

I want all checkboxes to be checked by default.

How can i do this?


形象
丢弃
最佳答案

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.

形象
丢弃
编写者

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

编写者

what am i doing wrong?

相关帖文 回复 查看 活动
0
6月 22
2417
2
12月 23
2194
1
12月 23
2659
1
2月 24
2225
2
8月 23
2331