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

[9.0][OU-FIX] #2339, purge obsolete models and fields #2535

Merged
merged 1 commit into from Apr 8, 2021

Conversation

StefanRijnhart
Copy link
Member

@StefanRijnhart StefanRijnhart commented Feb 7, 2021

Fixes #2339

  • add loaded models and fields to the set of loaded XMLIDs
  • purge models and fields with noupdate NULL instead of FALSE

Also

  • consult model's _fields instead of _columns when updating field XMLIDs
    as it is more complete
  • remove coverage as it is giving out red marks to PRs for no reason
  • check reference count before deleting a record after module upgrade
  • improve logging when deletion fails (should be rare now)
  • pass context to unlink to effectuate the module uninstall flag
  • reduce logging of deletions in CI
  • remove model relations, constraints and fields from ir.model's unlink
    to prevent IntegrityErrors
  • only apply integrity check to manual fields

This PR is part of a set of PRs for OpenUpgrade 9.0 up to 13.0. Background:

While Odoo deletes obsolete field and model entries from the data model
metadata explicitely in their migration scripts, in OpenUpgrade I have
always meant to rely on the mechanism of purging 'untouched' XMLIDs that
takes care of the deletion of obsolete data records (e.g. views).

However, this mechanism was not applied to field and model entries because
their XMLIDs were created with noupdate NULL instead of FALSE and as such
excluded in the query to gather all obsolete data records.

Also missing was marking the XMLIDs of fields and models as loaded in the
first place.

All of this is working properly in Odoo 13 (introduced gradually across new
releases) so all of this is backported from newer versions one way or
another.

@StefanRijnhart StefanRijnhart changed the title [TST] Also delete obsolete records with noupdate set to NULL [9.0][TST] Also delete obsolete records with noupdate set to NULL Feb 7, 2021
@StefanRijnhart StefanRijnhart added this to the 9.0 milestone Feb 7, 2021
@StefanRijnhart StefanRijnhart force-pushed the fix/9.0/noupdate_set_false_where_null branch 9 times, most recently from ca7f3a7 to 50fa2e0 Compare February 8, 2021 21:18
@StefanRijnhart StefanRijnhart force-pushed the fix/9.0/noupdate_set_false_where_null branch 11 times, most recently from 5424513 to 0ab7097 Compare February 16, 2021 15:11
@StefanRijnhart StefanRijnhart changed the title [9.0][TST] Also delete obsolete records with noupdate set to NULL [9.0][FIX] Remove obsolete ir.model.fields and ir.model entries Feb 16, 2021
Fixes OCA#2339

* add loaded models and fields to the set of loaded XMLIDs
* purge models and fields with noupdate NULL instead of FALSE

Also

* consult model's _fields instead of _columns when updating field XMLIDs
as it is more complete
* remove coverage as it is giving out red marks to PRs for no reason
* check reference count before deleting a record after module upgrade
* improve logging when deletion fails (should be rare now)
* pass context to `unlink` to effectuate the module uninstall flag
* reduce logging of deletions in CI
* remove model relations, constraints and fields from ir.model's unlink
to prevent IntegrityErrors
* only apply integrity check to manual fields

This PR is part of a set of PRs for OpenUpgrade 9.0 up to 13.0. Background:

While Odoo deletes obsolete field and model entries from the data model
metadata explicitely in their migration scripts, in OpenUpgrade I have
always meant to rely on the mechanism of purging 'untouched' XMLIDs that
takes care of the deletion of obsolete data records (e.g. views).

However, this mechanism was not applied to field and model entries because
their XMLIDs were created with noupdate NULL instead of FALSE and as such
excluded in the query to gather all obsolete data records.

Also missing was marking the XMLIDs of fields and models as loaded in the
first place.

All of this is working properly in Odoo 13 (introduced gradually across new
releases) so all of this is backported from newer versions one way or
another.
@StefanRijnhart StefanRijnhart force-pushed the fix/9.0/noupdate_set_false_where_null branch from 0ab7097 to 5afbbb6 Compare February 26, 2021 13:56
@StefanRijnhart StefanRijnhart changed the title [9.0][FIX] Remove obsolete ir.model.fields and ir.model entries [9.0][OU-FIX] #2339, purge obsolete models and fields Feb 26, 2021
@StefanRijnhart StefanRijnhart marked this pull request as ready for review February 26, 2021 13:58
@pedrobaeza pedrobaeza merged commit 43ea3da into OCA:9.0 Apr 8, 2021
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.

None yet

2 participants