[13.0] [MIG] database_cleanup - #1885
Conversation
|
This is strange - Travis CI fails for some reason. This does not happen in my environment, did also clean instance. @hbrunn could you please have a look? Is it me or Travis? |
|
Hi @Rad0van I was attempting to migrate on #1823 Did you check the improvements there? For me it is ok to continue the PR here as long you include the improve commented by @i-vyshnevska and 76f57df and 5758932 and 4a45ade BTW, for reviewing it is best to create a separate commit for the black, isort changes. |
@AaronHForgeFlow stupid me - forgot to check if anyboy else is working on this. My fault. Didn't see the one you did. But I see it is failing the same way my does :-) Does 4a45ade fix it? Regarding black and isort changes - I follow the migration guide so I ususally do that. Must have forgotten this time. So I see 2 options here - please advise which to choose:
What is your preferred option? |
|
Currently I don't have time to finish my PR so option 2 it's fine to me :) |
|
OK, I will rework this one. Better in new PR. So closing this one. |
|
@AaronHForgeFlow tried reworking int. Some patches were already present because I migrateda later. However the Travis still fails. Patch [4a45ade] didn't solve it - it still fails the same way it did for you. Do you have any idea as why that happens? |
|
It seems it is a CacheMiss Error. I have seen similar errors before but I really don't know how to solve this. Perhaps @hbrunn or @StefanRijnhart can help us here. |
Oh I thought you solved it somehow. Ok, will try to investigate more. |
I think you can fix this by removing the related ir.model.data record. |
@CasVissers-360ERP could you please be more specific? What do you mean I remove that record? The thing is this error only happens in Travis. When I run tests on new clean instance of database in my local environment it doesn't happen. The second line from top in stacktrace is call to this: |
|
I tested https://github.com/Rad0van/server-tools/tree/13.0-mig-database_cleanup/database_cleanup on my side (oca modules and some store modules installed) and i have to say that works like a charm, and didnt noticed any issue, i wil do more test on other enviroments and let you know. |
|
Hi, I was going to migrate this module, but I've seen 3 failed attempts (PR) already, 2 of them (including this one) being stuck on Travis with no specific reason. Is it an issue on Travis? cc: @moylop260 @StefanRijnhart |
|
About the Travis error: this module test code is by necessity a bit tricky, performing actual commits on the database. In this case https://github.com/OCA/server-tools/pull/1885/files#diff-bcf55f79eb1510415055d7ad3c2e195e24a777c4a95b48a6701cba91f6776d74R172 it does so to delete the dummy module that is created in the test. SQL mutations are often the cause of MissingErrors as they cause consistencies between the SQL data and the Odoo cache. That makes me think that maybe this issue is solved by calling the super's TearDown after the query, as the super clears the cache. |
|
@gustavovalverde Please go ahead porting this one to 14. Maybe you are able to fix the caching issue in your PR, and then the fix can be backported to this PR. |
Stefan, it seems to work! |
45d1871 to
2dc7753
Compare
|
Great to hear! About the code, it seems that you did not commit the prehook changes in a separate commit. Would it be alright for you to try and forge that in? See https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-13.0. The way that formatting and actual changes are combined in a single commit makes it a little hard to review. |
| for field in self.mapped("field_id"): | ||
| model = self.env[field.model] | ||
| name = '%s_%s_index' % (model._table, field.name) | ||
| name = "{}_{}_index".format(model._table, field.name) |
There was a problem hiding this comment.
Please don't replace string substitution by format. See https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#33idioms
There was a problem hiding this comment.
Was it actually pre-commit that did this?
There was a problem hiding this comment.
Was it actually pre-commit that did this?
I guess so. I didn't do that knowingly.
There was a problem hiding this comment.
I see it's pyupgrade from our pre-commit that does that, but only when it's safe so it's alright. I'm asking the lint-masters about it here: OCA/pylint-odoo#302 (comment)
I am always trying to follow that. Oh I see now. How can I "forge that in"? Not a clue on this. |
2dc7753 to
2680094
Compare
avoid ''NoneType' object has no attribute 'exists'' error when purging models fix my change guewen.baconnier@camptocamp.com-20140203103254-v1mzu2uib047xb9h, wrong lines replaced...
raw SQL query (but never read afterwards). Workaround for
lp:1277899
[FIX] Preserve dangling workflow table which is in use
[RFR] Group models per table when detecting columns to purge
to prevent problems with models sharing the same table
[ADD] Allow purging of dangling data entries
[FIX] Data purging now working
[IMP] Docstrings
[FIX] Label
[FIX] Catch attempt to unlink field from nonexisting model
[RFR] Flake8
[CHG] database_cleanup: move description to README.rst
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: server-tools-12.0/server-tools-12.0-database_cleanup Translate-URL: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-database_cleanup/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: server-tools-12.0/server-tools-12.0-database_cleanup Translate-URL: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-database_cleanup/
2680094 to
3c4b4e9
Compare
|
OK, should be done. Messy way. But done :-) |
| ) | ||
| tables.add(model._table) | ||
| for table in tables: | ||
| for _table in tables: |
There was a problem hiding this comment.
Guessing you added the underscore because the variable is not changed? I'm thinking that is a bug and the table variable should be passed instead of model._table in the line below. Can you confirm @hbrunn?
As always, you can blame it on the reviewers (#736)
Well to tell the truth I do not remember. But I guess the reason was the following line which reads:
self.env.cr.execute("analyze %s", (IdentifierAdapter(model._table),))
So without that change the table variable was never used.
There was a problem hiding this comment.
Indeed, but the point is that _table is still not used, but model._table is used instead.
There was a problem hiding this comment.
Oops, you're right. Now that's strange as original code did the same AFAICT. So this probably needs more investigation to get it right.
There was a problem hiding this comment.
Yes, it was there from the original PR on. But logically, it only makes sense to use table there instead of model._table.
There was a problem hiding this comment.
Yes, it was there from the original PR on. But logically, it only makes sense to use
tablethere instead ofmodel._table.
Sure, will do.
| "DELETE FROM ir_model WHERE id in %s", (tuple(self.models.ids),) | ||
| ) | ||
| cr2.commit() | ||
| super(TestDatabaseCleanup, self).tearDown() |
There was a problem hiding this comment.
Trivial, but scoping the call to super under the cursor contextmanager makes less sense. Just unindent.
There was a problem hiding this comment.
Trivial, but scoping the call to super under the cursor contextmanager makes less sense. Just unindent.
Stupid me. Will do.
bealdav
left a comment
There was a problem hiding this comment.
Other super call to check.
Thanks
| continue | ||
| if this.model not in self.env: | ||
| this.unlink() | ||
| return super(IrModelData, self)._module_data_uninstall(modules_to_remove) |
There was a problem hiding this comment.
| return super(IrModelData, self)._module_data_uninstall(modules_to_remove) | |
| return super()._module_data_uninstall(modules_to_remove) |
9b0a300 to
04456f4
Compare
|
This PR has the |
StefanRijnhart
left a comment
There was a problem hiding this comment.
Thanks for the updates! (on the side: you responded to my comments with 'will do' but it's more helpful to comment after you have applied the requested changes so that the reviewer knows that the PR is ready for re-review)
|
/ocabot merge nobump |
|
This PR looks fantastic, let's merge it! |
|
Congratulations, your PR was merged at 0520ea7. Thanks a lot for contributing to OCA. ❤️ |
Standard migration. Added
_descriptionto few classes to get rig of WARNING messages (not present in 12.0). Also changed broken translation in en.po that translated "Purge obsolete properties" as "Purge obsolete models".