details:   https://code.tryton.org/tryton/commit/58bde097ad51
branch:    default
user:      Cédric Krier <[email protected]>
date:      Thu Jun 25 15:26:30 2026 +0200
description:
        Set only one quantity per line items when creating Shopify fulfillment

        Closes #14912
diffstat:

 modules/web_shop_shopify/stock.py |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (33 lines):

diff -r d7c4e8ae89e4 -r 58bde097ad51 modules/web_shop_shopify/stock.py
--- a/modules/web_shop_shopify/stock.py Mon Jun 22 11:14:23 2026 +0200
+++ b/modules/web_shop_shopify/stock.py Thu Jun 25 15:26:30 2026 +0200
@@ -79,19 +79,24 @@
             QUERY_FULFILLMENT_ORDERS % {
                 'fields': graphql.selection(fulfillment_order_fields),
                 }, {'orderId': order_id}).data['order']['fulfillmentOrders']
-        line_items = defaultdict(list)
+        order_line_items = defaultdict(lambda: defaultdict(int))
         for move in self.outgoing_moves:
             if move.sale == sale:
                 for order_id, line_item in move.get_shopify(
                         fulfillment_orders, location_id):
-                    line_items[order_id].append(line_item)
-        if not line_items:
+                    order_line_items[order_id][line_item['id']] += (
+                        line_item['quantity'])
+        if not order_line_items:
             return
         fulfillment['lineItemsByFulfillmentOrder'] = [{
                 'fulfillmentOrderId': order_id,
-                'fulfillmentOrderLineItems': line_items,
+                'fulfillmentOrderLineItems': [{
+                        'id': id,
+                        'quantity': quantity,
+                        }
+                    for id, quantity in line_items.items()],
                 }
-            for order_id, line_items in line_items.items()]
+            for order_id, line_items in order_line_items.items()]
         fulfillment['notifyCustomer'] = bool(
             sale.web_shop.shopify_fulfillment_notify_customer)
         return fulfillment

Reply via email to