Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.0][ADD] connector-magento: migrate v9 jobs #324

Open
wants to merge 1 commit into
base: 10.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
])),
)