How to use openupgradelib - 10 common examples

To help you get started, we’ve selected a few openupgradelib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ForgeFlow / stock-rma / rma / post_init_hook.py View on Github external
def assign_origin(env):
    env.cr.execute("""
        select rol.id, ro.%s, rol.product_id, rol.product_qty
        from rma_order_line rol
        inner join rma_order ro on ro.id = rol.%s
    """ % (openupgrade.get_legacy_name('ref'),
           openupgrade.get_legacy_name('claim_id')))
    for rml_id, origin, product_id, product_qty in env.cr.fetchall():
        if origin and product_qty and product_id:
            table = origin.split(",")[0]
            obj_id = origin.split(",")[1]
            if table == 'account.invoice':
                env.cr.execute(
                    """
                    select ail.id
                    from  account_invoice_line ail
                    inner join account_invoice ai on ai.id = ail.invoice_id
                    where ai.id = %s
                    and ail.product_id = %s
                    and ail.quantity = %s
                    limit 1
                    """ % (obj_id, product_id, product_qty))
github eneldoserrata / marcos_community_addons / aa_modules_backup / account_invoice_currency / migrations / 9.0.1.0.0 / pre-migrate.py View on Github external
def migrate(cr, version):
    openupgrade.rename_columns(cr, column_renames)
    openupgrade.copy_columns(cr, column_copies)
github eneldoserrata / marcos_community_addons / aa_modules_backup / account_invoice_currency / migrations / 9.0.1.0.0 / pre-migrate.py View on Github external
def migrate(cr, version):
    openupgrade.rename_columns(cr, column_renames)
    openupgrade.copy_columns(cr, column_copies)
github ForgeFlow / stock-rma / rma / pre_init_hook.py View on Github external
def pre_init_hook(cr):
    env = Environment(cr, SUPERUSER_ID, {})
    if not openupgrade.table_exists(env.cr, 'rma_order'):
        openupgrade.copy_columns(env.cr, column_copies)
        openupgrade.rename_columns(env.cr, column_renames)
        openupgrade.rename_tables(env.cr, _table_renames)
        assign_status(env.cr)
        set_default_values(env.cr)
github ForgeFlow / stock-rma / rma_account / migrations / 9.0.1.0.0 / post-migration.py View on Github external
def link_refunds(cr):
    query = """
    update account_invoice_line ail set rma_line_id = null;
    """
    openupgrade.logged_query(cr, query)
    query = """
        update account_invoice_line ail
        set rma_line_id = rol.id
        from rma_order ro
        inner join rma_order_line rol on rol.rma_id = ro.id
        where rol.%s = ro.id
        and rol.%s = ail.id
    """ % (openupgrade.get_legacy_name('claim_id'),
           openupgrade.get_legacy_name('refund_line_id'))
    openupgrade.logged_query(cr, query)
github OCA / timesheet / hr_timesheet_sheet / migrations / 13.0.1.0.0 / pre-migration.py View on Github external
@openupgrade.migrate()
def migrate(env, version):
    openupgrade.rename_columns(env.cr, column_renames)
github shopinvader / odoo-shopinvader / shopinvader / migrations / 10.0.2.0.0 / pre-migrate.py View on Github external
def migrate(cr, version):
    """Update database from previous versions, after updating module."""
    openupgrade.rename_tables(
        cr=cr, table_spec=[("locomotive_backend", "shopinvader_backend")]
    )
    openupgrade.rename_models(
        cr=cr, model_spec=[("locomotive.backend", "shopinvader.backend")]
    )
    # remove blocking view
    cr.execute(
        """DELETE FROM ir_ui_view
        WHERE arch_db ilike '%locomotive_backend_ids%'"""
github ForgeFlow / stock-rma / rma / pre_init_hook.py View on Github external
def pre_init_hook(cr):
    env = Environment(cr, SUPERUSER_ID, {})
    if not openupgrade.table_exists(env.cr, 'rma_order'):
        openupgrade.copy_columns(env.cr, column_copies)
        openupgrade.rename_columns(env.cr, column_renames)
        openupgrade.rename_tables(env.cr, _table_renames)
        assign_status(env.cr)
        set_default_values(env.cr)
github ingadhoc / odoo-public-administration / public_budget / migrations / 9.0.1.33.0 / post-migration.py View on Github external
@openupgrade.migrate(use_env=True)
def migrate(env, version):
    """ Completamos fecha a nuevo campo:
    * tomando de payment_date si está seteado
    * tomando de confirmation_date si ya se paso a proceso de firma pero no
    tenemos payment_date
    """
    cr = env.cr

    cr.execute("""
        UPDATE account_payment_group set to_signature_date=payment_date
        WHERE payment_date is not null
    """)

    cr.execute("""
        UPDATE account_payment_group set to_signature_date=confirmation_date