Files
odoo_source/odoo/tools
Ayman Adil 6a3444e5bd [FIX] convert.py: skip the creation of a forcecreate=0 record when a reference is missing
When a record is `forcecreate=0` and a reference of one of its fields is missing, the update of the corresponding module fails. In this case, we can skip the creation of this record.

An example of this issue is this [record](https://github.com/odoo/enterprise/blob/6411ae071ace980834befeb8040c94b1a05c8034/documents_account/data/data.xml#L17) in `documents_account` module (enterprise) when the reference of this [field](https://github.com/odoo/enterprise/blob/6411ae071ace980834befeb8040c94b1a05c8034/documents_account/data/data.xml#L20) is missing.

This can be reproduced as follows:
1. Create a DB with `documents_account` module
2. Uninstall `documents_account` module
3. Remove `documents.documents_finance_status`
4. Reinstall `documents_account`

```
Traceback (most recent call last):
  File "/home/ayman/src/odoo/15.0/odoo/tools/convert.py", line 680, in _tag_root
    f(rec)
  File "/home/ayman/src/odoo/15.0/odoo/tools/convert.py", line 567, in _tag_record
    f_val = self.id_get(f_ref)
  File "/home/ayman/src/odoo/15.0/odoo/tools/convert.py", line 663, in id_get
    res = self.model_id_get(id_str, raise_if_not_found)
  File "/home/ayman/src/odoo/15.0/odoo/tools/convert.py", line 669, in model_id_get
    return self.env['ir.model.data']._xmlid_to_res_model_res_id(id_str, raise_if_not_found=raise_if_not_found)
  File "/home/ayman/src/odoo/15.0/odoo/addons/base/models/ir_model.py", line 1943, in _xmlid_to_res_model_res_id
    return self._xmlid_lookup(xmlid)[1:3]
  File "<decorator-gen-35>", line 2, in _xmlid_lookup
  File "/home/ayman/src/odoo/15.0/odoo/tools/cache.py", line 90, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/home/ayman/src/odoo/15.0/odoo/addons/base/models/ir_model.py", line 1936, in _xmlid_lookup
    raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: documents.documents_finance_status
```

closes odoo/odoo#107766

X-original-commit: 2e4f0667397d2d6670df50b9088fa9c23f1f9f5a
Signed-off-by: Christophe Simonis <chs@odoo.com>
2022-12-12 18:16:15 +01:00
..
…
2022-11-17 13:57:35 +01:00
…
…