details: https://code.tryton.org/tryton/commit/79cab698dc8d
branch: default
user: Cédric Krier <[email protected]>
date: Thu Nov 12 10:42:23 2026 +0100
description:
Use created date filter to fetch Shopify orders by cron
The cron task is used to catchup missing orders as Shopify may publish
some
order with a delay compared to the created date.
When run from the cron task, the filter is based on the last run of the
cron.
#15209
diffstat:
modules/web_shop_shopify/web.py | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diffs (39 lines):
diff -r 51bd87c024a7 -r 79cab698dc8d modules/web_shop_shopify/web.py
--- a/modules/web_shop_shopify/web.py Wed Nov 11 11:05:22 2026 +0100
+++ b/modules/web_shop_shopify/web.py Thu Nov 12 10:42:23 2026 +0100
@@ -763,11 +763,24 @@
pool = Pool()
Sale = pool.get('sale.sale')
Payment = pool.get('account.payment')
+ CronLog = pool.get('ir.cron.log')
context = Transaction().context
if shops is None:
shops = cls.search([
('type', '=', 'shopify'),
])
+ created_at = None
+ if method := context.get('_cron'):
+ logs = CronLog.search([
+ ('cron.method', '=', method),
+ ],
+ order=[('started', 'DESC')],
+ limit=1)
+ if logs:
+ log, = logs
+ created_at = log.started
+ # add small gap to catch late publication
+ created_at -= dt.timedelta(seconds=60)
fields = Sale.shopify_fields()
cls.lock(shops)
for shop in shops:
@@ -782,6 +795,10 @@
if pool.test and 'shopify_orders' in context:
query = ' OR '.join(
f'id:{id}' for id in context['shopify_orders'])
+ elif created_at is not None and last_order_id:
+ query = (
+ '-status:cancelled '
+ f"AND created_at:>='{created_at.isoformat()}Z'")
elif last_order_id:
query = f'-status:cancelled AND id:>{last_order_id}'
else: