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_fields: Be able to use a cursor instead of Environment #355

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rousseldenis
Copy link
Contributor

In some cases, we want to use the rename_fields() method without using a full environment but with a cursor instead.

In some cases, we want to use the rename_fields() method without using a full environment
but with a cursor instead.
@sbidoul sbidoul force-pushed the imp-rename_fields_env_cr-dro branch 2 times, most recently from af6503b to 4ff74cb Compare November 24, 2023 08:31
@MiquelRForgeFlow MiquelRForgeFlow self-requested a review April 5, 2024 08:55
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

deep=False parameter is already for not doing stuff with ORM if not available, but you can get any environment even in base pre-migration, or fake it with a class containing the property cr.

@rousseldenis why do you want to do this?

IMO it's to complicate the number of methods without reason.

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

By the stated above

@MiquelRForgeFlow
Copy link
Contributor

MiquelRForgeFlow commented Apr 5, 2024

Seeing @pedrobaeza comment, what do you think of doing this instead this?

def rename_fields(env_or_cr, field_spec, no_deep=False):
    if not no_deep:
        env = env_or_cr
        cr = env.cr
    else:
        cr = env_or_cr
    (...code using cr here...)
    if not no_deep:
        (...code using env here...)

maybe we could rename no_deep to no_env or is_cr... @pedrobaeza what do you think?

@pedrobaeza
Copy link
Member

OK about the renaming. It has this name for also not doing all the stuff we have in #319

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.

6 participants