If you are an Odoo developer, you might have used code like
self.write({"partner_ids": [(6, 0, partners.ids)]})
There is another approach to do same using commands. We can import the command as below
from odoo import api, fields, models, _, Command
then we shall do
self.write({"partner_ids": [Command.set(partners.ids)]})
which same as self.write({"partner_ids": [(6, 0, partners.ids)]})
we can also use in the XML as below
<field name="partner_ids" eval="[Command.set(ref('base.main_partner'))]" />
Numeric syntax | Command syntax |
---|---|
(0, 0, {...}) |
Command.create({...}) |
(1, id, {...}) |
Command.update(id, {...}) |
(2, id) |
Command.delete(id) |
(3, id) |
Command.unlink(id) |
(4, id) |
Command.link(id) |
(5, 0, 0) |
Command.clear() |
(6, 0, ids) |
Command.set(ids) |
for more : https://github.com/orgs/OCA/discussions/157
https://www.odoo.com/documentation/17.0/developer/reference/backend/orm.html#odoo.fields.Command
Top comments (0)