Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))
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 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",
)
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'))
""" % (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)
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)
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 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)