Skip to content

Conversation

jjmaksoud
Copy link
Contributor

The use of IrModelFields method is_manual_name was reverted for the sake of efficiency and avoiding instanciating models when not really needed.
The use of an overridable method is still needed (reference).
Here is a fix using a simple function that can still be patched.


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented Aug 27, 2025

Pull request status dashboard

@C3POdoo C3POdoo requested review from a team, kmagusiak and ryv-odoo and removed request for a team August 27, 2025 16:17
jjmaksoud added a commit to odoo-dev/upgrade-util that referenced this pull request Aug 27, 2025
The check for manual field names moved from being
a model method to a util function. It needs to be
patched starting version saas~18.4 to allow loading
custom module fields as manual for tests during the
upgrade process.

odoo/odoo#224524
odoo/enterprise#93335
jjmaksoud added a commit to odoo-dev/upgrade-util that referenced this pull request Aug 27, 2025
The check for manual field names moved from being
a model method to a util function. It needs to be
patched starting version saas~18.4 to allow loading
custom module fields as manual for tests during the
upgrade process.

odoo/odoo#224524
odoo/enterprise#93335
@kmagusiak kmagusiak requested review from rco-odoo and removed request for kmagusiak August 27, 2025 20:18
@kmagusiak
Copy link
Contributor

Please check with @rco-odoo.
I don't see a reason to have this other than "some customers might want to" - which does not explain why.
The function must have a docstring explaining why this function is needed, otherwise it might be dropped again on the future.

The use of IrModelFields method is_manual_name was reverted
for the sake of efficiency and avoiding instanciating models
when not really needed.
The use of an overridable method is still needed.
Here is a fix using a simple function that can still be
patched.
@jjmaksoud jjmaksoud force-pushed the saas-18.4-manual-fields-maji branch from a61a63e to 00dd16e Compare August 28, 2025 08:24
@jjmaksoud
Copy link
Contributor Author

@kmagusiak The override is also needed internally in the context of upgrades for all databases that have custom modules. Some of the integrity checks that are done during migration validate that views are still accessible, and those views may include fields that are not loaded, so the upgrade tries to load them as manual fields just for those checks. The patch needed in upgrade after this is resolved: odoo/upgrade-util#309

jjmaksoud added a commit to odoo-dev/upgrade-util that referenced this pull request Aug 29, 2025
The check for manual field names moved from being
a model method to a util function. It needs to be
patched starting version saas~18.4 to allow loading
custom module fields as manual for tests during the
upgrade process.

odoo/odoo#224524
odoo/enterprise#93335
@jjmaksoud
Copy link
Contributor Author

@Xavier-Do @beledouxdenis This didnt make the freeze but it is still needed for upgrades

for model in [model_cls] + [model_cls.pool[inherit] for inherit in model_cls._inherits]
)
if not (is_class_field or name.startswith('x_')):
if not (is_class_field or is_manual_field_name(name)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I follow correctly what @Xavier-Do is trying to achieve in his pull request #212579, he just want to use the registry rather than records in a maximum of places.

When he did this

-    if not (is_class_field or model.env['ir.model.fields']._is_manual_name(name)):
+    if not (is_class_field or name.startswith('x_')):

I believe the main issue was the use of model.env['ir.model.fields'], but using model.env.registry['ir.model.fields']._is_manual_name whould be fine I believe.

So I believe you could simplify your pull request with simply

Suggested change
if not (is_class_field or is_manual_field_name(name)):
if not (is_class_field or model.env.registry['ir.model.fields']._is_manual_name(name)):

and no need of this additional fields.is_manual_field_name.

However I would still ask Xavier guidance to make sure this is still ok to reach its performance goal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main goal was to speedup the setup as much as possible.
One of the slow point was to get model class in the registry and to instantiate it as a model.
The second part was partially an issue but not only, the getitem was visible and a part of the change was to avoid to call it on each field, but rather once per model when possible.

For this particular change, since no override were found in the code and the change was in master we decided to remove the method completely to cleanup a little. No necessary additional method call, easier to read, ... after a discussion with rco we decided to remove it, we didn't notice that it was patched in the upgrades.

Since the upgrade part just patch the method, it doesn't need to be a class method so I suggested to make a function, patchable but easier for me to assume that no performance regression will be introduced. If you think that a class method is better I can start a profiler on the branch to check if the change invisible or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO the is_manual_field_name could be defined immediately in the model_classes file, no need to import it it is only used there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use model_cls.pool['ir.model.fields']._is_manual_name I would still need to edit _is_manual_name signature to remove the self, which I think is not okay in stable

IMHO the is_manual_field_name could be defined immediately in the model_classes file, no need to import it it is only used there.

It is also used in base/ir_model which is modified in this PR as well

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.

5 participants