Commit a3ac185f authored by Nicolas Delaby's avatar Nicolas Delaby

* Call global method from portal itself to avoid acquisition lookup

* Do not translate Strings with variable replacement (%s)
* rename some variable according naming convention

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40181 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7fcd6fe4
......@@ -60,45 +60,47 @@
product\n
"""\n
no_inventory = False\n
portal = context.getPortalObject()\n
Base_translateString = portal.Base_translateString\n
\n
# Retrieve lines portal type\n
line_portal_type_list = [x for x in context.getTypeInfo().getTypeAllowedContentTypeList() \\\n
if x in context.getPortalMovementTypeList()]\n
if x in portal.getPortalMovementTypeList()]\n
line_portal_type = line_portal_type_list[0]\n
\n
if line_portal_type in context.getPortalSaleTypeList():\n
if line_portal_type in portal.getPortalSaleTypeList():\n
section_uid = context.getSourceSectionUid()\n
supply_cell_portal_type = "Sale Supply Cell"\n
supply_line_id = "default_ssl"\n
use_list = context.portal_preferences.getPreferredSaleUseList()\n
elif line_portal_type in context.getPortalPurchaseTypeList():\n
use_list = portal.portal_preferences.getPreferredSaleUseList()\n
elif line_portal_type in portal.getPortalPurchaseTypeList():\n
section_uid = context.getDestinationSectionUid()\n
supply_cell_portal_type = "Purchase Supply Cell"\n
supply_line_id = "default_psl"\n
use_list = context.portal_preferences.getPreferredPurchaseUseList()\n
elif line_portal_type in context.getPortalInternalTypeList():\n
use_list = portal.portal_preferences.getPreferredPurchaseUseList()\n
elif line_portal_type in portal.getPortalInternalTypeList():\n
section_uid = None\n
supply_line_id = "default_isl"\n
supply_cell_portal_type = "Internal Supply Cell"\n
use_list = context.portal_preferences.getPreferredPurchaseUseList() \\\n
+ context.portal_preferences.getPreferredSaleUseList()\n
elif line_portal_type in context.getPortalInventoryMovementTypeList():\n
use_list = portal.portal_preferences.getPreferredPurchaseUseList() \\\n
+ portal.portal_preferences.getPreferredSaleUseList()\n
elif line_portal_type in portal.getPortalInventoryMovementTypeList():\n
section_uid = None\n
no_inventory = True\n
use_list = context.portal_preferences.getPreferredPurchaseUseList() \\\n
+ context.portal_preferences.getPreferredSaleUseList()\n
use_list = portal.portal_preferences.getPreferredPurchaseUseList() \\\n
+ portal.portal_preferences.getPreferredSaleUseList()\n
else:\n
from Products.ERP5Type.Message import translateString\n
message = \'Type of document not known to supply cell type.\'\n
return context.Base_redirect(\'view\', keep_items=dict(\n
portal_status_message=translateString(\'Type of document not known to supply cell type.\')))\n
portal_status_message=Base_translateString(message)))\n
\n
request= context.REQUEST\n
portal = context.getPortalObject()\n
Base_translateString = portal.Base_translateString\n
\n
total_price = 0.0\n
status_message = ""\n
status_message_list = []\n
\n
for line in listbox:\n
if line.has_key(\'listbox_key\') and (line[\'title\'] not in (\'\', None)\n
if \'listbox_key\' in line and (line[\'title\'] not in (\'\', None)\n
or line[\'reference\'] not in (\'\', None)\n
or line.get(\'resource_relative_url\', None) not in (\'\', None)):\n
line_id = line[\'listbox_key\']\n
......@@ -109,25 +111,29 @@ for line in listbox:\n
request.form["field_listbox_title_new_%s"%line_id] = line["title"]\n
\n
# Retrieve the resource\n
if line.get(\'resource_relative_url\', None) not in (None, ""):\n
product = portal.restrictedTraverse(line[\'resource_relative_url\'])\n
resource_relative_url = line.get(\'resource_relative_url\')\n
if resource_relative_url:\n
product = portal.restrictedTraverse(resource_relative_url)\n
else:\n
product_list = list(context.portal_catalog(portal_type=[\'Product\',\'Service\'],\n
title=line[\'title\'],\n
default_use_uid=[context.portal_categories.resolveCategory(use).getUid()\n
for use in use_list],\n
reference=line[\'reference\']))\n
continue\n
use_uid_list = [portal.portal_categories.resolveCategory(use).getUid()\n
for use in use_list]\n
product_list = portal.portal_catalog(\n
portal_type=portal.getPortalResourceTypeList(),\n
title=line[\'title\'],\n
default_use_uid=use_uid_list,\n
reference=line[\'reference\'])\n
if len(product_list) != 1:\n
continue\n
else:\n
product = product_list[0].getObject()\n
\n
\n
# Resource part\n
line["resource_relative_url"] = product.getRelativeUrl() #cell.getResource()\n
request.set("field_listbox_resource_relative_url_new_%s"%line_id,product.getRelativeUrl())\n
\n
request.form["field_listbox_quantity_unit_new_%s"%line_id] = product.getQuantityUnit()\n
variation = request.form["field_listbox_variation_category_list_new_%s"%line_id] = line[\'variation_category_list\']\n
variation_list = line[\'variation_category_list\']\n
\n
# Part for fast input wich checks inventory value\n
if no_inventory is False:\n
......@@ -136,7 +142,7 @@ for line in listbox:\n
if line["quantity"] in (None, ""):\n
line["quantity"] = 0.0\n
if line[\'price\'] in (None,""):\n
if len(variation):\n
if variation_list:\n
# Retrieve the price from the cell\n
# if we have variation defined\n
try:\n
......@@ -145,7 +151,7 @@ for line in listbox:\n
# No price defined\n
supply_cell_list = []\n
for supply_cell in supply_cell_list:\n
if supply_cell.getVariationCategoryList() == variation:\n
if supply_cell.getVariationCategoryList() == variation_list:\n
line[\'price\'] = supply_cell.getBasePrice() or 0\n
line["total_price"] = line[\'quantity\'] * line[\'price\']\n
break\n
......@@ -169,18 +175,18 @@ for line in listbox:\n
total_price +=line[\'total_price\']\n
\n
# Part for products\n
if product.getPortalType()==\'Product\':\n
if product.getPortalType() in portal.getPortalProductTypeList():\n
# Inventory part\n
if len(variation):\n
if variation_list:\n
available_inv = request.form["field_listbox_available_quantity_new_%s"%line_id] = product.getAvailableInventory(\n
section_uid=section_uid,\n
variation_text=\'variation/%s\'%variation)\n
variation_text=variation_list)\n
request.form[\'field_listbox_inventory_new_%s\'%line_id] = product.getInventory(\n
section_uid=section_uid,\n
variation_text=\'variation/%s\'%variation)\n
variation_text=variation_list)\n
request.form["field_listbox_current_quantity_new_%s"%line_id] = product.getCurrentInventory(\n
section_uid=section_uid,\n
variation_text=\'variation/%s\'%variation)\n
variation_text=variation_list)\n
else:\n
available_inv = request.form["field_listbox_available_quantity_new_%s"%line_id] = product.getAvailableInventory(section_uid=section_uid)\n
request.form[\'field_listbox_inventory_new_%s\'%line_id] = product.getInventory(section_uid=section_uid)\n
......@@ -188,12 +194,16 @@ for line in listbox:\n
\n
# Check if quantity is available\n
if available_inv < line["quantity"]:\n
status_message += "%s -- " %(Base_translateString(\'Quantity Asked For Line %s : %s - %s Not Available In Inventory\'%(line[\'listbox_key\'],\n
product.getTitle(),\n
product.getReference())))\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 len(status_message):\n
request.set(\'portal_status_message\', status_message)\n
if status_message_list:\n
request.set(\'portal_status_message\', \' -- \'.join(status_message_list))\n
\n
request.form["field_my_total_price"] = total_price\n
context.Base_updateDialogForm(listbox=listbox,update=1,kw=kw)\n
......@@ -240,11 +250,13 @@ return getattr(context, request.form[\'dialog_id\'])(listbox=listbox, kw=kw)\n
<string>kw</string>
<string>False</string>
<string>no_inventory</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>Base_translateString</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>_getattr_</string>
<string>context</string>
<string>x</string>
<string>line_portal_type_list</string>
<string>_getitem_</string>
......@@ -255,29 +267,28 @@ return getattr(context, request.form[\'dialog_id\'])(listbox=listbox, kw=kw)\n
<string>use_list</string>
<string>None</string>
<string>True</string>
<string>Products.ERP5Type.Message</string>
<string>translateString</string>
<string>message</string>
<string>dict</string>
<string>request</string>
<string>portal</string>
<string>Base_translateString</string>
<string>total_price</string>
<string>status_message</string>
<string>status_message_list</string>
<string>line</string>
<string>line_id</string>
<string>product</string>
<string>_write_</string>
<string>list</string>
<string>resource_relative_url</string>
<string>use</string>
<string>use_uid_list</string>
<string>product_list</string>
<string>len</string>
<string>variation</string>
<string>variation_list</string>
<string>supply_cell_list</string>
<string>KeyError</string>
<string>supply_cell</string>
<string>supply_line</string>
<string>_inplacevar_</string>
<string>available_inv</string>
<string>mapping</string>
<string>getattr</string>
</tuple>
</value>
......
1024
\ No newline at end of file
1026
\ 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