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 migrate(cr, version):
openupgrade.rename_columns(cr, column_renames)
openupgrade.copy_columns(cr, column_copies)
def migrate(cr, version):
openupgrade.rename_columns(cr, column_renames)
openupgrade.copy_columns(cr, column_copies)
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)
def migrate(cr, version):
openupgrade.rename_columns(cr, column_renames)
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)
@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_columns(env.cr, column_renames)
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%'"""
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)
@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