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 @@ ...@@ -52,36 +52,13 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""Add selected product to the cart and continue"""\n <value> <string>"""Add selected product to the cart and continue"""\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
prefered_resource = portal.portal_preferences.getPreferredInstanceSetupResource()\n
service = portal.restrictedTraverse(prefered_resource)\n
\n \n
##Get item list\n if len(uids) != 1:\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
return context.Base_redirect(dialog_id,\n return context.Base_redirect(dialog_id,\n
keep_items={\'portal_status_message\':context.Base_translateString("Please select one service.")})\n keep_items={\'portal_status_message\':context.Base_translateString("Please select one service.")})\n
\n else:\n
\n session = context.WebSection_getVifibSession()\n
shopping_cart = context.SaleOrder_getShoppingCart()\n session[\'instance_software_product_uid\'] = uids[0]\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
\n \n
if kw.has_key(\'came_from\'):\n if kw.has_key(\'came_from\'):\n
#we override the context to redirect the user to the next web section\n #we override the context to redirect the user to the next web section\n
...@@ -131,19 +108,10 @@ context.WebSection_viewNextStep()\n ...@@ -131,19 +108,10 @@ context.WebSection_viewNextStep()\n
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal</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>len</string>
<string>shopping_cart</string> <string>session</string>
<string>shopping_cart_items</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>NotImplementedError</string> <string>_write_</string>
<string>product_url</string>
<string>order_line</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -59,21 +59,8 @@ service = portal.restrictedTraverse(prefered_resource)\n ...@@ -59,21 +59,8 @@ service = portal.restrictedTraverse(prefered_resource)\n
if context.getPortalType() != "Computer":\n if context.getPortalType() != "Computer":\n
raise NotImplementedError, "Should be called on a Computer"\n raise NotImplementedError, "Should be called on a Computer"\n
\n \n
##Reset the cart and get new shopping cart\n session = context.WebSection_getVifibSession()\n
if reset_shopping_cart:\n session[\'computer_uid\'] = context.getUid()\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
\n \n
web_section = context.getWebSectionValue()\n web_section = context.getWebSectionValue()\n
return web_section.Base_redirect(\'install-a-software\', keep_items={\'editable_mode\': 0})\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_ ...@@ -124,8 +111,8 @@ return web_section.Base_redirect(\'install-a-software\', keep_items={\'editable_
<string>prefered_resource</string> <string>prefered_resource</string>
<string>service</string> <string>service</string>
<string>NotImplementedError</string> <string>NotImplementedError</string>
<string>shopping_cart</string> <string>session</string>
<string>order_line</string> <string>_write_</string>
<string>web_section</string> <string>web_section</string>
</tuple> </tuple>
</value> </value>
......
...@@ -52,9 +52,11 @@ ...@@ -52,9 +52,11 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""Add selected product to the cart and continue"""\n <value> <string>"""Add selected product to the cart and continue"""\n
portal = context.getPortalObject()\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 service = portal.restrictedTraverse(prefered_resource)\n
\n \n
session = context.WebSection_getVifibSession()\n
\n
##Get item list\n ##Get item list\n
item_list = []\n item_list = []\n
if uids:\n if uids:\n
...@@ -64,43 +66,46 @@ if len(item_list) != 1:\n ...@@ -64,43 +66,46 @@ if len(item_list) != 1:\n
return context.Base_redirect(dialog_id,\n return context.Base_redirect(dialog_id,\n
keep_items={\'portal_status_message\':context.Base_translateString("Please select one software release.")})\n keep_items={\'portal_status_message\':context.Base_translateString("Please select one software release.")})\n
\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 item = item_list[0]\n
product_url = item.getAggregate()\n # XXX Check that release is associate to product\n
## check if we don\'t have already such a resource in cart\n \n
line_found=False\n computer = portal.portal_catalog.getResultValue(\n
for order_line in shopping_cart_items:\n uid=session[\'computer_uid\'],\n
if product_url in order_line.getAggregateList():\n portal_type="Computer",\n
line_found=True\n )\n
order_line.edit(aggregate_value_list=order_line.getAggregateList() + [item.getRelativeUrl()])\n
break\n
\n \n
if not line_found:\n # XXX Hardcoded values\n
raise NotImplementedError, "No shopping cart item related to the release found."\n seller = portal.restrictedTraverse("organisation_module/vifib_internet")\n
\n currency = portal.restrictedTraverse("currency_module/EUR")\n
##Set connected member as shopping cart customer\n person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
context.SaleOrder_setShoppingCartCustomer()\n
\n \n
packing_list_portal_type = "Purchase Packing List"\n packing_list_portal_type = "Purchase Packing List"\n
module = portal.getDefaultModule(portal_type=packing_list_portal_type)\n module = portal.getDefaultModule(portal_type=packing_list_portal_type)\n
packing_list = module.newContent(\n packing_list = module.newContent(\n
portal_type=packing_list_portal_type,\n portal_type=packing_list_portal_type,\n
start_date=DateTime(),\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 )\n
packing_list.newContent(\n packing_list.newContent(\n
portal_type="Purchase Packing List Line",\n portal_type="Purchase Packing List Line",\n
resource_value=order_line.getResourceValue(),\n resource_value=service,\n
aggregate_value_list=order_line.getAggregateValueList(),\n aggregate_value_list=[item, computer],\n
quantity=order_line.getQuantity()\n quantity=1\n
)\n )\n
packing_list.confirm()\n \n
context.SaleOrder_getShoppingCart(action=\'reset\')\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 web_section = context.getWebSiteValue()\n
return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n
</string> </value> </string> </value>
...@@ -148,24 +153,22 @@ return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n ...@@ -148,24 +153,22 @@ return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n
<string>portal</string> <string>portal</string>
<string>prefered_resource</string> <string>prefered_resource</string>
<string>service</string> <string>service</string>
<string>session</string>
<string>item_list</string> <string>item_list</string>
<string>$list0</string> <string>$list0</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>item</string> <string>item</string>
<string>len</string> <string>len</string>
<string>shopping_cart</string>
<string>shopping_cart_items</string>
<string>NotImplementedError</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>product_url</string> <string>computer</string>
<string>False</string> <string>seller</string>
<string>line_found</string> <string>currency</string>
<string>order_line</string> <string>person</string>
<string>True</string>
<string>packing_list_portal_type</string> <string>packing_list_portal_type</string>
<string>module</string> <string>module</string>
<string>DateTime</string> <string>DateTime</string>
<string>packing_list</string> <string>packing_list</string>
<string>_write_</string>
<string>web_section</string> <string>web_section</string>
</tuple> </tuple>
</value> </value>
......
260 264
\ 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