Commit 46bf8b43 authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Xiaowu Zhang

Unsorted changes found on production

* This commit should be rebased before be really released.
parent 8cdba82f
......@@ -57,6 +57,7 @@
TODO:\n
- add support to input parameters (**kw) so that it\n
is possible specialize price calculation\n
- support alt default currency\n
"""\n
from Products.ERP5Type.Document import newTempMovement\n
\n
......@@ -64,8 +65,6 @@ from Products.ERP5Type.Document import newTempMovement\n
web_site_value = context.REQUEST.get(\'current_web_site\', None)\n
if web_site_value is None:\n
web_site_value = context.getWebSiteValue() \n
if web_site_value is None:\n
raise ValueError("Could not determine the current web site to compute default currency of price")\n
\n
# If this resource is variated, initialize the default\n
# variation context\n
......@@ -84,8 +83,12 @@ if len(context.getVariationRangeCategoryList()):\n
variation_category = request.get(variation_base_category, default_variation)\n
variation_dict[variation_base_category] = variation_category\n
\n
if web_site_value is not None:\n
price_currency_value = web_site_value.WebSite_getShoppingCartDefaultCurrency()\n
else:\n
price_currency_value = context.getPortalObject().currency_module.EUR # hack\n
movement = newTempMovement(context, "temp_pricing_movement", resource_value=context,\n
price_currency_value=web_site_value.WebSite_getShoppingCartDefaultCurrency(),\n
price_currency_value=price_currency_value,\n
**variation_dict)\n
return movement\n
</string> </value>
......
......@@ -199,15 +199,25 @@
"""\n
request = context.REQUEST\n
translateString = context.Base_translateString \n
if field_my_buy_quantity is None:\n
field_my_buy_quantity=context.REQUEST.get("field_my_buy_quantity", None)\n
\n
if field_my_shipping_method is None:\n
field_my_shipping_method=context.REQUEST.get("field_my_shipping_method", None) \n
\n
if field_my_payment_mode is None:\n
field_my_payment_mode = context.REQUEST.get("field_my_payment_mode", None) \n
\n
quantity = field_my_buy_quantity\n
shipping_method = field_my_shipping_method\n
shopping_cart_items = context.SaleOrder_getShoppingCartItemList(include_shipping=True)\n
shopping_cart_products_items = filter(lambda x: x.getId()!=\'shipping_method\', shopping_cart_items)\n
shopping_cart = context.SaleOrder_getShoppingCart()\n
\n
\n
# Handle change in quantity for shopping items\n
if quantity is not None:\n
# Whenever there is onlu one item in shoppping cart, quantity\n
# Whenever there is only one item in shoppping cart, quantity\n
# is a string rather as a list\n
if isinstance(quantity, str):\n
quantity = [quantity]\n
......@@ -226,28 +236,32 @@ if quantity is not None:\n
order_line = getattr(shopping_cart, \'shipping_method\', None)\n
if shipping_method not in [\'\', None]:\n
shipping = context.getPortalObject().restrictedTraverse(shipping_method)\n
if order_line is None:\n
# create new shipping method order line\n
order_line = shopping_cart.newContent(id=\'shipping_method\', portal_type=\'Sale Order Line\')\n
if order_line is not None:\n
shopping_cart.manage_delObjects(order_line.getId())\n
# create new shipping method order line\n
order_line = shopping_cart.newContent(id=\'shipping_method\', portal_type=\'Sale Order Line\')\n
# .. and update it\n
order_line.setResource(shipping.getRelativeUrl())\n
order_line.setQuantity(1)\n
else:\n
if field_my_shipping_method in [\'\', None] and order_line is not None:\n
shopping_cart.manage_delObjects(order_line.getId())\n
\n
# Handle payment mode and comment\n
shopping_cart.setComment(field_my_comment)\n
shopping_cart.setPaymentConditionPaymentMode(field_my_payment_mode) # XXX This is bad because it does not use trade conditions XXX\n
\n
return context.SaleOrder_paymentRedirect()\n
if field_my_comment is not None:\n
shopping_cart.setComment(field_my_comment)\n
\n
if field_my_payment_mode is not None:\n
shopping_cart.setPaymentConditionPaymentMode(field_my_payment_mode) # XXX This is bad because it does not use trade conditions XXX\n
\n
if redirect:\n
# Hardcode redirection.\n
return context.Base_redirect("WebSection_viewShoppingCart", \\\n
keep_items={\'portal_status_message\': translateString("Shopping Cart Updated.")})\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>field_my_buy_quantity=None, field_my_shipping_method=None, field_my_comment=None, field_my_payment_mode=None, **kw</string> </value>
<value> <string>field_my_buy_quantity=None, field_my_shipping_method=None, field_my_comment=None, field_my_payment_mode=None, redirect=True, **kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
......@@ -192,9 +192,9 @@
\n
TODO:\n
- support generic variations\n
- rename buyer to supplier (everywhere)\n
- clean up python style such as space in "a = b" inside function calls\n
(hint: add global syntax and lexical analysis to ERP5 scripts)\n
- do we really need Proxy manager ?\n
"""\n
from DateTime import DateTime\n
request = context.REQUEST\n
......@@ -203,8 +203,8 @@ isAnon = context.portal_membership.isAnonymousUser()\n
translateString = context.Base_translateString\n
shopping_cart = context.SaleOrder_getShoppingCart()\n
shopping_cart_item_list = shopping_cart.SaleOrder_getShoppingCartItemList(include_shipping=True)\n
customer = shopping_cart.SaleOrder_getShoppingCartCustomer()\n
buyer = shopping_cart.SaleOrder_getShoppingCartBuyer()\n
customer = context.ERP5Site_getAuthenticatedMemberPersonValue()\n
\n
\n
if isAnon:\n
# Create first an account for user\n
......@@ -213,19 +213,12 @@ if isAnon:\n
keep_items={\'portal_status_message\': msg})\n
return\n
\n
# Check if payment is sucessfull (comment the if buyer line and uncoment the next to be able to test)\n
if buyer is None:\n
# if False:\n
raise ValueError, "Impossible to finalize an order which was not payed before"\n
\n
portal_type = shopping_cart.getPortalType()\n
module = context.getDefaultModule(portal_type)\n
sale_order = module.newContent(portal_type=portal_type,\n
destination_value = customer,\n
destination_section_value = customer,\n
destination_decision_value = customer,\n
source_section_value = buyer,\n
source_value = buyer,\n
start_date = DateTime(),\n
received_date = DateTime(),\n
comment = shopping_cart.getComment(),\n
......@@ -251,7 +244,7 @@ for order_line in shopping_cart_item_list:\n
sale_order.activate().order()\n
\n
# clean up shopping cart\n
context.SaleOrder_getShoppingCart(action=\'reset\')\n
context.WebSection_resetShoppingCart()\n
\n
# Display nice message\n
context.Base_redirect(\'SaleOrder_viewThankYouMessage\')\n
......@@ -261,6 +254,14 @@ context.Base_redirect(\'SaleOrder_viewThankYouMessage\')\n
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleOrder_finalizeShopping</string> </value>
......
......@@ -65,7 +65,7 @@ from DateTime import DateTime\n
\n
request = context.REQUEST\n
expire_timeout_days = 90\n
session_id = request.get(\'session_id\', None)\n
if session_id is None: session_id = request.get(\'session_id\', None)\n
portal_sessions = context.portal_sessions\n
\n
if session_id is None:\n
......@@ -86,21 +86,25 @@ session = portal_sessions[session_id]\n
# comes from a previous user with same session\n
if shopping_cart_id in session.keys():\n
shopping_cart = session[shopping_cart_id]\n
if not shopping_cart.SaleOrder_isShoppingCartConsistent():\n
portal_sessions.manage_delObjects(session_id)\n
session = portal_sessions[session_id]\n
#if not shopping_cart.SaleOrder_isShoppingCartConsistent():\n
# portal_sessions.manage_delObjects(session_id)\n
# session = portal_sessions[session_id]\n
\n
# create shopping cart\n
if not shopping_cart_id in session.keys():\n
from Products.ERP5Type.Document import newTempOrder\n
web_site = context.getWebSiteValue()\n
shopping_cart = context.sale_order_module.newContent(portal_type="Sale Order", id=shopping_cart_id, temp_object=1, container=portal_sessions)\n
shopping_cart = context.sale_order_module.newContent(portal_type="Sale Order", \n
id=shopping_cart_id, \n
temp_object=1, \n
container=portal_sessions)\n
# Set usable security for Anonymous\n
shopping_cart.manage_role("Anonymous", ["Access contents information",\n
"Add portal content",\n
"Delete objects",\n
"Modify portal content",\n
"View"])\n
shopping_cart.setSpecialise(web_site.WebSection_getDefaultTradeCondition())\n
shopping_cart.setPriceCurrency(web_site.WebSite_getShoppingCartDefaultCurrency().getRelativeUrl())\n
session[shopping_cart_id] = shopping_cart\n
\n
......@@ -111,7 +115,7 @@ return shopping_cart\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>action=\'\', new_shopping_cart=None</string> </value>
<value> <string>action=\'\', new_shopping_cart=None, session_id=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Return the default trade condition for thie ecommerce site\n
"""\n
return context.getWebSiteValue().getLayoutProperty(\n
\'ecommerce_default_trade_condition\', \n
\'sale_trade_condition_module/default_trade_condition\')\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_getDefaultTradeCondition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Return default trade condition</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -131,14 +131,14 @@ shopping_cart = context.SaleOrder_getShoppingCart()\n
shopping_cart.manage_setLocalRoles(kw[\'reference\'], [\'Owner\'])\n
\n
# Redirect if needed to coming_from_url\n
coming_from_url = kw[\'coming_from_url\']\n
if coming_from_url:\n
came_from = kw[\'came_from\']\n
if came_from:\n
from ZTUtils import make_query\n
parameter_string = make_query(__ac_name=kw[\'reference\'], __ac_password=kw[\'password\'],\n
portal_status_message=msg, editable_mode=0)\n
return context.REQUEST.RESPONSE.redirect(\'%s?%s\' % (coming_from_url, parameter_string))\n
\n
return website.Base_redirect(form_id, keep_items=dict(portal_status_message=msg,\n
return context.REQUEST.RESPONSE.redirect(\'%s?%s\' % (came_from, parameter_string))\n
\n
return website.Base_redirect(\'\', keep_items=dict(portal_status_message=msg,\n
__ac_name=kw[\'reference\'], # XXX - Make it generic\n
__ac_password=kw[\'password\'], # XXX - Make it generic\n
editable_mode=0))\n
......
......@@ -56,6 +56,8 @@
TODO:\n
- remove hardcoding of currency_module/EUR \n
(ex. use system properties for example)\n
\n
(rafael) We should rely on Trade Condition instead.\n
"""\n
web_site = context.getWebSiteValue()\n
return context.getPortalObject().restrictedTraverse(\n
......
306
\ No newline at end of file
307
\ 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