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

support function and project in inventory API


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29415 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 404a1ee5
......@@ -491,17 +491,21 @@ class SimulationTool(BaseTool):
# instances
resource=None, node=None, payment=None,
section=None, mirror_section=None, item=None,
function=None, project=None,
# used for tracking
input=0, output=0,
# categories
resource_category=None, node_category=None, payment_category=None,
section_category=None, mirror_section_category=None,
function_category=None, project_category=None,
# categories with strict membership
resource_category_strict_membership=None,
node_category_strict_membership=None,
payment_category_strict_membership=None,
section_category_strict_membership=None,
mirror_section_category_strict_membership=None,
function_category_strict_membership=None,
project_category_strict_membership=None,
# simulation_state
strict_simulation_state=0,
simulation_state=None, transit_simulation_state = None, omit_transit=0,
......@@ -512,7 +516,8 @@ class SimulationTool(BaseTool):
variation_category=None,
# uids
resource_uid=None, node_uid=None, section_uid=None, payment_uid=None,
mirror_node_uid=None, mirror_section_uid=None,
mirror_node_uid=None, mirror_section_uid=None, function_uid=None,
project_uid=None,
# omit input and output
omit_input=0,
omit_output=0,
......@@ -584,6 +589,8 @@ class SimulationTool(BaseTool):
column_value_dict.set('resource_uid', resource_uid)
column_value_dict.set('payment_uid', payment_uid)
column_value_dict.set('project_uid', project_uid)
column_value_dict.set('function_uid', function_uid)
if column_value_dict.set('section_uid', section_uid):
sql_kw['section_filtered'] = 1
column_value_dict.set('node_uid', node_uid)
......@@ -593,6 +600,8 @@ class SimulationTool(BaseTool):
column_value_dict.setUIDList('aggregate_uid', item)
column_value_dict.setUIDList('node_uid', node)
column_value_dict.setUIDList('payment_uid', payment)
column_value_dict.setUIDList('project_uid', project)
column_value_dict.setUIDList('function_uid', function)
if column_value_dict.setUIDList('section_uid', section):
sql_kw['section_filtered'] = 1
column_value_dict.setUIDList('mirror_section_uid', mirror_section)
......@@ -606,6 +615,8 @@ class SimulationTool(BaseTool):
# category membership
related_key_dict.setUIDList('resource_category_uid', resource_category)
related_key_dict.setUIDList('node_category_uid', node_category)
related_key_dict.setUIDList('project_category_uid', project_category)
related_key_dict.setUIDList('function_category_uid', function_category)
related_key_dict.setUIDList('payment_category_uid', payment_category)
if related_key_dict.setUIDList('section_category_uid',
section_category):
......@@ -617,6 +628,10 @@ class SimulationTool(BaseTool):
resource_category_strict_membership)
related_key_dict.setUIDList('node_category_strict_membership_uid',
node_category_strict_membership)
related_key_dict.setUIDList('project_category_strict_membership_uid',
project_category_strict_membership)
related_key_dict.setUIDList('function_category_strict_membership_uid',
function_category_strict_membership)
related_key_dict.setUIDList('payment_category_strict_membership_uid',
payment_category_strict_membership)
if related_key_dict.setUIDList('section_category_strict_membership_uid',
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>table_0</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>table_0</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<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</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_function_uid_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_0>.uid = stock.function_uid
]]></string> </value>
</item>
<item>
<key> <string>template</string> </key>
<value>
<object>
<klass>
<global name="__newobj__" module="copy_reg"/>
</klass>
<tuple>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string encoding="cdata"><![CDATA[
<string>
]]></string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-var table_0>.uid = stock.function_uid
]]></string> </value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>table_0</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>table_0</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<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</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_project_uid_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_0>.uid = stock.project_uid
]]></string> </value>
</item>
<item>
<key> <string>template</string> </key>
<value>
<object>
<klass>
<global name="__newobj__" module="copy_reg"/>
</klass>
<tuple>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string encoding="cdata"><![CDATA[
<string>
]]></string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-var table_0>.uid = stock.project_uid
]]></string> </value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>table_0</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>table_0</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<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</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_strict_membership_function_uid_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_0>.uid = stock.function_uid AND\n
<dtml-var table_0>.category_strict_membership = 1\n
]]></string> </value>
</item>
<item>
<key> <string>template</string> </key>
<value>
<object>
<klass>
<global name="__newobj__" module="copy_reg"/>
</klass>
<tuple>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string encoding="cdata"><![CDATA[
<string>
]]></string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-var table_0>.uid = stock.function_uid AND\n
<dtml-var table_0>.category_strict_membership = 1\n
]]></string> </value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>table_0</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>table_0</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<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</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_strict_membership_project_uid_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_0>.uid = stock.project_uid AND\n
<dtml-var table_0>.category_strict_membership = 1\n
]]></string> </value>
</item>
<item>
<key> <string>template</string> </key>
<value>
<object>
<klass>
<global name="__newobj__" module="copy_reg"/>
</klass>
<tuple>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string encoding="cdata"><![CDATA[
<string>
]]></string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-var table_0>.uid = stock.project_uid AND\n
<dtml-var table_0>.category_strict_membership = 1\n
]]></string> </value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -24,12 +24,16 @@
<key>parent_title | catalog/title/z_related_parent</key>
<key>predicate_uid | predicate/uid/z_related_predicate</key>
<key>resourceType | movement,catalog/portal_type/z_related_resource_from_movement</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_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_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_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_project_category_strict_membership_uid | category/category_uid/z_related_strict_membership_project_uid_from_stock</key>
<key>stock_project_category_uid | category/category_uid/z_related_project_uid_from_stock</key>
<key>stock_resource_category_strict_membership_uid | category/category_uid/z_related_strict_membership_resource_uid_from_stock</key>
<key>stock_resource_category_uid | category/category_uid/z_related_resource_uid_from_stock</key>
<key>stock_section_category_strict_membership_uid | category/category_uid/z_related_strict_membership_section_uid_from_stock</key>
......
140
\ No newline at end of file
142
\ No newline at end of file
......@@ -82,6 +82,7 @@ erp5_mysql_innodb/z_record_object_list
erp5_mysql_innodb/z_related_base_category_id
erp5_mysql_innodb/z_related_career_skill
erp5_mysql_innodb/z_related_explanation
erp5_mysql_innodb/z_related_function_uid_from_stock
erp5_mysql_innodb/z_related_grand_parent
erp5_mysql_innodb/z_related_metric_type
erp5_mysql_innodb/z_related_mirror_section_uid_from_stock
......@@ -91,13 +92,16 @@ erp5_mysql_innodb/z_related_parent_specialise
erp5_mysql_innodb/z_related_parent_strict_group
erp5_mysql_innodb/z_related_payment_uid_from_stock
erp5_mysql_innodb/z_related_predicate
erp5_mysql_innodb/z_related_project_uid_from_stock
erp5_mysql_innodb/z_related_resource_from_movement
erp5_mysql_innodb/z_related_resource_uid_from_stock
erp5_mysql_innodb/z_related_section_uid_from_stock
erp5_mysql_innodb/z_related_security
erp5_mysql_innodb/z_related_strict_membership_function_uid_from_stock
erp5_mysql_innodb/z_related_strict_membership_mirror_section_uid_from_stock
erp5_mysql_innodb/z_related_strict_membership_node_uid_from_stock
erp5_mysql_innodb/z_related_strict_membership_payment_uid_from_stock
erp5_mysql_innodb/z_related_strict_membership_project_uid_from_stock
erp5_mysql_innodb/z_related_strict_membership_resource_uid_from_stock
erp5_mysql_innodb/z_related_strict_membership_section_uid_from_stock
erp5_mysql_innodb/z_related_translated_causality_state
......
......@@ -26,6 +26,10 @@ base_category_id | category,catalog/id/z_related_base_category_id
grand_parent_simulation_state | catalog,catalog/simulation_state/z_related_grand_parent
stock_mirror_section_category_uid | category/category_uid/z_related_mirror_section_uid_from_stock
stock_node_category_strict_membership_uid | category/category_uid/z_related_strict_membership_node_uid_from_stock
stock_function_category_strict_membership_uid | category/category_uid/z_related_strict_membership_function_uid_from_stock
stock_function_category_uid | category/category_uid/z_related_function_uid_from_stock
stock_project_category_strict_membership_uid | category/category_uid/z_related_strict_membership_project_uid_from_stock
stock_project_category_uid | category/category_uid/z_related_project_uid_from_stock
deliveryLineType | movement,catalog/portal_type/z_related_uid_or_parent_uid
item_section_category_uid | category/category_uid/z_related_section_uid_from_item
parent_specialise_portal_type | category,catalog/portal_type/z_related_parent_specialise
......
......@@ -189,6 +189,8 @@ class InventoryAPITestCase(ERP5TypeTestCase):
'group/level1/level2',
'group/anotherlevel',
'product_line/level1/level2',
'function/function1',
'function/function1/function2',
# we create a huge group category for consolidation tests
) + self.GROUP_CATEGORIES + self.VARIATION_CATEGORIES
......@@ -393,6 +395,90 @@ class TestInventory(InventoryAPITestCase):
self.assertEquals(getInventory(
node_category_strict_membership=['group/level1']), 100)
def test_Function(self):
"""Tests inventory on function"""
getInventory = self.getSimulationTool().getInventory
self._makeMovement(quantity=100,
destination_function='function/function1')
self.assertEquals(getInventory(
function='function/function1'), 100)
self.assertEquals(getInventory(
function='function/function1/function2'), 0)
def test_FunctionUid(self):
"""Tests inventory on function uid"""
getInventory = self.getSimulationTool().getInventory
function = self.portal.portal_categories.function
self._makeMovement(quantity=100,
destination_function='function/function1')
self.assertEquals(getInventory(
function_uid=function.function1.getUid()), 100)
self.assertEquals(getInventory(
function_uid=function.function1.function2.getUid()), 0)
def test_FunctionCategory(self):
"""Tests inventory on function category"""
getInventory = self.getSimulationTool().getInventory
function = self.portal.portal_categories.function
self._makeMovement(quantity=100,
destination_function='function/function1/function2')
self.assertEquals(getInventory(
function_category='function/function1'), 100)
self.assertEquals(getInventory(
function='function/function1/function2'), 100)
def test_FunctionCategoryStrictMembership(self):
"""Tests inventory on function category strict membership"""
getInventory = self.getSimulationTool().getInventory
function = self.portal.portal_categories.function
self._makeMovement(quantity=100,
destination_function='function/function1/function2')
self.assertEquals(getInventory(
function_category_strict_membership='function/function1'), 0)
self.assertEquals(getInventory(
function_category_strict_membership='function/function1/function2'), 100)
def test_Project(self):
"""Tests inventory on project"""
getInventory = self.getSimulationTool().getInventory
self._makeMovement(quantity=100,
destination_project_value=self.mirror_node)
self.assertEquals(getInventory(
project=self.mirror_node.getRelativeUrl()), 100)
def test_ProjectUid(self):
"""Tests inventory on project uid"""
getInventory = self.getSimulationTool().getInventory
self._makeMovement(quantity=100,
destination_project_value=self.mirror_node)
self.assertEquals(getInventory(
project_uid=self.mirror_node.getUid()), 100)
def test_ProjectCategory(self):
"""Tests inventory on project category"""
# this test uses unrealistic data
getInventory = self.getSimulationTool().getInventory
self.mirror_node.setGroup('level1/level2')
self._makeMovement(quantity=100,
destination_project_value=self.mirror_node)
self.assertEquals(getInventory(
project_category='group/level1'), 100)
self.assertEquals(getInventory(
project_category='group/level1/level2'), 100)
def test_ProjectCategoryStrictMembership(self):
"""Tests inventory on project category strict membership"""
# this test uses unrealistic data
getInventory = self.getSimulationTool().getInventory
self.mirror_node.setGroup('level1/level2')
self._makeMovement(quantity=100,
destination_project_value=self.mirror_node)
self.assertEquals(getInventory(
project_category_strict_membership='group/level1'), 0)
self.assertEquals(getInventory(
project_category_strict_membership='group/level1/level2'), 100)
def test_ResourceCategory(self):
"""Tests inventory on resource_category """
getInventory = self.getSimulationTool().getInventory
......
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