From 09ff03afe2665b6a6e8aa600eb92b3451bb2ab53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Fri, 1 Feb 2013 12:08:34 +0100
Subject: [PATCH] Inventory API: test and document the problems with
 resource_portal_type / resourceType

---
 product/ERP5/tests/testInventoryAPI.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/product/ERP5/tests/testInventoryAPI.py b/product/ERP5/tests/testInventoryAPI.py
index ddf6483cd8..806ed1434f 100644
--- a/product/ERP5/tests/testInventoryAPI.py
+++ b/product/ERP5/tests/testInventoryAPI.py
@@ -525,6 +525,23 @@ class TestInventory(InventoryAPITestCase):
     self.assertInventoryEquals(100,
                 resource_category_strict_membership=['product_line/level1'])
 
+  def test_ResourcePortalType(self):
+    """Tests inventory on resource_portal_type """
+    self._makeMovement(quantity=2, source_value=None)
+    self._makeMovement(quantity=3,
+      source_value=None,
+      resource_value=self.portal.portal_categories.product_line.level1)
+    assert self.resource.portal_type != 'Category'
+    self.assertInventoryEquals(2,
+      resource_portal_type=self.resource.portal_type)
+    self.assertInventoryEquals(3,
+      resource_portal_type='Category')
+    # FIXME: resource_portal_type is an automatically generated related key,
+    # but as movements categories are not cataloged with acquisition, it does
+    # not work for movements acquiring resource from their parents.
+    # One way is to make an explicit resource_portal_type related key that
+    # would use stock.resource_uid (replacing the ugly 'resourceType')
+
   def test_PaymentCategory(self):
     """Tests inventory on payment_category """
     # for now, BankAccount have a product_line category, so we can use this for
-- 
2.30.9