Reputation: 187
I want to have all checkboxes selected by default
I have already asked this question on odoo.com but the answer I got was to set this lambda function to default:
event_booth_ids = fields.Many2many('event.booth', string='Stände', default=lambda self: self.env['event.booth'].search([('id', '=', 2)]))
Unfortunately tho, this does not appear to be working since all checkboxes are still unselected.
What would also work if there was a button to select all. I just need a way to select all at once.
Also, only the records in the domain(This is what it looks like in the view)
<field name="event_booth_ids" widget="many2many_checkboxes" domain="[('halle_id', '=', halle_id)]"/>
should be selected
thank you for your help
Upvotes: 0
Views: 836
Reputation: 26678
Odoo will automatically check the many2many values
To make all checkboxes checked set the value event_booth_ids
to all event.booth
records (filtered by domain
)
You can test it by setting the value of the many2many field when the value of halle_id
changes
Example:
@api.onchange('halle_id')
def _onchange_halle_id(self):
if self.halle_id:
self.event_booth_ids = self.env['event.booth'].search([('halle_id', '=', self.halle_id.id)])
All records assigned to the event_booth_ids
field (returned by the search method) should be checked.
Upvotes: 1