I'm trying to update a many2many field from website via a <select multiple> element.
However, I'm unable to store already existing ids along with newly selected options.
For example, the many2many relation holds the ids 1,2,3. Now, upon updating the new ids would supposed to be 1,2,3,4,5 based on the selected <option>s in the <select> - but only the new ids (4,5) are stored, 1,2,3 get removed.
values['field'] = (6, 0, [1,2,3,4,5])
res.write(values)
Any hints, why this could be happening? Maybe I'm misinterpreting the documentation saying "(6, _, ids)
replaces all existing records in the set by the ids list, equivalent to using the command 5 followed by a command 4 for each id in ids." (https://www.odoo.com/documentation/12.0/reference/orm.html#model-reference)?
---
Edit fyi:
Model:
_inherit = 'res.partner'
field = fields.Many2many(comodel_name='res.country', relation="some_country_res_partner_rel", string='Some countries', default=False)
values['field'] = [(6, 0, [1,2,3,4,5])]
Nope, "values" (at the time of "res.write(values)") is {'field': (6, 0, ['1', '2','3','4','5'])} - your suggestion would get me {'field': ([(6, 0, ['1', '2','3','4','5'])],)} which then does not update the many2many field at all (already set relations are kept in that case though)