How to use the openupgradelib.openupgrade.get_legacy_name function in openupgradelib

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 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 / post-migration.py View on Github external
def res_company_sheet_range_map_values(env):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name("sheet_range"),
        "sheet_range",
        [(MONTHLY, "MONTHLY"), (WEEKLY, "WEEKLY"), (DAILY, "DAILY")],
        table="res_company",
    )
github ForgeFlow / stock-rma / rma / post_init_hook.py View on Github external
def assign_name(cr):
    cr.execute("""
        update rma_order set name = %s
    """ % openupgrade.get_legacy_name('number'))
    cr.execute("""
        update rma_order set reference = %s
    """ % openupgrade.get_legacy_name('code'))
github ForgeFlow / stock-rma / rma / post_init_hook.py View on Github external
""" % (openupgrade.get_legacy_name('move_in_id'))
    openupgrade.logged_query(cr, query)

    query = """
        update rma_order_line rml
        set delivery_policy = 'ordered'
        from rma_order ro
        where %s is not null
    """ % (openupgrade.get_legacy_name('move_out_id'))
    openupgrade.logged_query(cr, query)
    query = """
        update rma_order_line rml
        set delivery_policy = 'no'
        from rma_order ro
        where %s is null
    """ % (openupgrade.get_legacy_name('move_out_id'))
    openupgrade.logged_query(cr, query)
github ForgeFlow / stock-rma / rma / post_init_hook.py View on Github external
def map_crm_claim_warehouse_id(cr):
    query = """
        update rma_order_line rol
        set in_warehouse_id = ro.%s, out_warehouse_id = ro.%s
        from rma_order ro where ro.id = rol.%s
    """ % (openupgrade.get_legacy_name('warehouse_id'),
           openupgrade.get_legacy_name('warehouse_id'),
           openupgrade.get_legacy_name('claim_id'))
    openupgrade.logged_query(cr, query)
github ForgeFlow / stock-rma / rma / post_init_hook.py View on Github external
def link_moves(cr):
    query = """
        update stock_move stm
        set rma_line_id = rol.id
        from rma_order_line rol
        inner join rma_order on rol.%s = rma_order.id
        where rol.%s = stm.id
    """ % (openupgrade.get_legacy_name('claim_id'),
           openupgrade.get_legacy_name('move_out_id'))
    openupgrade.logged_query(cr, query)
    query = """
        update stock_move stm
        set rma_line_id = rol.id
        from rma_order_line rol
        inner join rma_order on rol.%s = rma_order.id
        where rol.%s = stm.id
    """ % (openupgrade.get_legacy_name('claim_id'),
           openupgrade.get_legacy_name('move_in_id'))
    openupgrade.logged_query(cr, query)
github ForgeFlow / stock-rma / rma / post_init_hook.py View on Github external
def set_policies(cr):
    query = """
        update rma_order_line rml
        set receipt_policy = 'ordered'
        from rma_order ro
        where %s is not null
    """ % (openupgrade.get_legacy_name('move_in_id'))
    openupgrade.logged_query(cr, query)
    query = """
        update rma_order_line rml
        set receipt_policy = 'no'
        from rma_order ro
        where %s is null
    """ % (openupgrade.get_legacy_name('move_in_id'))
    openupgrade.logged_query(cr, query)

    query = """
        update rma_order_line rml
        set delivery_policy = 'ordered'
        from rma_order ro
        where %s is not null
    """ % (openupgrade.get_legacy_name('move_out_id'))
    openupgrade.logged_query(cr, query)