Commit af649623 authored by Jérome Perrin's avatar Jérome Perrin

Inventory API: add some related keys, for example stock_node_title

(cherry picked from commit 86af2076)
parent a40709f6
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>table_0\r\n
table_1\r\n
RELATED_QUERY_SEPARATOR=" AND "</string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_related_explanation_translated_portal_type_from_stock</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>100</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-var table_1>.message_context = "portal_type"\n
AND <dtml-var table_1>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">\n
\n
<dtml-var RELATED_QUERY_SEPARATOR>\n
\n
<dtml-var table_1>.original_message = <dtml-var table_0>.portal_type\n
AND <dtml-var table_0>.uid = stock.explanation_uid
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -32,15 +32,20 @@ ...@@ -32,15 +32,20 @@
<key>related_resource_from_use_category_uid | category,category/category_uid/z_related_resource_from_use</key> <key>related_resource_from_use_category_uid | category,category/category_uid/z_related_resource_from_use</key>
<key>resourceType | catalog/portal_type/z_related_resource_uid_from_stock</key> <key>resourceType | catalog/portal_type/z_related_resource_uid_from_stock</key>
<key>stock_explanation_portal_type | catalog/portal_type/z_related_explanation_from_stock</key> <key>stock_explanation_portal_type | catalog/portal_type/z_related_explanation_from_stock</key>
<key>stock_explanation_reference | catalog/reference/z_related_explanation_from_stock</key>
<key>stock_explanation_simulation_state | catalog/simulation_state/z_related_explanation_from_stock</key> <key>stock_explanation_simulation_state | catalog/simulation_state/z_related_explanation_from_stock</key>
<key>stock_explanation_title | catalog/title/z_related_explanation_from_stock</key>
<key>stock_explanation_translated_portal_type | catalog,translation/translated_message/z_related_explanation_translated_portal_type_from_stock</key>
<key>stock_function_category_strict_membership_uid | category/category_uid/z_related_strict_membership_function_uid_from_stock</key> <key>stock_function_category_strict_membership_uid | category/category_uid/z_related_strict_membership_function_uid_from_stock</key>
<key>stock_function_category_uid | category/category_uid/z_related_function_uid_from_stock</key> <key>stock_function_category_uid | category/category_uid/z_related_function_uid_from_stock</key>
<key>stock_funding_category_strict_membership_uid | category/category_uid/z_related_strict_membership_funding_uid_from_stock</key> <key>stock_funding_category_strict_membership_uid | category/category_uid/z_related_strict_membership_funding_uid_from_stock</key>
<key>stock_funding_category_uid | category/category_uid/z_related_funding_uid_from_stock</key> <key>stock_funding_category_uid | category/category_uid/z_related_funding_uid_from_stock</key>
<key>stock_mirror_section_category_strict_membership_uid | category/category_uid/z_related_strict_membership_mirror_section_uid_from_stock</key> <key>stock_mirror_section_category_strict_membership_uid | category/category_uid/z_related_strict_membership_mirror_section_uid_from_stock</key>
<key>stock_mirror_section_category_uid | category/category_uid/z_related_mirror_section_uid_from_stock</key> <key>stock_mirror_section_category_uid | category/category_uid/z_related_mirror_section_uid_from_stock</key>
<key>stock_mirror_section_title | catalog/title/z_related_mirror_section_uid_from_stock</key>
<key>stock_node_category_strict_membership_uid | category/category_uid/z_related_strict_membership_node_uid_from_stock</key> <key>stock_node_category_strict_membership_uid | category/category_uid/z_related_strict_membership_node_uid_from_stock</key>
<key>stock_node_category_uid | category/category_uid/z_related_node_uid_from_stock</key> <key>stock_node_category_uid | category/category_uid/z_related_node_uid_from_stock</key>
<key>stock_node_title | catalog/title/z_related_node_uid_from_stock</key>
<key>stock_payment_category_strict_membership_uid | category/category_uid/z_related_strict_membership_payment_uid_from_stock</key> <key>stock_payment_category_strict_membership_uid | category/category_uid/z_related_strict_membership_payment_uid_from_stock</key>
<key>stock_payment_category_uid | category/category_uid/z_related_payment_uid_from_stock</key> <key>stock_payment_category_uid | category/category_uid/z_related_payment_uid_from_stock</key>
<key>stock_payment_request_category_strict_membership_uid | category/category_uid/z_related_strict_membership_payment_request_uid_from_stock</key> <key>stock_payment_request_category_strict_membership_uid | category/category_uid/z_related_strict_membership_payment_request_uid_from_stock</key>
......
...@@ -82,6 +82,7 @@ erp5_mysql_innodb/z_related_child_aggregate ...@@ -82,6 +82,7 @@ erp5_mysql_innodb/z_related_child_aggregate
erp5_mysql_innodb/z_related_children erp5_mysql_innodb/z_related_children
erp5_mysql_innodb/z_related_explanation erp5_mysql_innodb/z_related_explanation
erp5_mysql_innodb/z_related_explanation_from_stock erp5_mysql_innodb/z_related_explanation_from_stock
erp5_mysql_innodb/z_related_explanation_translated_portal_type_from_stock
erp5_mysql_innodb/z_related_function_uid_from_stock erp5_mysql_innodb/z_related_function_uid_from_stock
erp5_mysql_innodb/z_related_funding_uid_from_stock erp5_mysql_innodb/z_related_funding_uid_from_stock
erp5_mysql_innodb/z_related_grand_parent erp5_mysql_innodb/z_related_grand_parent
......
stock_explanation_title | catalog/title/z_related_explanation_from_stock
stock_explanation_reference | catalog/reference/z_related_explanation_from_stock
stock_mirror_section_title | catalog/title/z_related_mirror_section_uid_from_stock
stock_node_title | catalog/title/z_related_node_uid_from_stock
stock_explanation_translated_portal_type | catalog,translation/translated_message/z_related_explanation_translated_portal_type_from_stock
item_resource_category_uid | category/category_uid/z_related_resource_uid_from_item item_resource_category_uid | category/category_uid/z_related_resource_uid_from_item
stock_section_category_strict_membership_uid | category/category_uid/z_related_strict_membership_section_uid_from_stock stock_section_category_strict_membership_uid | category/category_uid/z_related_strict_membership_section_uid_from_stock
subject | versioning,subject/subject/z_related_subject subject | versioning,subject/subject/z_related_subject
......
...@@ -786,6 +786,18 @@ class TestInventory(InventoryAPITestCase): ...@@ -786,6 +786,18 @@ class TestInventory(InventoryAPITestCase):
self.assertInventoryEquals(0, node_uid=self.node.getUid(), omit_input=1) self.assertInventoryEquals(0, node_uid=self.node.getUid(), omit_input=1)
self.assertInventoryEquals(1, node_uid=self.node.getUid(), omit_output=1) self.assertInventoryEquals(1, node_uid=self.node.getUid(), omit_output=1)
def test_NodeTitle(self):
self._makeMovement(quantity=1)
self.assertInventoryEquals(1, stock_node_title=self.node.getTitle())
self.assertInventoryEquals(-1, stock_node_title=self.mirror_node.getTitle())
def test_MirrorSectionTitle(self):
self._makeMovement(quantity=1)
self.assertInventoryEquals(1,
stock_mirror_section_title=self.mirror_section.getTitle())
self.assertInventoryEquals(-1,
stock_mirror_section_title=self.section.getTitle())
def test_TimeZone(self): def test_TimeZone(self):
""" """
Check that getInventory support DateTime parameter with Check that getInventory support DateTime parameter with
...@@ -1222,6 +1234,30 @@ class TestInventoryList(InventoryAPITestCase): ...@@ -1222,6 +1234,30 @@ class TestInventoryList(InventoryAPITestCase):
self.assertEqual(-1, inventory_list[0].total_price) self.assertEqual(-1, inventory_list[0].total_price)
self.assertEqual(-1, inventory_list[0].total_quantity) self.assertEqual(-1, inventory_list[0].total_quantity)
def test_NodeTitle(self):
getInventoryList = self.getSimulationTool().getInventoryList
self._makeMovement(quantity=1)
inventory_list = getInventoryList(stock_node_title=self.node.getTitle())
self.assertEqual(1, len(inventory_list))
self.assertEqual(1, inventory_list[0].total_quantity)
inventory_list = getInventoryList(stock_node_title=self.mirror_node.getTitle())
self.assertEqual(1, len(inventory_list))
self.assertEqual(-1, inventory_list[0].total_quantity)
def test_MirrorSectionTitle(self):
getInventoryList = self.getSimulationTool().getInventoryList
self._makeMovement(quantity=1)
inventory_list = getInventoryList(
stock_mirror_section_title=self.mirror_section.getTitle())
self.assertEqual(1, len(inventory_list))
self.assertEqual(1, inventory_list[0].total_quantity)
inventory_list = getInventoryList(
stock_mirror_section_title=self.section.getTitle())
self.assertEqual(1, len(inventory_list))
self.assertEqual(-1, inventory_list[0].total_quantity)
def test_CurentAvailableFutureInventoryList(self): def test_CurentAvailableFutureInventoryList(self):
def makeMovement(simulation_state=None, quantity=None): def makeMovement(simulation_state=None, quantity=None):
self._makeMovement(quantity=quantity, price=1, self._makeMovement(quantity=quantity, price=1,
...@@ -2140,6 +2176,32 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -2140,6 +2176,32 @@ class TestMovementHistoryList(InventoryAPITestCase):
omit_input=1, omit_input=1,
omit_output=1))) omit_output=1)))
def test_NodeTitle(self):
self._makeMovement(quantity=1)
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
mvt_history_list = getMovementHistoryList(
stock_node_title=self.node.getTitle())
self.assertEqual(1, len(mvt_history_list))
self.assertEqual(1, mvt_history_list[0].total_quantity)
mvt_history_list = getMovementHistoryList(
stock_node_title=self.mirror_node.getTitle())
self.assertEqual(1, len(mvt_history_list))
self.assertEqual(-1, mvt_history_list[0].total_quantity)
def test_MirrorSectionTitle(self):
self._makeMovement(quantity=1)
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
mvt_history_list = getMovementHistoryList(
stock_mirror_section_title=self.mirror_section.getTitle())
self.assertEqual(1, len(mvt_history_list))
self.assertEqual(1, mvt_history_list[0].total_quantity)
mvt_history_list = getMovementHistoryList(
stock_mirror_section_title=self.section.getTitle())
self.assertEqual(1, len(mvt_history_list))
self.assertEqual(-1, mvt_history_list[0].total_quantity)
def test_debit_credit(self): def test_debit_credit(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
self._makeMovement(quantity=-1, price=2, self._makeMovement(quantity=-1, price=2,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment