Commit efadd53b authored by Vincent Pelletier's avatar Vincent Pelletier

Fix Cash Container fast inputs to support multiple pages.

Drop fast input sorting: doesn't work on multiple pages in current implementation, and not scalable if done in MySQL. Instead, provide a way to filter by cash container reference.
Translate error messages.
Stop caching values inside script. To be added back if current code is demonstrated to benefit from it.

Also, factorise forms, fixing divergences:
- always display reception date
- fix price display
- fix quantity display
- always check a start date is set

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38823 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2342f909
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${object_url}/CashMovementNewNotEmitted_viewCashContainerInputDialog</string> </value> <value> <string>string:${object_url}/CashContainer_fastInputForm</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${portal_url}/banking_images/cash_out.png</string> </value> <value> <string>string:${portal_url}/images/cash_out.png</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${object_url}/MonetaryIssue_viewCashContainerInputDialog</string> </value> <value> <string>string:${object_url}/CashContainer_fastInputForm</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${portal_url}/banking_images/cash_out.png</string> </value> <value> <string>string:${portal_url}/images/cash_out.png</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>CashContainer_saveFastInputLine</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>None</string> </value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string>multipart/form-data</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>listbox</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list>
<string>listbox_quantity</string>
<string>listbox_total_price</string>
<string>listbox_selection</string>
</list>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_reference</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>CashContainer_fastInputForm</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>CashContainer_fastInputForm</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Save</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string>CashContainer_fastInputForm</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -346,6 +346,10 @@ ...@@ -346,6 +346,10 @@
<string>cash_number_range_stop</string> <string>cash_number_range_stop</string>
<string>End Number</string> <string>End Number</string>
</tuple> </tuple>
<tuple>
<string>date</string>
<string>Reception Date</string>
</tuple>
<tuple> <tuple>
<string>resource_translated_title</string> <string>resource_translated_title</string>
<string>Denomination</string> <string>Denomination</string>
...@@ -436,7 +440,7 @@ ...@@ -436,7 +440,7 @@
</item> </item>
<item> <item>
<key> <string>lines</string> </key> <key> <string>lines</string> </key>
<value> <int>0</int> </value> <value> <int>20</int> </value>
</item> </item>
<item> <item>
<key> <string>list_action</string> </key> <key> <string>list_action</string> </key>
...@@ -454,6 +458,10 @@ ...@@ -454,6 +458,10 @@
<list/> <list/>
</value> </value>
</item> </item>
<item>
<key> <string>page_template</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>portal_types</string> </key> <key> <string>portal_types</string> </key>
<value> <value>
...@@ -529,18 +537,15 @@ ...@@ -529,18 +537,15 @@
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="Method" module="Products.Formulator.MethodField"/>
<string>Products.Formulator.MethodField</string> <tuple/>
<string>Method</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item> <item>
<key> <string>method_name</string> </key> <key> <string>method_name</string> </key>
<value> <string>ListBox_initializeFastInput</string> </value> <value> <string>ListBox_listCashContainers</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -3,15 +3,21 @@ ...@@ -3,15 +3,21 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<global name="FloatField" module="Products.Formulator.StandardFields"/> <global name="StringField" module="Products.Formulator.StandardFields"/>
<tuple/> <tuple/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>listbox_quantity</string> </value> <value> <string>your_reference</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
...@@ -21,14 +27,14 @@ ...@@ -21,14 +27,14 @@
<key> <string>external_validator_failed</string> </key> <key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value> <value> <string>The input failed the external validator.</string> </value>
</item> </item>
<item>
<key> <string>not_float</string> </key>
<value> <string>You did not enter a floating point number.</string> </value>
</item>
<item> <item>
<key> <string>required_not_found</string> </key> <key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value> <value> <string>Input is required but no input given.</string> </value>
</item> </item>
<item>
<key> <string>too_long</string> </key>
<value> <string>Too much input was given.</string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -81,19 +87,23 @@ ...@@ -81,19 +87,23 @@
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>input_style</string> </key> <key> <string>max_length</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>precision</string> </key> <key> <string>required</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>required</string> </key> <key> <string>title</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
...@@ -152,13 +162,7 @@ ...@@ -152,13 +162,7 @@
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>input_style</string> </key> <key> <string>max_length</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
...@@ -169,6 +173,14 @@ ...@@ -169,6 +173,14 @@
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>whitespace_preserve</string> </key> <key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -186,7 +198,7 @@ ...@@ -186,7 +198,7 @@
</item> </item>
<item> <item>
<key> <string>css_class</string> </key> <key> <string>css_class</string> </key>
<value> <string>figure</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
...@@ -206,7 +218,7 @@ ...@@ -206,7 +218,7 @@
</item> </item>
<item> <item>
<key> <string>editable</string> </key> <key> <string>editable</string> </key>
<value> <int>0</int> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>enabled</string> </key> <key> <string>enabled</string> </key>
...@@ -218,27 +230,31 @@ ...@@ -218,27 +230,31 @@
</item> </item>
<item> <item>
<key> <string>extra</string> </key> <key> <string>extra</string> </key>
<value> <string>align="right"</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>input_style</string> </key> <key> <string>max_length</string> </key>
<value> <string>-1234.5</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>precision</string> </key> <key> <string>required</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>required</string> </key> <key> <string>title</string> </key>
<value> <string>Reference</string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>unicode</string> </key>
<value> <string>Quantity</string> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>whitespace_preserve</string> </key> <key> <string>whitespace_preserve</string> </key>
...@@ -250,23 +266,4 @@ ...@@ -250,23 +266,4 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>string:-1 234.5 | preferences/getPreferredMoneyQuantityStyle</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
...@@ -9,10 +9,22 @@ ...@@ -9,10 +9,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>Script_magic</string> </key> <key> <string>Script_magic</string> </key>
<value> <int>3</int> </value> <value> <int>3</int> </value>
</item> </item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
...@@ -53,9 +65,12 @@ ...@@ -53,9 +65,12 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>return context.Delivery_saveContainerFastInputLine(listbox=listbox,\n <value> <string>portal_type = context.getPortalType()\n
line_portal_type=\'Monetary Issue Line\',\n return context.Delivery_saveContainerFastInputLine(\n
container_line_portal_type=\'Monetary Issue Container\')\n listbox=listbox,\n
line_portal_type=portal_type + \' Line\',\n
container_line_portal_type=portal_type + \' Container\',\n
)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -64,6 +79,18 @@ ...@@ -64,6 +79,18 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>listbox=None, **kw</string> </value> <value> <string>listbox=None, **kw</string> </value>
...@@ -96,6 +123,7 @@ ...@@ -96,6 +123,7 @@
<string>kw</string> <string>kw</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal_type</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -114,7 +142,7 @@ ...@@ -114,7 +142,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>MonetaryIssue_saveFastInputLine</string> </value> <value> <string>CashContainer_saveFastInputLine</string> </value>
</item> </item>
<item> <item>
<key> <string>warnings</string> </key> <key> <string>warnings</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<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_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<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>_body</string> </key>
<value> <string>from DateTime import DateTime\n
\n
\n
container_portal_type_list = ["Monetary Reception",]\n
resource_translated_title_dict = {}\n
base_price_dict = {}\n
total_price_dict = {}\n
\n
if listbox is None:\n
\n
node = context.getSource()\n
if node is None:\n
request = context.REQUEST\n
redirect_url = \'%s/%s?%s\' % ( context.absolute_url()\n
, \'view\'\n
, \'portal_status_message=Please+select+a+source.\'\n
)\n
return request.RESPONSE.redirect( redirect_url )\n
\n
if not \'transit\' in node:\n
request = context.REQUEST\n
redirect_url = \'%s/%s?%s\' % ( context.absolute_url()\n
, \'view\'\n
, \'portal_status_message=Transit+must+be+in+source.\'\n
)\n
return request.RESPONSE.redirect( redirect_url )\n
\n
reference_date = DateTime()\n
container_list = []\n
listbox = []\n
for o in context.portal_simulation.getCurrentTrackingList(at_date= reference_date, node = node):\n
cash_container = o.getObject()\n
\n
if cash_container.getObject().getParentValue().getPortalType() in container_portal_type_list:\n
# get one line in order to know some properties of the cash container\n
container_dict = {}\n
container_lines = cash_container.searchFolder(portal_type=\'Container Line\')\n
if len(container_lines) == 0:\n
continue\n
container_line = container_lines[0].getObject()\n
container_dict[\'reference\'] = cash_container.getReference()\n
container_dict[\'cash_number_range_start\'] = cash_container.getCashNumberRangeStart()\n
container_dict[\'cash_number_range_stop\'] = cash_container.getCashNumberRangeStop()\n
\n
resource = container_line.getResource()\n
base_price = base_price_dict.get(resource, None)\n
if base_price is None:\n
base_price = container_line.getResourceValue().getBasePrice()\n
base_price_dict[resource] = base_price\n
container_dict[\'base_price\'] = base_price\n
resource_translated_title = resource_translated_title_dict.get(resource, None)\n
if resource_translated_title is None:\n
resource_translated_title = container_line.getResourceTranslatedTitle()\n
resource_translated_title_dict[resource] = resource_translated_title\n
container_dict[\'resource_translated_title\'] = resource_translated_title\n
quantity = container_line.getQuantity()\n
container_dict[\'quantity\'] = quantity\n
total_price = total_price_dict.get((quantity,resource), None)\n
if total_price is None:\n
total_price = container_line.getTotalPrice(fast=0)\n
total_price_dict[(quantity,resource)] = total_price \n
container_dict[\'total_price\'] = total_price\n
container_dict[\'selection\'] = 0\n
container_dict[\'date\'] = o.date\n
container_dict[\'uid\'] = \'new_%s\' %(cash_container.getUid(),) #cash_container.getReference().replace(\'/\', \'_\'),)\n
\n
listbox.append(container_dict)\n
\n
def sortListbox(a, b):\n
result = cmp(a["date"], b["date"])\n
if result == 0:\n
result = cmp(a["base_price"], b["base_price"])\n
if result == 0:\n
result = cmp(a["reference"], b["reference"])\n
\n
return result\n
\n
listbox.sort(sortListbox)\n
\n
context.Base_updateDialogForm(listbox=listbox\n
)\n
\n
return context.asContext(context=None\n
, portal_type=context.getPortalType()\n
).CashMovementNewNotEmitted_fastInputForm(**kw)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>listbox=None, cash_detail_dict=None, **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>listbox</string>
<string>cash_detail_dict</string>
<string>kw</string>
<string>DateTime</string>
<string>container_portal_type_list</string>
<string>resource_translated_title_dict</string>
<string>base_price_dict</string>
<string>total_price_dict</string>
<string>None</string>
<string>_getattr_</string>
<string>context</string>
<string>node</string>
<string>request</string>
<string>redirect_url</string>
<string>reference_date</string>
<string>container_list</string>
<string>_getiter_</string>
<string>o</string>
<string>cash_container</string>
<string>container_dict</string>
<string>container_lines</string>
<string>len</string>
<string>_getitem_</string>
<string>container_line</string>
<string>_write_</string>
<string>resource</string>
<string>base_price</string>
<string>resource_translated_title</string>
<string>quantity</string>
<string>total_price</string>
<string>sortListbox</string>
<string>_apply_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>CashMovementNewNotEmitted_viewCashContainerInputDialog</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -9,10 +9,22 @@ ...@@ -9,10 +9,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>Script_magic</string> </key> <key> <string>Script_magic</string> </key>
<value> <int>3</int> </value> <value> <int>3</int> </value>
</item> </item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
...@@ -53,9 +65,58 @@ ...@@ -53,9 +65,58 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>return context.Delivery_saveContainerFastInputLine(listbox=listbox,\n <value> <string>def error(msg):\n
line_portal_type=\'Cash Movement New Not Emitted Line\',\n raise Redirect(\'%s/view?portal_status_message=%s\' % (\n
container_line_portal_type=\'Cash Movement New Not Emitted Container\')\n context.absolute_url(),\n
context.Base_translateString(msg))\n
)\n
\n
node = context.getBaobabSource()\n
if node is None:\n
error(\'Please select a source\')\n
if context.getPortalType() == \'Cash Movement New Not Emitted\' and \'transit\' not in node:\n
error(\'Transit must be in source.\')\n
at_date = context.getStartDate()\n
if at_date is None:\n
error(\'Please register a date.\')\n
\n
tracking_kw = {\n
\'at_date\': at_date,\n
\'node\': node,\n
\'limit_expression\': (int(kw.get(\'list_start\')) or 0, int(kw.get(\'list_lines\')) or 20),\n
}\n
\n
request = context.REQUEST\n
reference = getattr(request, \'your_reference\', None)\n
if reference:\n
tracking_kw[\'reference\'] = reference\n
\n
container_portal_type_set = {\n
\'Monetary Reception\': None,\n
}\n
listbox = []\n
append = listbox.append\n
for o in context.portal_simulation.getCurrentTrackingList(**tracking_kw):\n
cash_container = o.getObject()\n
if cash_container.getParentValue().getPortalType() not in container_portal_type_set:\n
continue\n
container_line_list = cash_container.objectValues(portal_type=\'Container Line\')\n
if len(container_line_list) == 0:\n
# XXX: we should probably raise here instead\n
continue\n
container_line = container_line_list[0]\n
append({\n
\'uid\': \'new_%s\' % (cash_container.getUid(), ),\n
\'reference\': cash_container.getReference(),\n
\'cash_number_range_start\': cash_container.getCashNumberRangeStart(),\n
\'cash_number_range_stop\': cash_container.getCashNumberRangeStop(),\n
\'date\': o.date,\n
\'resource_translated_title\': container_line.getResourceTranslatedTitle(),\n
\'quantity\': container_line.getQuantity(),\n
\'total_price\': container_line.getTotalPrice(fast=0),\n
})\n
context.Base_updateDialogForm(listbox=listbox)\n
return context.ListBox_initializeFastInput()\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -64,9 +125,29 @@ ...@@ -64,9 +125,29 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>listbox=None, **kw</string> </value> <value> <string>*args, **kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -86,16 +167,37 @@ ...@@ -86,16 +167,37 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>1</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>listbox</string> <string>args</string>
<string>kw</string> <string>kw</string>
<string>error</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>node</string>
<string>None</string>
<string>at_date</string>
<string>int</string>
<string>tracking_kw</string>
<string>request</string>
<string>getattr</string>
<string>reference</string>
<string>_write_</string>
<string>container_portal_type_set</string>
<string>listbox</string>
<string>append</string>
<string>_getiter_</string>
<string>_apply_</string>
<string>o</string>
<string>cash_container</string>
<string>container_line_list</string>
<string>len</string>
<string>_getitem_</string>
<string>container_line</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -107,14 +209,12 @@ ...@@ -107,14 +209,12 @@
<item> <item>
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<tuple>
<none/> <none/>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>CashMovementNewNotEmitted_saveFastInputLine</string> </value> <value> <string>ListBox_listCashContainers</string> </value>
</item> </item>
<item> <item>
<key> <string>warnings</string> </key> <key> <string>warnings</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="CheckBoxField" module="Products.Formulator.StandardFields"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_selection</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>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</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>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Selected</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<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_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<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>_body</string> </key>
<value> <string>from DateTime import DateTime\n
\n
container_portal_type_list = ["Monetary Reception",]\n
base_price_dict = {}\n
request = context.REQUEST\n
if context.getStartDate() is None:\n
redirect_url = \'%s/%s?%s\' % ( context.absolute_url()\n
, \'view\'\n
, \'portal_status_message=Please register a date.\'\n
)\n
return request.RESPONSE.redirect( redirect_url )\n
\n
\n
if listbox is None:\n
node = context.getSource()\n
reference_date = context.getStartDate()\n
container_list = []\n
listbox = []\n
#context.log("tracking list", context.portal_simulation.getCurrentTrackingList(at_date= reference_date, node = node))\n
resource_translated_title_dict = {}\n
total_price_dict = {}\n
listbox_append = listbox.append\n
for o in context.portal_simulation.getCurrentTrackingList(at_date= reference_date, node = node):\n
cash_container = o.getObject()\n
\n
if cash_container.getParentValue().getPortalType() in container_portal_type_list:\n
# get one line in order to know some properties of the cash container\n
container_dict = {}\n
container_lines = cash_container.objectValues(portal_type=\'Container Line\')\n
if len(container_lines) == 0:\n
context.log("MonetaryIssue_generateCashContainerInputDialog", "No container line find for cash container %s" %(cash_container.getRelativeUrl(),))\n
continue\n
container_line = container_lines[0]\n
resource = container_line.getResource()\n
container_dict[\'reference\'] = cash_container.getReference()\n
container_dict[\'cash_number_range_start\'] = cash_container.getCashNumberRangeStart()\n
container_dict[\'cash_number_range_stop\'] = cash_container.getCashNumberRangeStop()\n
\n
base_price = base_price_dict.get(resource, None)\n
if base_price is None:\n
base_price = container_line.getResourceValue().getBasePrice()\n
base_price_dict[resource] = base_price\n
container_dict[\'base_price\'] = base_price\n
\n
resource_translated_title = resource_translated_title_dict.get(resource, None)\n
if resource_translated_title is None:\n
resource_translated_title = container_line.getResourceTranslatedTitle()\n
resource_translated_title_dict[resource] = resource_translated_title\n
container_dict[\'resource_translated_title\'] = resource_translated_title\n
quantity = container_line.getQuantity()\n
container_dict[\'quantity\'] = quantity\n
total_price = total_price_dict.get((quantity,resource), None)\n
if total_price is None:\n
total_price = container_line.getTotalPrice(fast=0)\n
total_price_dict[(quantity,resource)] = total_price\n
container_dict[\'total_price\'] = total_price\n
container_dict[\'selection\'] = 0\n
container_dict[\'date\'] = o.date\n
container_dict[\'uid\'] = \'new_%s\' %(cash_container.getUid(),) #cash_container.getReference().replace(\'/\', \'_\'),)\n
\n
listbox_append(container_dict)\n
\n
def sortListbox(a, b):\n
result = cmp(a["date"], b["date"])\n
if result == 0:\n
result = cmp(a["base_price"], b["base_price"])\n
if result == 0:\n
result = cmp(a["reference"], b["reference"])\n
\n
return result\n
\n
listbox.sort(sortListbox)\n
context.Base_updateDialogForm(listbox=listbox\n
)\n
\n
return context.asContext(context=None\n
, portal_type=context.getPortalType()\n
).MonetaryIssue_fastInputForm(**kw)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>listbox=None, cash_detail_dict=None, **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>listbox</string>
<string>cash_detail_dict</string>
<string>kw</string>
<string>DateTime</string>
<string>container_portal_type_list</string>
<string>base_price_dict</string>
<string>_getattr_</string>
<string>context</string>
<string>request</string>
<string>None</string>
<string>redirect_url</string>
<string>node</string>
<string>reference_date</string>
<string>container_list</string>
<string>resource_translated_title_dict</string>
<string>total_price_dict</string>
<string>listbox_append</string>
<string>_getiter_</string>
<string>o</string>
<string>cash_container</string>
<string>container_dict</string>
<string>container_lines</string>
<string>len</string>
<string>_getitem_</string>
<string>container_line</string>
<string>resource</string>
<string>_write_</string>
<string>base_price</string>
<string>resource_translated_title</string>
<string>quantity</string>
<string>total_price</string>
<string>sortListbox</string>
<string>_apply_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>MonetaryIssue_viewCashContainerInputDialog</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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