Commit 404a071
committed
[FIX] util/orm: don't mark inherited field manual for custom
During the upgrade process, inherited fields were incorrectly
marked as `manual`, whereas they should
retain their original `base` state.
like Fields created through Studio or `ir.model.fields` are
expected to have `state = manual`, while
inherited fields are set up by the ORM with
`state = base` [1].
Marking inherited fields as `manual` makes the ORM treat them
as independently created fields, which can trigger unnecessary
computations, e.g for non-stored fields and
`Many2many` fields related to `ir.attachment`.
This change ensures that:
* inherited fields retain `state = base`
* only fields explicitly
`ir.model.fields` are marked as `manual` or custom
module field should mark as `manual`
* field setup remains consistent with the ORM behavior
This prevents inherited fields from being treated as independent
fields and avoids unwanted computations during mock crawl.
[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-61014251 parent 3c8babe commit 404a071
1 file changed
Lines changed: 40 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
663 | 665 | | |
664 | 666 | | |
665 | 667 | | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
666 | 704 | | |
667 | 705 | | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
| 706 | + | |
679 | 707 | | |
680 | 708 | | |
681 | 709 | | |
682 | 710 | | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
| 711 | + | |
694 | 712 | | |
695 | 713 | | |
696 | 714 | | |
| |||
0 commit comments