Skip to content

[FIX] util/orm: don't mark inherited field manual for custom#418

Open
sagu-odoo wants to merge 1 commit into
odoo:masterfrom
odoo-dev:master-fix-custom-field-manaul-sagu
Open

[FIX] util/orm: don't mark inherited field manual for custom#418
sagu-odoo wants to merge 1 commit into
odoo:masterfrom
odoo-dev:master-fix-custom-field-manaul-sagu

Conversation

@sagu-odoo

@sagu-odoo sagu-odoo commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

During the upgrade process, inherited fields were incorrectly marked as manual, while they should retain their original
state (base).

Fields created via Studio are expected to have state = manual, whereas inherited fields must remain base according to ORM behavior 1.

In particular, marking inherited fields as manual triggers unnecessary computations, especially for non-stored fields and
Many2many fields linked to ir.attachment.

This change ensures that:

  • inherited fields are not marked as manual
  • only fields explicitly created via Studio or ir.model.fields
    are considered manual

This aligns the upgrade behavior with the ORM logic and prevents
unwanted computations on inherited fields.

('account.product_product_menu_sellable', 122, 'Accounting > Customers > Products', 254):
 Traceback (most recent call last):
   File "/tmp/tmpqgivh7_j/migrations/base/tests/test_mock_crawl.py", line 335, in crawl_menu
    self.mock_action(action_vals)
   File "/tmp/tmpqgivh7_j/migrations/base/tests/test_mock_crawl.py", line 348, in mock_action
    return self.mock_act_window(action)
   File "/tmp/tmpqgivh7_j/migrations/base/tests/test_mock_crawl.py", line 432, in mock_act_window
    views = get_views(
   File "/home/odoo/src/odoo/19.0/addons/mail/models/mail_thread.py", line 471, in get_views
    res = super().get_views(views, options)
   File "/home/odoo/src/enterprise/19.0/web_studio/models/models.py", line 10, in get_views
    result = super().get_views(views, options=options)
   File "/home/odoo/src/enterprise/19.0/web_studio/models/ir_ui_view.py", line 52, in get_views
    return super().get_views(views, options)
   File "/home/odoo/src/odoo/19.0/odoo/addons/base/models/ir_ui_view.py", line 2946, in get_views
    result['models'][model] = {"fields": self.env[model].fields_get(
   File "/home/odoo/src/enterprise/19.0/web_studio/models/ir_model.py", line 76, in fields_get
    return super().fields_get(allfields, attributes=attributes)
   File "/home/odoo/src/enterprise/19.0/ai_fields/models/models.py", line 47, in fields_get
    res = super().fields_get(allfields, attributes)
   File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 3361, in fields_get
    description = field.get_description(self.env, attributes=attributes)
   File "/home/odoo/src/odoo/19.0/odoo/orm/fields.py", line 884, in get_description
    value = value(env)
   File "/home/odoo/src/odoo/19.0/odoo/orm/fields.py", line 937, in _description_groupable
    model._read_group_groupby(model._table, groupby, query)
   File "/home/odoo/src/odoo/19.0/addons/mail/models/mail_activity_mixin.py", line 257, in _read_group_groupby
    return super()._read_group_groupby(alias, groupby_spec, query)
   File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 2064, in _read_group_groupby
    coquery = comodel._search(codomain, bypass_access=field.bypass_search_access)
   File "/home/odoo/src/odoo/19.0/odoo/addons/base/models/ir_attachment.py", line 677, in _search
    records = self.sudo().with_context(active_test=False).search_fetch(
   File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 1418, in search_fetch
    return self._fetch_query(query, fields_to_fetch)
   File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 3917, in _fetch_query
    rows = self.env.execute_query(query.select(*sql_terms))
   File "/home/odoo/src/odoo/19.0/odoo/orm/environments.py", line 534, in execute_query
    self.cr.execute(query)
   File "/home/odoo/src/odoo/19.0/odoo/tests/test_cursor.py", line 79, in execute
    return self._cursor.execute(*args, **kwargs)
   File "/home/odoo/src/odoo/19.0/odoo/sql_db.py", line 433, in execute
    self._obj.execute(query, params)
 psycopg2.DatabaseError: out of memory for query result

upg-4179716
opw-6101425

@robodoo

robodoo commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Pull request status dashboard

@sagu-odoo
sagu-odoo force-pushed the master-fix-custom-field-manaul-sagu branch from 0f12608 to bd59ab3 Compare April 22, 2026 10:27
@sagu-odoo
sagu-odoo requested review from a team and Pirols April 22, 2026 11:03
@KangOl

KangOl commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

The MemoryError traceback looks unrelated and more like a side-effect.

@aj-fuentes

Copy link
Copy Markdown
Contributor

Besides what @KangOl mentioned I want to point out that the description in the PR is quite ambiguous. Please clarify what you meant. The query you modified mark all fields that weren't loaded as manual, this is important to avoid other errors. It doesn't make sense to disable this without a clear description of the setup such that we know if it is really safe to do so. Regarding the linked patch. If you need something to "get applied" maybe there are other ways to achieve that. Hence, once more, a detailed setup is important.

@sagu-odoo

sagu-odoo commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

The MemoryError traceback looks unrelated and more like a side-effect.

The issue related to computation being triggered on inherited fields, which caused blocking especially for non-stored fields Many2Many fields linked with ir.attachment.

The intention of the fix is to ensure that inherited fields are not marked as manual fields. Only fields created via the UI or explicitly through ir.model.fields should be considered manual.

There is no issue with stored field computation; the problem specifically occurs with inherited (non-stored) fields.

This has been addressed in the following PR, which resolves the blocking of upgrade requests for almost:

Related fixes to address the traceback but not for 19.0 version

@sagu-odoo

Copy link
Copy Markdown
Contributor Author

this isssue mostly limited to custom module fields only as of now.

@KangOl

KangOl commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

upgradeci retry with always only crm

@sagu-odoo

sagu-odoo commented Apr 24, 2026

Copy link
Copy Markdown
Contributor Author

for mentioned traceback, I think we can backport something like this fix not exact to 19.0 odoo/odoo#246333 . So, group by feature on ir.attachment will be disable because of this and this.

@sagu-odoo
sagu-odoo force-pushed the master-fix-custom-field-manaul-sagu branch from bd59ab3 to f678dce Compare April 27, 2026 13:22
@sagu-odoo
sagu-odoo force-pushed the master-fix-custom-field-manaul-sagu branch from f678dce to a4bc288 Compare May 6, 2026 11:02
@sagu-odoo

Copy link
Copy Markdown
Contributor Author

Hello @aj-fuentes and @KangOl , can i get your opinion on this ?.

Thanks in advance

@sagu-odoo

Copy link
Copy Markdown
Contributor Author

Hello @aj-fuentes and @KangOl ,Gentle reminder! can i get your opinion on this ?.

Thanks in advance

@sagu-odoo

Copy link
Copy Markdown
Contributor Author

Hllo @aj-fuentes , Gentle reminder!, can i get review on this ?.

Thanks in advance.

During the upgrade process, inherited fields were incorrectly
marked as `manual`, while they should retain their original
state (`base`).

Fields created via Studio are expected to have `state = manual`,
whereas inherited fields must remain `base` according to ORM
behavior [1]. Overriding this state leads to unintended side
effects.

In particular, marking inherited fields as `manual` triggers
unnecessary computations, especially for non-stored fields and
Many2many fields linked to `ir.attachment`. This can lead to
tracebacks and block upgrade requests

This change ensures that:
- inherited fields are not marked as `manual`
- only fields explicitly created via Studio or `ir.model.fields`
  are considered `manual`

This aligns the upgrade behavior with the ORM logic and prevents
unwanted computations on inherited fields.

[1]: https://github.com/odoo/odoo/blob/d58f4ed332af35f6de26a93f07adf05368731e20/odoo/orm/model_classes.py#L493-L508
```
('account.product_product_menu_sellable', 122, 'Accounting > Customers > Products', 254):
 Traceback (most recent call last):
   File "/tmp/tmpqgivh7_j/migrations/base/tests/test_mock_crawl.py", line 335, in crawl_menu
    self.mock_action(action_vals)
   File "/tmp/tmpqgivh7_j/migrations/base/tests/test_mock_crawl.py", line 348, in mock_action
    return self.mock_act_window(action)
   File "/tmp/tmpqgivh7_j/migrations/base/tests/test_mock_crawl.py", line 432, in mock_act_window
    views = get_views(
   File "/home/odoo/src/odoo/19.0/addons/mail/models/mail_thread.py", line 471, in get_views
    res = super().get_views(views, options)
   File "/home/odoo/src/enterprise/19.0/web_studio/models/models.py", line 10, in get_views
    result = super().get_views(views, options=options)
   File "/home/odoo/src/enterprise/19.0/web_studio/models/ir_ui_view.py", line 52, in get_views
    return super().get_views(views, options)
   File "/home/odoo/src/odoo/19.0/odoo/addons/base/models/ir_ui_view.py", line 2946, in get_views
    result['models'][model] = {"fields": self.env[model].fields_get(
   File "/home/odoo/src/enterprise/19.0/web_studio/models/ir_model.py", line 76, in fields_get
    return super().fields_get(allfields, attributes=attributes)
   File "/home/odoo/src/enterprise/19.0/ai_fields/models/models.py", line 47, in fields_get
    res = super().fields_get(allfields, attributes)
   File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 3361, in fields_get
    description = field.get_description(self.env, attributes=attributes)
   File "/home/odoo/src/odoo/19.0/odoo/orm/fields.py", line 884, in get_description
    value = value(env)
   File "/home/odoo/src/odoo/19.0/odoo/orm/fields.py", line 937, in _description_groupable
    model._read_group_groupby(model._table, groupby, query)
   File "/home/odoo/src/odoo/19.0/addons/mail/models/mail_activity_mixin.py", line 257, in _read_group_groupby
    return super()._read_group_groupby(alias, groupby_spec, query)
   File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 2064, in _read_group_groupby
    coquery = comodel._search(codomain, bypass_access=field.bypass_search_access)
   File "/home/odoo/src/odoo/19.0/odoo/addons/base/models/ir_attachment.py", line 677, in _search
    records = self.sudo().with_context(active_test=False).search_fetch(
   File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 1418, in search_fetch
    return self._fetch_query(query, fields_to_fetch)
   File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 3917, in _fetch_query
    rows = self.env.execute_query(query.select(*sql_terms))
   File "/home/odoo/src/odoo/19.0/odoo/orm/environments.py", line 534, in execute_query
    self.cr.execute(query)
   File "/home/odoo/src/odoo/19.0/odoo/tests/test_cursor.py", line 79, in execute
    return self._cursor.execute(*args, **kwargs)
   File "/home/odoo/src/odoo/19.0/odoo/sql_db.py", line 433, in execute
    self._obj.execute(query, params)
 psycopg2.DatabaseError: out of memory for query result
```

upg-4179716
opw-6101425
@sagu-odoo
sagu-odoo force-pushed the master-fix-custom-field-manaul-sagu branch from a4bc288 to cf89594 Compare July 15, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants