Commit 4d102bfc authored by Mame Coumba Sall's avatar Mame Coumba Sall

2008-12-31 mame

* Modified fast input to add total price of sale order lines, quantity_unit , title and variation in listbox. Also, fast input now displays sale order lines already added so that we can directly updates them on the fast input

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24997 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1aed5df4
...@@ -53,15 +53,35 @@ ...@@ -53,15 +53,35 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Document import newTempBase\n <value> <string>"""\n
This script creates a list of empty lines when called for\n
the first time.When called the next time, it displays on \n
the fast input all sale order lines already added and \n
updates them based on fast input entries.\n
"""\n
from Products.ERP5Type.Document import newTempBase\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
request = context.REQUEST\n
listbox = getattr(request, \'listbox\', None) \n
\n \n
result = []\n result = []\n
line_list = context.contentValues(portal_type=\'Sale Order Line\')\n
\n \n
for i in range(lines_num):\n len_line_list = len(line_list)\n
obj = newTempBase(portal, id="tmp_item_%s" % i, uid="tmp_item_%s" % i)\n if len(line_list)!=0:\n
result.append(obj)\n for line in line_list:\n
\n obj = newTempBase(portal, id="tmp_item_%s" % line.getId(), uid="tmp_item_%s" % line.getId()) \n
obj.edit(title=line.getResourceTitle(),\n
quantity=line.getQuantity(),\n
quantity_unit=line.getQuantityUnit(),\n
total_price=line.getTotalPrice(),\n
getAvailableInventory=line.getResourceValue().getAvailableInventory(),\n
getCurrentInventory=line.getResourceValue().getCurrentInventory(),\n
inventory=line.getResourceValue().getInventory())\n
result.append(obj)\n
for i in range(len_line_list+1,lines_num+1):\n
obj = newTempBase(portal, id="tmp_item_%s" % i, uid="tmp_item_%s" % i)\n
result.append(obj)\n
return result\n return result\n
</string> </value> </string> </value>
</item> </item>
...@@ -106,11 +126,19 @@ return result\n ...@@ -106,11 +126,19 @@ return result\n
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal</string> <string>portal</string>
<string>request</string>
<string>getattr</string>
<string>None</string>
<string>listbox</string>
<string>result</string> <string>result</string>
<string>line_list</string>
<string>len</string>
<string>len_line_list</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>line</string>
<string>obj</string>
<string>range</string> <string>range</string>
<string>i</string> <string>i</string>
<string>obj</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -53,25 +53,53 @@ ...@@ -53,25 +53,53 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>result_list = []\n <value> <string>"""\n
This script creates or updates sale order lines based on the fast \n
input information.It should take into account any sale order line \n
which were already created so that they are not duplicated.\n
"""\n
result_list = []\n
sale_order_line_list = context.contentValues(portal_type=\'Sale Order Line\')\n
if sale_order_line_list!=[]:\n
sale_order_line_id_list = [x.getId() for x in sale_order_line_list]\n
for line in listbox:\n for line in listbox:\n
if line.has_key(\'listbox_key\') and line[\'reference\'] not in (\'\', None):\n #for each line in listbox if line has a reference defined, search \n
product_list = [x.getObject() for x in context.portal_catalog(portal_type=\'Product\',\n #for the product whose reference has been entered\n
if line.has_key(\'listbox_key\') and line[\'reference\'] not in (\'\', None):\n
line_id = line[\'listbox_key\'].split(\'/erp5/tmp_item_\')[1]\n
product_list = [x.getObject() for x in context.portal_catalog(\n
portal_type=\'Product\',\n
reference=line[\'reference\'])]\n reference=line[\'reference\'])]\n
product = product_list[0]\n product = product_list[0]\n
sale_order_line= context.newContent(\n #for each sale order line already added,\n
#if the line\'s id is the same as the sale order line, update it\n
for sale_order_line in sale_order_line_list:\n
if sale_order_line.getId()==line_id:\n
sale_order_line.edit(start_date=context.getStartDate(),\n
stop_date=context.getStopDate(),\n
resource_title=product.getTitle(),\n
price_currency = context.getPriceCurrency(),\n
quantity = line["quantity"],\n
quantity_unit = product.getQuantityUnit(),)\n
sale_order_line.setResourceValue(product)\n
result_list.append(sale_order_line)\n
else:\n
# if there was no sale order line already defined\n
# for the sale order, add a new sale order line\n
if len(sale_order_line_list)==0 or line_id not in sale_order_line_id_list:\n
sale_order_line= context.newContent(\n
portal_type=\'Sale Order Line\',)\n portal_type=\'Sale Order Line\',)\n
sale_order_line.edit(\n sale_order_line.edit(\n
start_date=context.getStartDate(),\n start_date=context.getStartDate(),\n
stop_dat=context.getStopDate(),\n stop_date=context.getStopDate(),\n
resource_title=product.getTitle(),\n resource_title=product.getTitle(),\n
total_price = line[\'total_price\'],\n
price_currency = context.getPriceCurrency(),\n price_currency = context.getPriceCurrency(),\n
quantity = line["quantity"],\n quantity = line["quantity"],\n
quantity_unit = product.getQuantityUnit(),)\n quantity_unit = product.getQuantityUnit(),)\n
sale_order_line.setResourceValue(product)\n sale_order_line.setResourceValue(product)\n
result_list.append(sale_order_line)\n result_list.append(sale_order_line)\n
\n \n
#return to the feature module\n
context.REQUEST.response.redirect(\n context.REQUEST.response.redirect(\n
\'%s/view?portal_status_message=%s\' % (context.absolute_url(), \'Sale Order Lines created.\'.replace(\' \', \'%20\')))\n \'%s/view?portal_status_message=%s\' % (context.absolute_url(), \'Sale Order Lines created.\'.replace(\' \', \'%20\')))\n
</string> </value> </string> </value>
...@@ -113,18 +141,22 @@ context.REQUEST.response.redirect(\n ...@@ -113,18 +141,22 @@ context.REQUEST.response.redirect(\n
<string>listbox</string> <string>listbox</string>
<string>kw</string> <string>kw</string>
<string>result_list</string> <string>result_list</string>
<string>_getiter_</string>
<string>line</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>_getitem_</string> <string>context</string>
<string>None</string> <string>sale_order_line_list</string>
<string>append</string> <string>append</string>
<string>$append0</string> <string>$append0</string>
<string>context</string> <string>_getiter_</string>
<string>x</string> <string>x</string>
<string>sale_order_line_id_list</string>
<string>line</string>
<string>_getitem_</string>
<string>None</string>
<string>line_id</string>
<string>product_list</string> <string>product_list</string>
<string>product</string> <string>product</string>
<string>sale_order_line</string> <string>sale_order_line</string>
<string>len</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -53,30 +53,49 @@ ...@@ -53,30 +53,49 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string encoding="cdata"><![CDATA[
"""\n
This script just returns what the user entered in\n This script just returns what the user entered in\n
the fast input form.\n the fast input form, searches for the product whose\n
reference or title has been just entered and updates\n
the total price and the stock corresponding to the \n
product\n
"""\n """\n
request = context.REQUEST\n request = context.REQUEST\n
\n portal = context.getPortalObject()\n
Base_translateString = portal.Base_translateString\n
total_price = 0.0\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
for line in listbox:\n for line in listbox:\n
if line.has_key(\'listbox_key\') and line[\'reference\'] not in (\'\', None):\n if line.has_key(\'listbox_key\') and (line[\'title\'] or line[\'reference\'] not in (\'\', None)):\n
product_list = context.portal_catalog(portal_type=\'Product\',\n product_list = context.portal_catalog(portal_type=\'Product\',\n
title=line[\'title\'],\n
reference=line[\'reference\'])\n reference=line[\'reference\'])\n
product = product_list[0]\n product = product_list[0]\n
line[\'getAvailableInventory\'] = product.getAvailableInventory()\n if line[\'quantity\'] <= product.getAvailableInventory():\n
line["inventory"] = product.getInventory()\n line_id = line[\'listbox_key\'].split(\'/erp5/\')[1]\n
inventory = line["inventory"]\n line["total_price"] = line[\'quantity\'] * product.getPrice()\n
line_id = line[\'listbox_key\'].split(\'/erp5/\')[1]\n line["quantity_unit"] = product.getQuantityUnit()\n
line["total_price"] = line[\'quantity\'] * product.getPrice()\n request.form["field_listbox_reference_%s"%line_id] = product.getReference()\n
request.form["field_listbox_total_price_%s"%line_id] = line[\'quantity\'] * product.getPrice()\n request.form["field_listbox_title_%s"%line_id] = product.getTitle()\n
request.form["field_listbox_getAvailableInventory_%s"%line_id] = product.getAvailableInventory()\n request.form["field_listbox_total_price_%s"%line_id] = line[\'quantity\'] * product.getPrice()\n
request.form[\'field_listbox_inventory_%s\'%line_id] = product.getInventory()\n request.form["field_listbox_quantity_unit_%s"%line_id] = product.getQuantityUnit()\n
request.form["field_listbox_getCurrentInventory_%s"%line_id] = product.getCurrentInventory()\n request.form["field_listbox_getAvailableInventory_%s"%line_id] = product.getAvailableInventory()\n
request.form[\'field_listbox_inventory_%s\'%line_id] = product.getInventory()\n
request.form["field_listbox_getCurrentInventory_%s"%line_id] = product.getCurrentInventory()\n
request.form["field_listbox_variation_category_item_list_%s"%line_id] =\\\n
[x[0] for x in product.getVariationCategoryItemList()]\n
total_price +=line[\'total_price\']\n
request.form["field_my_total_price"] = total_price\n
else:\n
request.set(\'portal_status_message\', Base_translateString(\'Quantity Asked Not Available In Inventory\')) \n
\n
context.Base_updateDialogForm(listbox=listbox,update=1,kw=kw)\n context.Base_updateDialogForm(listbox=listbox,update=1,kw=kw)\n
return context.SaleOrder_viewSaleOrderFastInputDialog(listbox=listbox,**kw)\n return context.SaleOrder_viewSaleOrderFastInputDialog(listbox=listbox,**kw)\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -118,15 +137,20 @@ return context.SaleOrder_viewSaleOrderFastInputDialog(listbox=listbox,**kw)\n ...@@ -118,15 +137,20 @@ return context.SaleOrder_viewSaleOrderFastInputDialog(listbox=listbox,**kw)\n
<string>context</string> <string>context</string>
<string>request</string> <string>request</string>
<string>portal</string> <string>portal</string>
<string>Base_translateString</string>
<string>total_price</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>line</string> <string>line</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>None</string> <string>None</string>
<string>product_list</string> <string>product_list</string>
<string>product</string> <string>product</string>
<string>_write_</string>
<string>inventory</string>
<string>line_id</string> <string>line_id</string>
<string>_write_</string>
<string>append</string>
<string>$append0</string>
<string>x</string>
<string>_inplacevar_</string>
<string>_apply_</string> <string>_apply_</string>
</tuple> </tuple>
</value> </value>
......
...@@ -99,13 +99,18 @@ ...@@ -99,13 +99,18 @@
<string>listbox_getAvailableInventory</string> <string>listbox_getAvailableInventory</string>
<string>listbox_getCurrentInventory</string> <string>listbox_getCurrentInventory</string>
<string>listbox_inventory</string> <string>listbox_inventory</string>
<string>listbox_variation_category_item_list</string>
<string>listbox_title</string>
<string>listbox_quantity_unit</string>
</list> </list>
</value> </value>
</item> </item>
<item> <item>
<key> <string>left</string> </key> <key> <string>left</string> </key>
<value> <value>
<list/> <list>
<string>my_total_price</string>
</list>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -326,14 +326,26 @@ ...@@ -326,14 +326,26 @@
<key> <string>all_columns</string> </key> <key> <string>all_columns</string> </key>
<value> <value>
<list> <list>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple> <tuple>
<string>reference</string> <string>reference</string>
<string>Reference</string> <string>Reference</string>
</tuple> </tuple>
<tuple>
<string>variation_category_item_list</string>
<string>Variation</string>
</tuple>
<tuple> <tuple>
<string>quantity</string> <string>quantity</string>
<string>Quantity</string> <string>Quantity</string>
</tuple> </tuple>
<tuple>
<string>quantity_unit</string>
<string>Quantity Unit</string>
</tuple>
<tuple> <tuple>
<string>total_price</string> <string>total_price</string>
<string>Total Price</string> <string>Total Price</string>
...@@ -365,14 +377,26 @@ ...@@ -365,14 +377,26 @@
<key> <string>columns</string> </key> <key> <string>columns</string> </key>
<value> <value>
<list> <list>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple> <tuple>
<string>reference</string> <string>reference</string>
<string>Reference</string> <string>Reference</string>
</tuple> </tuple>
<tuple>
<string>variation_category_item_list</string>
<string>Variation</string>
</tuple>
<tuple> <tuple>
<string>quantity</string> <string>quantity</string>
<string>Quantity</string> <string>Quantity</string>
</tuple> </tuple>
<tuple>
<string>quantity_unit</string>
<string>Quantity Unit</string>
</tuple>
<tuple> <tuple>
<string>total_price</string> <string>total_price</string>
<string>Total Price</string> <string>Total Price</string>
...@@ -428,14 +452,26 @@ ...@@ -428,14 +452,26 @@
<key> <string>editable_columns</string> </key> <key> <string>editable_columns</string> </key>
<value> <value>
<list> <list>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple> <tuple>
<string>reference</string> <string>reference</string>
<string>Reference</string> <string>Reference</string>
</tuple> </tuple>
<tuple>
<string>variation_category_item_list</string>
<string>Variation</string>
</tuple>
<tuple> <tuple>
<string>quantity</string> <string>quantity</string>
<string>Quantity</string> <string>Quantity</string>
</tuple> </tuple>
<tuple>
<string>quantity_unit</string>
<string>Quantity Unit</string>
</tuple>
<tuple> <tuple>
<string>total_price</string> <string>total_price</string>
<string>Total Price</string> <string>Total Price</string>
...@@ -521,6 +557,10 @@ ...@@ -521,6 +557,10 @@
<key> <string>search_columns</string> </key> <key> <string>search_columns</string> </key>
<value> <value>
<list> <list>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple> <tuple>
<string>reference</string> <string>reference</string>
<string>Reference</string> <string>Reference</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_title</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>extra_context</string> </key>
<value> <string></string> </value>
</item>
<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>extra_context</string> </key>
<value> <string></string> </value>
</item>
<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>extra_context</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_title</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>OrderLine_viewFieldLibrary</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>precision</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_total_price</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>precision</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</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_total_price</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>OrderLine_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
556 557
\ No newline at end of file \ No newline at end of file
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