From 4afface0637277206023a7b88535706c02baa1a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Mon, 6 Jun 2016 07:31:58 +0000
Subject: [PATCH] Inventory API: expose order_id in movement history list

The use case is to generate an unique id for each sides of the movement
or each "submovements" when using asMovementList
---
 .../erp5_core/Resource_zGetMovementHistoryList.xml             | 1 +
 product/ERP5/tests/testInventoryAPI.py                         | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
index 534043d2bc..16d0db4e25 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
@@ -490,6 +490,7 @@ FROM (\n
 SELECT DISTINCT\n
   catalog.path as path,\n
   catalog.uid as uid,\n
+  stock.order_id as order_id,\n
   catalog.relative_url as relative_url,\n
   stock.date AS date_utc,\n
   stock.mirror_date AS mirror_date_utc,\n
diff --git a/product/ERP5/tests/testInventoryAPI.py b/product/ERP5/tests/testInventoryAPI.py
index 3da95a4e7d..fdc950d16f 100644
--- a/product/ERP5/tests/testInventoryAPI.py
+++ b/product/ERP5/tests/testInventoryAPI.py
@@ -1566,6 +1566,9 @@ class TestMovementHistoryList(InventoryAPITestCase):
     self.assertTrue(hasattr(brain, 'resource_relative_url'))
     self.assertEqual(brain.resource_relative_url, self.resource.getRelativeUrl())
 
+    # order_id is exposed on brains, useful to generate unique id, using "{uid}-{order_id}"
+    self.assertTrue(hasattr(brain, 'order_id'))
+
 
   def testBrainGetItem(self):
     """Test __getitem__ interface on brains."""
-- 
2.30.9