Commit 11f6c277 authored by Jérome Perrin's avatar Jérome Perrin

pdm: support quantity_unit and metric_type conversion in stock browser

Convert the amounts in inventory list view, the movement history list
views still show in movement unit for simplicity.
parent 7b5c900b
...@@ -231,6 +231,8 @@ ...@@ -231,6 +231,8 @@
<string>my_view_mode_read_only_title</string> <string>my_view_mode_read_only_title</string>
<string>my_dialog_mode_node_category</string> <string>my_dialog_mode_node_category</string>
<string>my_dialog_mode_section_category</string> <string>my_dialog_mode_section_category</string>
<string>my_dialog_mode_quantity_unit</string>
<string>my_dialog_mode_metric_type</string>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_dialog_mode_metric_type</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_dialog_mode_category</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Metric Type</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_dialog_mode_quantity_unit</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_dialog_mode_category</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Quantity Unit</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.PythonScripts.standard import Object from Products.PythonScripts.standard import Object
portal = context.getPortalObject() portal = context.getPortalObject()
inventory_kw = { inventory_list_kw = {
'selection_domain': selection_domain, 'selection_domain': selection_domain,
'group_by_section': False, 'group_by_section': False,
'group_by_node': True, 'group_by_node': True,
...@@ -10,8 +10,51 @@ inventory_kw = { ...@@ -10,8 +10,51 @@ inventory_kw = {
} }
if node_category: if node_category:
inventory_kw['node_category'] = node_category inventory_list_kw['node_category'] = node_category
if section_category: if section_category:
inventory_list_kw['section_category'] = section_category
if quantity_unit:
inventory_list_kw['quantity_unit'] = quantity_unit
if metric_type:
inventory_list_kw['metric_type'] = metric_type
def makeResultLine(brain):
"""Rewap a brain to propagate inventory kw in getCurrentInventory and getAvailableInventory
"""
inventory_kw = {
'node_uid': brain.node_uid,
'resource_uid': brain.resource_uid,
'variation_text': brain.variation_text,
}
if section_category:
inventory_kw['section_category'] = section_category inventory_kw['section_category'] = section_category
if quantity_unit:
inventory_kw['quantity_unit'] = quantity_unit
if metric_type:
inventory_kw['metric_type'] = metric_type
def getCurrentInventory():
return portal.portal_simulation.getCurrentInventory(**inventory_kw)
def getAvailableInventory():
return portal.portal_simulation.getAvailableInventory(**inventory_kw)
return Object(
uid='new_',
node_title=brain.node_title,
inventory=getattr(brain, 'converted_quantity', brain.inventory),
getCurrentInventory=getCurrentInventory,
getAvailableInventory=getAvailableInventory,
getVariationCategoryItemList=brain.getVariationCategoryItemList,
variation_category_item_list=[x[0] for x in brain.getObject().getVariationCategoryItemList()],
getListItemUrl=brain.getListItemUrl,
getListItemParamDict=brain.getListItemParamDict,
getListItemUrlDict=brain.getListItemUrlDict,
)
return portal.portal_simulation.getFutureInventoryList(**inventory_kw) return [
makeResultLine(brain)
for brain in portal.portal_simulation.getFutureInventoryList(
**inventory_list_kw)
]
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>node_category=None, section_category=None, selection_domain=None, **kw</string> </value> <value> <string>node_category=None, section_category=None, quantity_unit=None, metric_type=None, selection_domain=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -2,10 +2,14 @@ from Products.PythonScripts.standard import Object ...@@ -2,10 +2,14 @@ from Products.PythonScripts.standard import Object
inventory_kw = { inventory_kw = {
'selection_domain': selection_domain 'selection_domain': selection_domain
} }
if section_category:
inventory_kw['section_category'] = section_category
if node_category: if node_category:
inventory_kw['node_category'] = node_category inventory_kw['node_category'] = node_category
if section_category:
inventory_kw['section_category'] = section_category
if quantity_unit:
inventory_kw['quantity_unit'] = quantity_unit
if metric_type:
inventory_kw['metric_type'] = metric_type
obj = Object(uid="new_") obj = Object(uid="new_")
obj["node_title"] = "" obj["node_title"] = ""
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>section_category=None, node_category=None, selection_domain=None, **kw</string> </value> <value> <string>node_category=None, section_category=None, quantity_unit=None, metric_type=None, selection_domain=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -113,7 +113,10 @@ ...@@ -113,7 +113,10 @@
<item> <item>
<key> <string>right</string> </key> <key> <string>right</string> </key>
<value> <value>
<list/> <list>
<string>your_metric_type</string>
<string>your_quantity_unit</string>
</list>
</value> </value>
</item> </item>
</dictionary> </dictionary>
......
...@@ -134,9 +134,7 @@ ...@@ -134,9 +134,7 @@
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
<value> <value> <string></string> </value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -297,17 +295,4 @@ ...@@ -297,17 +295,4 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [x[0] for x in cell.getVariationCategoryItemList()]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_metric_type</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_dialog_mode_metric_type</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewPDMFieldLibrary</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_quantity_unit</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_dialog_mode_quantity_unit</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewPDMFieldLibrary</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testConversionMetricType</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html>
<head><title>Test stock browser for metric type conversions</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="4">
Test stock browser for metric type conversions
</td></tr>
</thead>
<tbody tal:define="init_method string:PdmZuite_createDelivery?state=stopped">
<!-- Setup {{{ -->
<tal:block metal:use-macro="here/PdmZuite_CommonTemplateForRenderjsUi/macros/init" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<!-- Check source -->
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_source_site_title';
metric_type string: Unit/Abstract Unit;
node_title string: erp5_pdm_ui_test_source_node_title;
inventory_list_count python: 1;
current_inventory python: -3;
available_inventory python: -3;
future_inventory python: -3;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowserForRenderjsUi/macros/check_inventory" />
</tal:block>
<!-- Check destination -->
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_destination_site_title';
metric_type string: Unit/Abstract Unit;
node_title string: erp5_pdm_ui_test_destination_node_title;
inventory_list_count python: 1;
current_inventory python: 3;
available_inventory python: 3;
future_inventory python: 3;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowserForRenderjsUi/macros/check_inventory" />
</tal:block>
<tal:block metal:use-macro="here/PdmZuite_CommonTemplateForRenderjsUi/macros/check_links_for_stocks" />
<!-- Check the links in hardcoded way -->
<!-- TODO: If possible, move to macros -->
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[1]/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[1]/a</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="pagination_configuration python: {'header': '(1)', 'footer': '1 Records'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[3]</td>
<td>erp5_pdm_ui_test_destination_node_title</td>
</tr>
<tal:block metal:use-macro="here/PdmZuite_CommonTemplateForRenderjsUi/macros/check_links" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[5]/a</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
<!-- vim: syntax=html foldmethod=marker -->
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testConversionQuantityUnit</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html>
<head><title>Test stock browser for quantity unit conversions</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="4">
Test stock browser for quantity unit conversions
</td></tr>
</thead>
<tbody tal:define="init_method string:PdmZuite_createDelivery?state=stopped">
<!-- Setup {{{ -->
<tal:block metal:use-macro="here/PdmZuite_CommonTemplateForRenderjsUi/macros/init" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<!-- Check source -->
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_source_site_title';
quantity_unit string: Mass/Kilogram;
node_title string: erp5_pdm_ui_test_source_node_title;
inventory_list_count python: 1;
current_inventory string: -1 500;
available_inventory string: -1 500;
future_inventory string: -1 500;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowserForRenderjsUi/macros/check_inventory" />
</tal:block>
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_source_site_title';
quantity_unit string: Mass/Ton;
node_title string: erp5_pdm_ui_test_source_node_title;
inventory_list_count python: 1;
current_inventory string: -1.5;
available_inventory string: -1.5;
future_inventory string: -1.5;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowserForRenderjsUi/macros/check_inventory" />
</tal:block>
<!-- Check destination -->
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_destination_site_title';
quantity_unit string: Mass/Kilogram;
node_title string: erp5_pdm_ui_test_destination_node_title;
inventory_list_count python: 1;
current_inventory string: 1 500;
available_inventory string: 1 500;
future_inventory string: 1 500;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowserForRenderjsUi/macros/check_inventory" />
</tal:block>
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_destination_site_title';
quantity_unit string: Mass/Ton;
node_title string: erp5_pdm_ui_test_destination_node_title;
inventory_list_count python: 1;
current_inventory string: 1.5;
available_inventory string: 1.5;
future_inventory string: 1.5;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowserForRenderjsUi/macros/check_inventory" />
</tal:block>
<tal:block metal:use-macro="here/PdmZuite_CommonTemplateForRenderjsUi/macros/check_links_for_stocks" />
<!-- Check the links in hardcoded way -->
<!-- TODO: If possible, move to macros -->
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[1]/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[1]/a</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="pagination_configuration python: {'header': '(1)', 'footer': '1 Records'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[3]</td>
<td>erp5_pdm_ui_test_destination_node_title</td>
</tr>
<tal:block metal:use-macro="here/PdmZuite_CommonTemplateForRenderjsUi/macros/check_links" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[5]/a</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
<!-- vim: syntax=html foldmethod=marker -->
\ No newline at end of file
...@@ -20,11 +20,17 @@ ...@@ -20,11 +20,17 @@
Optional parameters: Optional parameters:
- select_node_category: if True (the default) the node category will be selected - select_node_category: if True (the default) the node category will be selected
- quantity_unit: the label of the quantity unit to select in dialog, to enable
quantity unit conversion
- metric_type: the label of the metric type to select in dialog, to enable
metric type conversion
--> -->
<tal:block <tal:block
metal:define-macro="check_inventory" metal:define-macro="check_inventory"
tal:define="base_url python: '/' + here.getPortalObject().getId(); tal:define="base_url python: '/' + here.getPortalObject().getId();
select_node_category select_node_category | python: True"> select_node_category select_node_category | python: True;
quantity_unit quantity_unit | python: False;
metric_type metric_type | python: False;">
<tal:block tal:condition="select_node_category"> <tal:block tal:condition="select_node_category">
<tr> <tr>
...@@ -47,6 +53,34 @@ ...@@ -47,6 +53,34 @@
</tr> </tr>
</tal:block> </tal:block>
<tal:block tal:condition="quantity_unit">
<tr>
<td colspan="3"><b>Select quantity unit in dialog</b></td>
</tr>
<tr>
<td>select</td>
<td>//select[@name="field_your_quantity_unit"]</td>
<td tal:content='quantity_unit'></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
</tal:block>
<tal:block tal:condition="metric_type">
<tr>
<td colspan="3"><b>Select metric type in dialog</b></td>
</tr>
<tr>
<td>select</td>
<td>//select[@name="field_your_metric_type"]</td>
<td tal:content='metric_type'></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
</tal:block>
<!-- Check inventory total records --> <!-- Check inventory total records -->
<tal:block tal:define="pagination_configuration python: {'header': '(%s)' % inventory_list_count, 'footer': '%s Records' % inventory_list_count}"> <tal:block tal:define="pagination_configuration python: {'header': '(%s)' % inventory_list_count, 'footer': '%s Records' % inventory_list_count}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>conversion_metric_type</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html>
<head><title>Test stock browser for metric type conversion</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="4">
Test stock browser for metric type conversion
</td></tr>
</thead>
<tbody tal:define="init_method string:PdmZuite_createDelivery?state=delivered">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowser/macros/init" />
<!-- Check source -->
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_source_site_title';
metric_type string: Unit/Abstract Unit;
inventory_list_count python: 1;
current_inventory python: -3.0;
available_inventory python: -3.0;
future_inventory python: -3.0;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowser/macros/check_inventory" />
</tal:block>
<!-- Check destination -->
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_destination_site_title';
metric_type string: Unit/Abstract Unit;
inventory_list_count python: 1;
current_inventory python: 3.0;
available_inventory python: 3.0;
future_inventory python: 3.0;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowser/macros/check_inventory" />
</tal:block>
</tbody></table>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>conversion_quantity_unit</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html>
<head><title>Test stock browser for quantity unit conversion</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="4">
Test stock browser for quantity unit conversion
</td></tr>
</thead>
<tbody tal:define="init_method string:PdmZuite_createDelivery?state=delivered">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowser/macros/init" />
<!-- Check source -->
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_source_site_title';
quantity_unit string: Mass/Kilogram;
inventory_list_count python: 1;
current_inventory string: -1 500.0;
available_inventory string: -1 500.0;
future_inventory string: -1 500.0;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowser/macros/check_inventory" />
</tal:block>
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_source_site_title';
quantity_unit string: Mass/Ton;
inventory_list_count python: 1;
current_inventory python: -1.5;
available_inventory python: -1.5;
future_inventory python: -1.5;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowser/macros/check_inventory" />
</tal:block>
<!-- Check destination -->
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_destination_site_title';
quantity_unit string: Mass/Kilogram;
inventory_list_count python: 1;
current_inventory string: 1 500.0;
available_inventory string: 1 500.0;
future_inventory string: 1 500.0;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowser/macros/check_inventory" />
</tal:block>
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_destination_site_title';
quantity_unit string: Mass/Ton;
inventory_list_count python: 1;
current_inventory python: 1.5;
available_inventory python: 1.5;
future_inventory python: 1.5;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowser/macros/check_inventory" />
</tal:block>
</tbody></table>
</body>
</html>
\ No newline at end of file
...@@ -10,6 +10,59 @@ ...@@ -10,6 +10,59 @@
</tr> </tr>
</tal:block> </tal:block>
<!-- Internal macro to apply filter in dialog. -->
<tal:block metal:define-macro="_set_dialog_parameters">
<tal:block tal:condition="select_node_category">
<!-- Select node category in dialog -->
<tr>
<td>select</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_callDialogMethod:method</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:condition="not: select_node_category">
<tr>
<td>assertSelected</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
</tal:block>
<tal:block tal:condition="quantity_unit">
<!-- Select quantity unit in dialog -->
<tr>
<td>select</td>
<td>//select[@name="field_your_quantity_unit"]</td>
<td tal:content='quantity_unit'></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_callDialogMethod:method</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:condition="metric_type">
<!-- Select metric type in dialog -->
<tr>
<td>select</td>
<td>//select[@name="field_your_metric_type"]</td>
<td tal:content='metric_type'></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_callDialogMethod:method</td>
<td></td>
</tr>
</tal:block>
</tal:block>
<!-- <!--
Macro to check inventory displayed in stock browser. Macro to check inventory displayed in stock browser.
...@@ -26,32 +79,19 @@ ...@@ -26,32 +79,19 @@
Optional parameters: Optional parameters:
- select_node_category: if True (the default) the node category will be selected - select_node_category: if True (the default) the node category will be selected
- quantity_unit: the label of the quantity unit to select in dialog, to enable
quantity unit conversion
- metric_type: the label of the metric type to select in dialog, to enable
metric type conversion
--> -->
<tal:block <tal:block
metal:define-macro="check_inventory" metal:define-macro="check_inventory"
tal:define="base_url python: '/' + here.getPortalObject().getId(); tal:define="base_url python: '/' + here.getPortalObject().getId();
select_node_category select_node_category | python: True"> select_node_category select_node_category | python: True;
quantity_unit quantity_unit | python: False;
metric_type metric_type | python: False;">
<tal:block tal:condition="select_node_category"> <tal:block metal:use-macro="here/PdmZuite_checkStockBrowser/macros/_set_dialog_parameters" />
<!-- Select node category in dialog -->
<tr>
<td>select</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_callDialogMethod:method</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:condition="not: select_node_category">
<tr>
<td>assertSelected</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
</tal:block>
<!-- Check inventory --> <!-- Check inventory -->
<tr> <tr>
...@@ -103,26 +143,9 @@ ...@@ -103,26 +143,9 @@
<td></td> <td></td>
</tr> </tr>
<tal:block tal:condition="select_node_category"> <!-- apply dialog parameters again -->
<!-- Select node category in dialog (again) --> <tal:block metal:use-macro="here/PdmZuite_checkStockBrowser/macros/_set_dialog_parameters" />
<tr>
<td>select</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_callDialogMethod:method</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:condition="not: select_node_category">
<tr>
<td>assertSelected</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
</tal:block>
</tal:block> </tal:block>
</tal:block> </tal:block>
</tal:block> </tal:block>
......
...@@ -11,30 +11,120 @@ source_site_title = "erp5_pdm_ui_test_source_site_title" ...@@ -11,30 +11,120 @@ source_site_title = "erp5_pdm_ui_test_source_site_title"
destination_site_id = "erp5_pdm_ui_test_destination_site" destination_site_id = "erp5_pdm_ui_test_destination_site"
destination_site_title = "erp5_pdm_ui_test_destination_site_title" destination_site_title = "erp5_pdm_ui_test_destination_site_title"
quantity_unit_category = portal.portal_categories.quantity_unit
# validate rules # validate rules
for rule in portal.portal_rules.objectValues(): for rule in portal.portal_rules.objectValues():
if rule.getValidationState() != 'validated': if rule.getValidationState() != 'validated':
rule.validate() rule.validate()
# Create resources # create categories
quantity_unit_category = portal.portal_categories.quantity_unit
if getattr(quantity_unit_category, "unit", None) is None: if getattr(quantity_unit_category, "unit", None) is None:
quantity_unit_category.newContent( quantity_unit_category.newContent(
portal_type="Category", portal_type="Category",
id="unit" id="unit",
title="Unit",
)
if getattr(quantity_unit_category.unit, "piece", None) is None:
quantity_unit_category.unit.newContent(
portal_type="Category",
id="piece",
title="Piece",
)
if getattr(quantity_unit_category, "mass", None) is None:
quantity_unit_category.newContent(
portal_type="Category",
id="mass",
title="Mass",
)
if getattr(quantity_unit_category.mass, "kilogram", None) is None:
quantity_unit_category.mass.newContent(
portal_type="Category",
id="kilogram",
title="Kilogram",
)
if getattr(quantity_unit_category.mass, "ton", None) is None:
quantity_unit_category.mass.newContent(
portal_type="Category",
id="ton",
title="Ton",
) )
metric_type_category = portal.portal_categories.metric_type
if getattr(metric_type_category, "unit", None) is None:
metric_type_category.newContent(
portal_type="Category",
id="unit",
title="Unit",
)
if getattr(metric_type_category.unit, "abstract_unit", None) is None:
metric_type_category.unit.newContent(
portal_type="Category",
id="abstract_unit",
title="Abstract Unit",
)
if getattr(metric_type_category, "mass", None) is None:
metric_type_category.newContent(
portal_type="Category",
id="mass",
title="Mass",
)
# create default quantity unit conversion groups
if getattr(portal.quantity_unit_conversion_module, 'unit_conversion_group', None) is None:
portal.quantity_unit_conversion_module.newContent(
portal_type='Quantity Unit Conversion Group',
id='unit_conversion_group',
quantity_unit_value=quantity_unit_category.unit.piece,
).validate()
# XXX we need a 1=1 for unit, because there's no other unit definition in this group
if getattr(portal.quantity_unit_conversion_module.unit_conversion_group, 'unit', None) is None:
portal.quantity_unit_conversion_module.unit_conversion_group.newContent(
portal_type='Quantity Unit Conversion Definition',
id='unit',
quantity_unit_value=quantity_unit_category.unit.piece,
quantity=1,
).validate()
if getattr(portal.quantity_unit_conversion_module, 'mass_conversion_group', None) is None:
portal.quantity_unit_conversion_module.newContent(
portal_type='Quantity Unit Conversion Group',
id='mass_conversion_group',
quantity_unit_value=quantity_unit_category.mass.kilogram,
).validate()
if getattr(portal.quantity_unit_conversion_module.mass_conversion_group, 'ton', None) is None:
portal.quantity_unit_conversion_module.mass_conversion_group.newContent(
portal_type='Quantity Unit Conversion Definition',
id='ton',
quantity_unit_value=quantity_unit_category.mass.ton,
quantity=1000,
).validate()
# unit conversions are cached, so reset cache if we changed them
portal.portal_caches.clearCacheFactory(('erp5_content_long', ))
# Create resources
portal.product_module.newContent( portal.product_module.newContent(
portal_type='Product', portal_type='Product',
id='erp5_pdm_ui_test_product', id='erp5_pdm_ui_test_product',
title='erp5_pdm_ui_test_product_title', title='erp5_pdm_ui_test_product_title',
quantity_unit='unit', quantity_unit_value=quantity_unit_category.unit.piece,
).validate() ).validate()
portal.product_module.erp5_pdm_ui_test_product.newContent(
portal_type='Measure',
metric_type_value=metric_type_category.mass,
quantity_unit_value=quantity_unit_category.mass.kilogram,
quantity=1500,
)
portal.product_module.erp5_pdm_ui_test_product.newContent(
portal_type='Measure',
metric_type_value=metric_type_category.unit.abstract_unit,
quantity_unit_value=quantity_unit_category.unit.piece,
quantity=3,
)
portal.component_module.newContent( portal.component_module.newContent(
portal_type='Component', portal_type='Component',
id='erp5_pdm_ui_test_component', id='erp5_pdm_ui_test_component',
title='erp5_pdm_ui_test_component_title', title='erp5_pdm_ui_test_component_title',
quantity_unit='unit', quantity_unit_value=quantity_unit_category.unit.piece,
).validate() ).validate()
......
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