Heads-upHighlight of Weekly #001
Related non-stored many2many fields get no relation table
Non-stored related many2many fields no longer get a relation table, the same as non-related ones. Before, two such fields could end up sharing a table, so reading one filled the other.
On the upgrade checklist: 17.0 → 18.0
Pull requests and commits
Commit message
[FIX] orm: related non-stored many2many has no relation
When we setup a many2many field which is not stored, it must not have a
relation. This is already done for nonrelated fields, but we must do it
also for related fields. Otherwise, we may have side-effects like
finding sibling fields in 20.0: in the code below, reading categories
would fill roles.
```py
model_id = self.env["ir.model"]._get("test_new_api.foo")
fields = [{
"name": "x_partner_id",
"ttype": "many2one",
"relation": "res.partner",
}, {
"name": "x_role_ids",
"ttype": "many2many",
"relation": "res.partner.category",
}, {
"name": "x_partner_category_ids",
"ttype": "many2many",
"relation": "res.partner.category",
"related": "x_partner_id.category_id",
"store": False,
"readonly": True
}]
for f in fields:
f["model_id"] = model_id.id
self.env["ir.model.fields"].create(fields)
env['test_new_api.foo']._fields['x_partner_category_ids'].relation # should be None
```