OCA / openupgradelib

A library with support functions to be called from Odoo migration scripts.
GNU Affero General Public License v3.0
85 stars 171 forks source link

[IMP] rename_fields: Be able to use a cursor instead of Environment #355

Open rousseldenis opened 9 months ago

rousseldenis commented 9 months ago

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

OCA-git-bot commented 5 months ago

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). 🤖

MiquelRForgeFlow commented 5 months ago

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 commented 5 months ago

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