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

[ADD] update_module_moved_models #281

Merged

Conversation

MiquelRForgeFlow
Copy link
Contributor

Avoid cases like:
Selection_244

@pedrobaeza
Copy link
Member

This should be done in update_module_moved_fields

def update_module_moved_fields(
, but as we avoid such method, it should be part of the framework, as the other part (XML-ID and so) is already handled there.

@MiquelRForgeFlow
Copy link
Contributor Author

MiquelRForgeFlow commented Mar 2, 2022

This should be done in update_module_moved_fields

Not exactly, because that method is used only for fields, not models. One could do a new one, like in #249, but I thought it's easier to just reuse rename_models

it should be part of the framework

The odoo framework doesn't do renames per se. It only deletes "wrong data" and creates new data. Obviously, it will not delete translations that have wrong module after a model rename. About OU framework, I don't know if it can be readapted, but I don't want to consume more time to check it.

@pedrobaeza
Copy link
Member

I think then it should be a different method, as you can have a module rename, but not a model rename.

@MiquelRForgeFlow MiquelRForgeFlow force-pushed the master-add-rename_models-module_rename branch 2 times, most recently from f288ad4 to 0013ccc Compare March 2, 2022 13:01
@MiquelRForgeFlow
Copy link
Contributor Author

@pedrobaeza Ready

@MiquelRForgeFlow
Copy link
Contributor Author

@kaerdsar FYI

)
underscore = "_" if version_info[0] < 12 else "__"
logged_query(
cr, """UPDATE ir_model_data imd
Copy link
Member

Choose a reason for hiding this comment

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

This is handled by framework, so I don't think this should be done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The OU framework only is used in migrations. But if you are not in OU, but in production, and do an update of two modules that contains a refactor between them, and you want to use this method, then what? Let's be sure this method handle everything neatly just in case (it will be used in very few places) independently of the OU framework.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not talking about OU framework, but ORM framework. It's handled automatically since 12.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But ORM framework doesn't do data updates, only deletes wrong data and creates new data for the non-existing ones. Yeah, we could let ORM do this, but it's ugly. I prefer update the data by query and avoid the later ORM process of delete + create.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What if the affected model has noupdate records? then the ORM won't update them!

Copy link
Member

Choose a reason for hiding this comment

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

Is that a real case?

Copy link

@sebalix sebalix Apr 7, 2022

Choose a reason for hiding this comment

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

We faced it lately (mail templates in noupdate + translations done directly in the DB), having such method to move all of this from one addon to another would have saved us time for sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

On some projects we used a small helper that is similar to this this one.
We did not had the time to add it to openupgradelib.

@MiquelRForgeFlow MiquelRForgeFlow force-pushed the master-add-rename_models-module_rename branch from 0013ccc to a22c92b Compare March 2, 2022 14:48
@MiquelRForgeFlow MiquelRForgeFlow changed the title [IMP] rename_models: consider module rename case [ADD] update_module_moved_models Mar 9, 2022
Copy link

@sebalix sebalix left a comment

Choose a reason for hiding this comment

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

I find it useful

@pedrobaeza pedrobaeza merged commit 1f942fd into OCA:master May 18, 2022
@MiquelRForgeFlow MiquelRForgeFlow deleted the master-add-rename_models-module_rename branch May 18, 2022 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants