Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] core: allow skipping field recomputitation on installation #99571

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yelizariev
Copy link
Contributor

When a module adds new computated field, it may take significant time to make
initial computation. Before this commit, the only way to avoid this was using
_auto_init. Example:

if not column_exists(self.env.cr, "account_move", "l10n_latam_document_type_id"):
create_column(self.env.cr, "account_move", "l10n_latam_document_type_id", "int4")
return super()._auto_init()

https://github.com/odoo/enterprise/blob/46812d9abb3eb6e2b5ac565b4817548317c4a354/l10n_mx_edi_extended/models/account_move.py#L79-L82

But such method requires creating columns manually.

This commit allows using _init_column method instead by adding return value
initialized

Also, make some cleanup in odoo/fields.py and move code
"optimization for computing simple related fields like 'foo_id.bar'" to new method initialize

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

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

@robodoo
Copy link
Contributor

robodoo commented Sep 5, 2022

Pull request status dashboard

@C3POdoo C3POdoo requested a review from a team September 5, 2022 12:56
@yelizariev yelizariev force-pushed the master-skip-recomputation-on-installation-IEL branch from e006591 to f969ccf Compare September 5, 2022 12:56
@C3POdoo C3POdoo added the RD research & development, internal work label Sep 5, 2022
@yelizariev yelizariev force-pushed the master-skip-recomputation-on-installation-IEL branch 5 times, most recently from e14bed9 to 0ade5e4 Compare September 6, 2022 13:04
@yelizariev

This comment was marked as outdated.

@yelizariev yelizariev force-pushed the master-skip-recomputation-on-installation-IEL branch 2 times, most recently from 4589877 to 6c930a6 Compare February 16, 2023 14:27
@C3POdoo C3POdoo requested review from a team February 16, 2023 14:29
@yelizariev yelizariev force-pushed the master-skip-recomputation-on-installation-IEL branch 2 times, most recently from cdfcddd to d355674 Compare February 17, 2023 11:58
@C3POdoo C3POdoo requested review from a team and jbw-odoo and removed request for a team February 17, 2023 11:59
@yelizariev yelizariev force-pushed the master-skip-recomputation-on-installation-IEL branch 2 times, most recently from ee58a9c to 69b66da Compare February 17, 2023 13:30
@yelizariev
Copy link
Contributor Author

Previously discussed in #69132

@yelizariev
Copy link
Contributor Author

@rco-odoo
This PR introduces a safer way to skip column initialization: developer doesn't need to use low level functions column_exists, create_column. You previously reviewed the update in #69132 (I made a new PR to make a proper branch name master-...). This PR also applies the new API to existing code.

image

@yelizariev yelizariev force-pushed the master-skip-recomputation-on-installation-IEL branch from 69b66da to d35784a Compare February 20, 2023 09:22
@C3POdoo C3POdoo requested a review from a team February 20, 2023 09:24
@yelizariev yelizariev force-pushed the master-skip-recomputation-on-installation-IEL branch from d35784a to efa01ac Compare April 17, 2023 12:28
@yelizariev yelizariev force-pushed the master-skip-recomputation-on-installation-IEL branch from efa01ac to e71e31a Compare April 27, 2023 08:21
When a module adds new computated field, it may take significant time to make
initial computation. Before this commit, the only way to avoid this was using
`_auto_init`. Example:

https://github.com/odoo/odoo/blob/ca0d8978b6585fe4f96100df56b8a7346468dc6c/addons/l10n_latam_invoice_document/models/account_move.py#L42-L44

https://github.com/odoo/enterprise/blob/46812d9abb3eb6e2b5ac565b4817548317c4a354/l10n_mx_edi_extended/models/account_move.py#L79-L82

But such method requires creating columns manually.

This commit allows using `_init_column` method instead by adding return value
``initialized``

Also, make some cleanup in odoo/fields.py and move code
"optimization for computing simple related fields like 'foo_id.bar'" to new method `initialize`

Also, some fields don't need neither `_init_column` nor `_auto_init` if they
are simple related fields
@yelizariev yelizariev force-pushed the master-skip-recomputation-on-installation-IEL branch from e71e31a to f55d6e0 Compare April 28, 2023 08:55
@yelizariev
Copy link
Contributor Author

@rco-odoo

@seb-odoo seb-odoo removed the request for review from a team July 6, 2023 18:14
@jbw-odoo jbw-odoo removed their request for review February 27, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants