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] rename_models: rename the models in the reference fields #175

Merged
merged 1 commit into from
Mar 11, 2022

Conversation

MiquelRForgeFlow
Copy link
Contributor

This new method renames the models in the reference fields.

Also fixes _change_reference_refs_sql method.

@pedrobaeza
Copy link
Member

Why an extra method instead of being part of existing rename_models? All should be done in the same method IMO.

@pedrobaeza
Copy link
Member

Please put the other fix in a separate PR

@MiquelRForgeFlow
Copy link
Contributor Author

Why an extra method instead of being part of existing rename_models?

Because the need of the env. rename_models doesn't use env but the new method needs it.

Maybe we can expand rename_models signature like:

def rename_models(cr, model_spec, env=False):

what do you think?

@pedrobaeza
Copy link
Member

But I think we can avoid the use of the env. Let's search directly on ir_model_fields table possible fields of ttype='reference', and then perform the SQL with the change.

@MiquelRForgeFlow
Copy link
Contributor Author

But how I obtain the table?

@pedrobaeza
Copy link
Member

Yeah, good point... Now you know why I always want to pass env although no initial use. I don't like too much the option of adding that extra "optional" argument. Or at least not only. It's better to build a new environment for cr (we can do it the same as we do on migrate decorator) if not provided via that argument.

@MiquelRForgeFlow MiquelRForgeFlow force-pushed the master-add-rename_models_reference branch from 6355f67 to 5fccd32 Compare September 19, 2019 15:33
@MiquelRForgeFlow
Copy link
Contributor Author

MiquelRForgeFlow commented Sep 19, 2019

I think this method should remain separated and not merged into the rename_models method.
Reason: rename_models is called in pre-migration and covers all cases without using the env. Instead, rename_models_reference should be called in end-migration, because it's only in end-migration when all models are in the env, and thus, only in end-migration will you obtain any model table, by the same way that merge_records usually is called in end-migration.

@MiquelRForgeFlow MiquelRForgeFlow force-pushed the master-add-rename_models_reference branch from 5fccd32 to 60b4f15 Compare March 18, 2021 14:20
@MiquelRForgeFlow
Copy link
Contributor Author

I have updated the PR. Now the rename_models method make use of it. And also it can be called independently in the end-migration with the environment.

@MiquelRForgeFlow MiquelRForgeFlow force-pushed the master-add-rename_models_reference branch from 60b4f15 to 5d91ffe Compare March 18, 2021 15:19
@MiquelRForgeFlow MiquelRForgeFlow force-pushed the master-add-rename_models_reference branch from 5d91ffe to 88fd38a Compare March 9, 2022 15:53
@MiquelRForgeFlow
Copy link
Contributor Author

instead of being part of existing rename_models? All should be done in the same method IMO.

Now it's handled this way. Very simple.

@MiquelRForgeFlow MiquelRForgeFlow changed the title [ADD] rename_models_reference [IMP] rename_models: rename the models in the reference fields Mar 9, 2022
@MiquelRForgeFlow MiquelRForgeFlow requested review from pedrobaeza and removed request for StefanRijnhart and pedrobaeza March 9, 2022 15:55
@pedrobaeza pedrobaeza merged commit 7284922 into OCA:master Mar 11, 2022
@MiquelRForgeFlow MiquelRForgeFlow deleted the master-add-rename_models_reference branch March 11, 2022 12:59
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.

3 participants