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.

Versions18.019.020.0
AppFramework & technical

On the upgrade checklist: 17.0 → 18.0

Pull requests and commits

BranchPull requestCommit
18.0odoo/odoo#290240 ↗259f7682fb ↗
19.0odoo/odoo#290286 ↗58dcdd82c3 ↗
20.0odoo/odoo#290414 ↗2bae936138 ↗

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
```

My stack

Pick the versions and apps you run. Weekly digests, this week's table and All changes then show only what concerns you. Saved in this browser.

Versions
Apps
Modules