Skip to content

Commit

Permalink
[ADD] connector-magento: migrate v9 import_record jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed May 6, 2021
1 parent 589b62a commit e33f393
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions connector_magento/migrations/10.0.1.0.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*-
# (c) 2021 Hunki Enterprises BV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


def migrate(cr, version=None):
"""Migrate jobs to new format"""
if not version:
return
# import_record
cr.execute(
"""update queue_job
set
args=json_build_array(
json_build_object(
'_type', 'odoo_recordset',
'model', 'magento.backend',
'ids', array[args::json->1],
'uid', user_id
),
args::json->2
)
where
method_name=%s and model_name in %s""",
('import_record', tuple([
'magento.account.invoice',
'magento.sale.order',
'magento.sale.order.line',
'magento.stock.picking',
])),
)
# sale_order_import_batch
cr.execute(
"""update queue_job
set
method_name='import_batch',
args=json_build_array(
json_build_object(
'_type', 'odoo_recordset',
'model', 'magento.backend',
'ids', array[args::json->1],
'uid', user_id
)
)
where
method_name=%s and model_name in %s""",
('sale_order_import_batch', tuple([
'magento.sale.order',
])),
)
# export_picking_done
cr.execute(
"""update queue_job
set
record_ids=json_build_array(
args::json->1
),
args=json_build_array()
where
method_name=%s and model_name in %s""",
('export_picking_done', tuple([
'magento.stock.picking',
])),
)
# export_tracking_number
cr.execute(
"""update queue_job
set
record_ids=json_build_array(
args::json->1
),
args=json_build_array()
where
method_name=%s and model_name in %s""",
('export_tracking_number', tuple([
'magento.stock.picking',
])),
)

0 comments on commit e33f393

Please sign in to comment.