[Erp5-report] r40807 nicolas - in /erp5/trunk/bt5/erp5_trade: SkinTemplateItem/portal_skins...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Nov 26 18:58:27 CET 2010


Author: nicolas
Date: Fri Nov 26 18:58:25 2010
New Revision: 40807

URL: http://svn.erp5.org?rev=40807&view=rev
Log:
Improve portal_status_message, by grouping listbox line ids per resource,
to produce a message like :
Asked quantity of "Resource Title - Resource Reference" is not available in inventory for lines 1, 2, 4, 5, 6
instead of 5 messages

Modified:
    erp5/trunk/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Delivery_updateFastInputLineList.xml
    erp5/trunk/bt5/erp5_trade/bt/revision

Modified: erp5/trunk/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Delivery_updateFastInputLineList.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Delivery_updateFastInputLineList.xml?rev=40807&r1=40806&r2=40807&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Delivery_updateFastInputLineList.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Delivery_updateFastInputLineList.xml [utf8] Fri Nov 26 18:58:25 2010
@@ -97,7 +97,7 @@ else:\n
 request= context.REQUEST\n
 \n
 total_price = 0.0\n
-status_message_list = []\n
+status_message_dict = {}\n
 \n
 for line in listbox:\n
   if \'listbox_key\' in line and (line[\'title\'] not in (\'\', None)\n
@@ -193,15 +193,22 @@ for line in listbox:\n
 \n
         # Check if quantity is available\n
         if available_inv < line["quantity"]:\n
-          message = \'Quantity Asked For Line ${line_id} : ${product_title}\'\\\n
-                    \'- ${product_reference} Not Available In Inventory\'\n
-          mapping = {\'line_id\': line[\'listbox_key\'],\n
-                     \'product_title\': product.getTitle(\'\'),\n
-                     \'product_reference\': product.getReference(\'\')}\n
-          status_message_list.append(Base_translateString(message,\n
-                                                          mapping=mapping))\n
-\n
-if status_message_list:\n
+          status_message_dict.setdefault(product.getRelativeUrl(), []).append(line[\'listbox_key\'])\n
+          \n
+status_message_list = []\n
+if status_message_dict:\n
+  for product_relative_url, line_id_list in status_message_dict.items():\n
+    product = portal.restrictedTraverse(product_relative_url)\n
+    mapping = {\'product_title\': product.getTitle(\'\'),\n
+               \'product_reference\': product.getReference(\'\')}\n
+    if len(line_id_list) > 1:\n
+      line_id_list.sort()\n
+      message = \'Asked quantity of "${product_title} - ${product_reference}" is not available in inventory for lines ${line_id}\'\n
+      mapping[\'line_id\'] = \', \'.join(line_id_list)\n
+    else:\n
+      message = \'Asked quantity of "${product_title} - ${product_reference}" is not available in inventory for line ${line_id}\'\n
+      mapping[\'line_id\'] = line_id_list[0]\n
+    status_message_list.append(Base_translateString(message, mapping=mapping))\n
   request.set(\'portal_status_message\', \' -- \'.join(status_message_list))\n
 \n
 request.form["field_my_total_price"] = total_price\n
@@ -270,7 +277,7 @@ return getattr(context, request.form[\'d
                             <string>dict</string>
                             <string>request</string>
                             <string>total_price</string>
-                            <string>status_message_list</string>
+                            <string>status_message_dict</string>
                             <string>line</string>
                             <string>line_id</string>
                             <string>product</string>
@@ -287,6 +294,9 @@ return getattr(context, request.form[\'d
                             <string>supply_line</string>
                             <string>_inplacevar_</string>
                             <string>available_inv</string>
+                            <string>status_message_list</string>
+                            <string>product_relative_url</string>
+                            <string>line_id_list</string>
                             <string>mapping</string>
                             <string>getattr</string>
                           </tuple>

Modified: erp5/trunk/bt5/erp5_trade/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_trade/bt/revision?rev=40807&r1=40806&r2=40807&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_trade/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_trade/bt/revision [utf8] Fri Nov 26 18:58:25 2010
@@ -1 +1 @@
-1048
\ No newline at end of file
+1049
\ No newline at end of file




More information about the Erp5-report mailing list