[FIX] util/orm: Fix non store field issue - #485
Conversation
|
upgradeci retry with always base in all versions |
|
upgradeci retry with always only base |
|
Not sure that it should be handled here. It looks like it can be handled by a specific script. |
|
@KangOl FYI here is tbg https://upgrade.odoo.com/odoo/tbg/2822
The thing is, we cannot be sure whether the client’s fields are searchable or not, as this entirely depends on their custom code. I think we should fix this generically by patching the same behavior in mock_crawl or here. Since we cannot reliably determine whether a field is searchable, and marking the field as manual is what causes the issue here, it would be better to handle it at this level. This was not the case previously, as mentioned in the description.
that's already being managed by adding the failing menus to env variable skip_menus |
3597374 to
c4584f8
Compare
Since 18.3, domain resolution goes strictly through
` _search`
```
domain.optimize_full(model)
if not domain.is_true():
query.add_where(domain._to_sql(self, self._table, query))
```
[domain]: https://github.com/odoo/odoo/blob/2f0f8e5e00685129b5bbe954117bc9f80a568e88/odoo/orm/models.py#L5365-L5371
optimize_full() leaves a leaf untouched when the field has no
`search=` defined, so `_to_sql()` calls `field.to_sql()` directly.
For non-stored fields this now raises:
```
File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 5256, in _order_to_sql
term = self._order_field_to_sql(alias, field_name, sql_direction, sql_nulls, query)
File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 5315, in _order_field_to_sql
sql_field = self._field_to_sql(alias, field_name, query)
File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 2930, in _field_to_sql
sql = field.to_sql(self, alias)
File "/home/odoo/src/odoo/19.0/odoo/orm/fields_textual.py", line 395, in to_sql
sql_field = super().to_sql(model, alias)
File "/home/odoo/src/odoo/19.0/odoo/orm/fields.py", line 1216, in to_sql
raise ValueError(f"Cannot convert {self} to SQL because it is not stored")
ValueError: Cannot convert photovoltaics.installer.name to SQL because it is not stored
```
Previously (pre-18.3), such leaves were treated as always-true instead
of raising:
https://github.com/odoo/odoo/blob/d9c06a66356dd9d5a50821b8cde6194967353c18/odoo/osv/expression.py#L1180-L1187
Since we don't always know if a custom/third-party field is stored or
searchable, assign a dummy `search=` returning an always-true leaf
(e.g. [(1, '=', 1)]). This makes optimize_full() resolve the domain to
is_true() before _to_sql() runs, restoring the old behavior and
avoiding the ValueError.
upg- 4578773
c4584f8 to
5376110
Compare

Since 18.3, domain resolution goes strictly through
_searchoptimize_full() leaves a leaf untouched when the field has no
search=defined, so_to_sql()callsfield.to_sql()directly. For non-stored fields this now raises:Previously (pre-18.3), such leaves were treated as always-true instead of raising:
https://github.com/odoo/odoo/blob/d9c06a66356dd9d5a50821b8cde6194967353c18/odoo/osv/expression.py#L1180-L1187
Since we don't always know if a custom/third-party field is stored or searchable, assign a dummy
search=returning an always-true leaf (e.g. [(1, '=', 1)]). This makes optimize_full() resolve the domain to is_true() before _to_sql() runs, restoring the old behavior and avoiding the ValueError.