Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def rename_config_parameters(cr, keys_spec):
for (old, new) in keys_spec:
query = ("UPDATE ir_config_parameter SET key = %s "
"WHERE key = %s")
openupgrade.logged_query(cr, query, (new, old))
def set_type(cr):
query = """
update rma_order
set type = 'customer'
where %s = 1
""" % (openupgrade.get_legacy_name('claim_type'))
openupgrade.logged_query(cr, query)
query = """
update rma_order
set type = 'supplier'
where %s = 2
""" % (openupgrade.get_legacy_name('claim_type'))
openupgrade.logged_query(cr, query)
query = """
update rma_order_line rml set type = ro.type
from rma_order ro
where ro.id = rml.rma_id
"""
openupgrade.logged_query(cr, query)
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)
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)
update rma_order_line rml
set refund_policy = 'ordered'
from rma_order ro
where refund_line_id is not null
and rml.%s = ro.id
""" % (openupgrade.get_legacy_name('claim_id'))
openupgrade.logged_query(cr, query)
query = """
update rma_order_line rml
set refund_policy = 'no'
from rma_order ro
where refund_line_id is null
and rml.%s = ro.id
""" % (openupgrade.get_legacy_name('claim_id'))
openupgrade.logged_query(cr, query)
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)
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)
def migrate(cr, version):
openupgrade.logged_query(cr, """
DELETE FROM ir_ui_view where model = 'db.configuration'
def migrate(env, version):
openupgrade.logged_query(
env.cr,
"""
UPDATE res_company
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)