[FIX] base: external identifier traceback

Current behaviour:
Traceback when trying to create
a new external identifier

Steps to reproduce:
1. Activate the developer mode
2. Go to settings
3. Technical > External Identifiers
4. Click on "New"
5. Traceback

Cause of the issue:
Introduced by https://github.com/odoo/odoo/commit/3c62ca1eb96d571b2b686b5caee370324c589ab4
When computing display_name, the model
can be false, and not be in self.env

opw-3489581

closes odoo/odoo#136279

X-original-commit: 2462df26977acc9e3ccafd57863703aacd2f059e
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
Co-authored-by: Rémy Voet <ryv@odoo.com>
This commit is contained in:
Antoine (ande)
2023-09-22 15:06:09 +00:00
co-authored by Rémy Voet
parent 80a0ca239a
commit 2c377f4cb8
+5 -2
View File
@@ -2013,9 +2013,12 @@ class IrModelData(models.Model):
self._table, ['model', 'res_id'])
return res
@api.depends('res_id', 'model')
@api.depends('res_id', 'model', 'complete_name')
def _compute_display_name(self):
for model, model_data_records in self.grouped('model').items():
invalid_records = self.filtered(lambda r: not r.res_id or r.model not in self.env)
for invalid_record in invalid_records:
invalid_record.display_name = invalid_record.complete_name
for model, model_data_records in (self - invalid_records).grouped('model').items():
records = self.env[model].browse(model_data_records.mapped('res_id'))
for xid, target_record in zip(model_data_records, records):
try: