Commit adb81c42 authored by Romain Courteaud's avatar Romain Courteaud

Explicitely generate Purchase Packing List parameter.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42514 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0e4828e8
......@@ -52,36 +52,13 @@
<key> <string>_body</string> </key>
<value> <string>"""Add selected product to the cart and continue"""\n
portal = context.getPortalObject()\n
prefered_resource = portal.portal_preferences.getPreferredInstanceSetupResource()\n
service = portal.restrictedTraverse(prefered_resource)\n
\n
##Get item list\n
item_list = []\n
if uids:\n
item_list = [item.getObject() for item in portal.portal_catalog(uid=uids, portal_type="Software Product")]\n
\n
if len(item_list) != 1:\n
if len(uids) != 1:\n
return context.Base_redirect(dialog_id,\n
keep_items={\'portal_status_message\':context.Base_translateString("Please select one service.")})\n
\n
\n
shopping_cart = context.SaleOrder_getShoppingCart()\n
shopping_cart_items = context.SaleOrder_getShoppingCartItemList()\n
\n
item = item_list[0]\n
\n
if len(shopping_cart_items) != 1:\n
raise NotImplementedError, "There should be only one shopping card item."\n
\n
product_url = item.getRelativeUrl()\n
\n
order_line = shopping_cart_items[0]\n
order_line.edit(\n
aggregate_list=order_line.getAggregateList() + [product_url],\n
)\n
\n
##Set connected member as shopping cart customer\n
context.SaleOrder_setShoppingCartCustomer()\n
else:\n
session = context.WebSection_getVifibSession()\n
session[\'instance_software_product_uid\'] = uids[0]\n
\n
if kw.has_key(\'came_from\'):\n
#we override the context to redirect the user to the next web section\n
......@@ -131,19 +108,10 @@ context.WebSection_viewNextStep()\n
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>prefered_resource</string>
<string>service</string>
<string>item_list</string>
<string>$list0</string>
<string>_getiter_</string>
<string>item</string>
<string>len</string>
<string>shopping_cart</string>
<string>shopping_cart_items</string>
<string>session</string>
<string>_getitem_</string>
<string>NotImplementedError</string>
<string>product_url</string>
<string>order_line</string>
<string>_write_</string>
</tuple>
</value>
</item>
......
......@@ -59,21 +59,8 @@ service = portal.restrictedTraverse(prefered_resource)\n
if context.getPortalType() != "Computer":\n
raise NotImplementedError, "Should be called on a Computer"\n
\n
##Reset the cart and get new shopping cart\n
if reset_shopping_cart:\n
context.SaleOrder_getShoppingCart(action=\'reset\')\n
\n
shopping_cart = context.SaleOrder_getShoppingCart()\n
\n
## new Resource so add it to shopping cart\n
order_line = shopping_cart.newContent(portal_type=\'Sale Order Line\',\n
quantity=1,\n
resource=prefered_resource,\n
price=50,\n
aggregate_list=[context.getRelativeUrl()])\n
\n
##Set connected member as shopping cart customer\n
context.SaleOrder_setShoppingCartCustomer()\n
session = context.WebSection_getVifibSession()\n
session[\'computer_uid\'] = context.getUid()\n
\n
web_section = context.getWebSectionValue()\n
return web_section.Base_redirect(\'install-a-software\', keep_items={\'editable_mode\': 0})\n
......@@ -124,8 +111,8 @@ return web_section.Base_redirect(\'install-a-software\', keep_items={\'editable_
<string>prefered_resource</string>
<string>service</string>
<string>NotImplementedError</string>
<string>shopping_cart</string>
<string>order_line</string>
<string>session</string>
<string>_write_</string>
<string>web_section</string>
</tuple>
</value>
......
......@@ -52,9 +52,11 @@
<key> <string>_body</string> </key>
<value> <string>"""Add selected product to the cart and continue"""\n
portal = context.getPortalObject()\n
prefered_resource = portal.portal_preferences.getPreferredInstanceSetupResource()\n
prefered_resource = portal.portal_preferences.getPreferredSoftwareSetupResource()\n
service = portal.restrictedTraverse(prefered_resource)\n
\n
session = context.WebSection_getVifibSession()\n
\n
##Get item list\n
item_list = []\n
if uids:\n
......@@ -64,43 +66,46 @@ if len(item_list) != 1:\n
return context.Base_redirect(dialog_id,\n
keep_items={\'portal_status_message\':context.Base_translateString("Please select one software release.")})\n
\n
shopping_cart = context.SaleOrder_getShoppingCart()\n
shopping_cart_items = context.SaleOrder_getShoppingCartItemList()\n
\n
# Assert that there is only one shopping cart items\n
if len(shopping_cart_items) != 1:\n
raise NotImplementedError, "There should be only one shopping cart item."\n
\n
item = item_list[0]\n
product_url = item.getAggregate()\n
## check if we don\'t have already such a resource in cart\n
line_found=False\n
for order_line in shopping_cart_items:\n
if product_url in order_line.getAggregateList():\n
line_found=True\n
order_line.edit(aggregate_value_list=order_line.getAggregateList() + [item.getRelativeUrl()])\n
break\n
# XXX Check that release is associate to product\n
\n
computer = portal.portal_catalog.getResultValue(\n
uid=session[\'computer_uid\'],\n
portal_type="Computer",\n
)\n
\n
if not line_found:\n
raise NotImplementedError, "No shopping cart item related to the release found."\n
\n
##Set connected member as shopping cart customer\n
context.SaleOrder_setShoppingCartCustomer()\n
# XXX Hardcoded values\n
seller = portal.restrictedTraverse("organisation_module/vifib_internet")\n
currency = portal.restrictedTraverse("currency_module/EUR")\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
\n
packing_list_portal_type = "Purchase Packing List"\n
module = portal.getDefaultModule(portal_type=packing_list_portal_type)\n
packing_list = module.newContent(\n
portal_type=packing_list_portal_type,\n
start_date=DateTime(),\n
destination_section_value=person,\n
destination_decision_value=person,\n
source_administration_value=person,\n
# XXX Hardcoded values\n
source_value=seller,\n
source_section_value=seller,\n
price_currency_value=currency,\n
)\n
packing_list.newContent(\n
portal_type="Purchase Packing List Line",\n
resource_value=order_line.getResourceValue(),\n
aggregate_value_list=order_line.getAggregateValueList(),\n
quantity=order_line.getQuantity()\n
resource_value=service,\n
aggregate_value_list=[item, computer],\n
quantity=1\n
)\n
packing_list.confirm()\n
context.SaleOrder_getShoppingCart(action=\'reset\')\n
\n
portal.portal_workflow.doActionFor(packing_list, "confirm_action")\n
# packing_list.confirm()\n
\n
session[\'instance_software_product_uid\'] = ""\n
session[\'instance_software_release_uid\'] = ""\n
session[\'computer_uid\'] = ""\n
\n
web_section = context.getWebSiteValue()\n
return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n
</string> </value>
......@@ -148,24 +153,22 @@ return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n
<string>portal</string>
<string>prefered_resource</string>
<string>service</string>
<string>session</string>
<string>item_list</string>
<string>$list0</string>
<string>_getiter_</string>
<string>item</string>
<string>len</string>
<string>shopping_cart</string>
<string>shopping_cart_items</string>
<string>NotImplementedError</string>
<string>_getitem_</string>
<string>product_url</string>
<string>False</string>
<string>line_found</string>
<string>order_line</string>
<string>True</string>
<string>computer</string>
<string>seller</string>
<string>currency</string>
<string>person</string>
<string>packing_list_portal_type</string>
<string>module</string>
<string>DateTime</string>
<string>packing_list</string>
<string>_write_</string>
<string>web_section</string>
</tuple>
</value>
......
260
\ No newline at end of file
264
\ 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