Commit 7640e4e6 authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Xiaowu Zhang

erp5_commerce: related ...

parent b5392479
...@@ -3,9 +3,17 @@ from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod ...@@ -3,9 +3,17 @@ from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
import urllib import urllib
import mechanize import mechanize
def getProductPrice(product): def getProductPrice(product, date=None):
getPrice = UnrestrictedMethod(product.getPrice) getPrice = UnrestrictedMethod(product.getPrice)
return getPrice(supply_path_type=["Sale Supply Line", "Sale Supply Cell"]) getDefaultContext = UnrestrictedMethod(product.Resource_getPriceCalculationDefaultContext)
return getPrice(supply_path_type=["Sale Supply Line", "Sale Supply Cell"],
context=getDefaultContext(date=date))
def getCurrentInventory(product, **kw):
return UnrestrictedMethod(product.getCurrentInventory)(**kw)
def getFutureInventory(product, **kw):
return UnrestrictedMethod(product.getFutureInventory)(**kw)
def submitPaypalNVPRequest(parameter_dict, nvp_url): def submitPaypalNVPRequest(parameter_dict, nvp_url):
request = mechanize.Request(nvp_url) request = mechanize.Request(nvp_url)
......
...@@ -83,6 +83,13 @@ if len(context.getVariationRangeCategoryList()):\n ...@@ -83,6 +83,13 @@ if len(context.getVariationRangeCategoryList()):\n
variation_category = request.get(variation_base_category, default_variation)\n variation_category = request.get(variation_base_category, default_variation)\n
variation_dict[variation_base_category] = variation_category\n variation_dict[variation_base_category] = variation_category\n
\n \n
if date is None:\n
variation_dict["start_date"] = DateTime()\n
variation_dict["stop_date"] = DateTime()+0.00001\n
else:\n
variation_dict["start_date"] = date\n
variation_dict["stop_date"] = date+0.00001\n
\n
if web_site_value is not None:\n if web_site_value is not None:\n
price_currency_value = web_site_value.WebSite_getShoppingCartDefaultCurrency()\n price_currency_value = web_site_value.WebSite_getShoppingCartDefaultCurrency()\n
else:\n else:\n
...@@ -95,7 +102,7 @@ return movement\n ...@@ -95,7 +102,7 @@ return movement\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>**kw</string> </value> <value> <string>date=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
...@@ -190,6 +190,8 @@ ...@@ -190,6 +190,8 @@
Return selected shipping method from shopping cart\n Return selected shipping method from shopping cart\n
"""\n """\n
shopping_cart = context.SaleOrder_getShoppingCart()\n shopping_cart = context.SaleOrder_getShoppingCart()\n
if shopping_cart is None:\n
return None\n
shipping_method = getattr(shopping_cart, \'shipping_method\', None)\n shipping_method = getattr(shopping_cart, \'shipping_method\', None)\n
if shipping_method is not None:\n if shipping_method is not None:\n
return shipping_method.getResourceValue()\n return shipping_method.getResourceValue()\n
......
...@@ -60,7 +60,10 @@ ...@@ -60,7 +60,10 @@
name probably.\n name probably.\n
- make sure this script is not called more than once per page\n - make sure this script is not called more than once per page\n
"""\n """\n
shopping_cart_order_line_list = context.SaleOrder_getShoppingCart().contentValues(portal_type="Sale Order Line")\n shopping_cart = context.SaleOrder_getShoppingCart()\n
if shopping_cart is None:\n
return []\n
shopping_cart_order_line_list = shopping_cart.contentValues(portal_type="Sale Order Line")\n
if include_shipping:\n if include_shipping:\n
return shopping_cart_order_line_list\n return shopping_cart_order_line_list\n
else:\n else:\n
......
...@@ -59,6 +59,7 @@ request = context.REQUEST\n ...@@ -59,6 +59,7 @@ request = context.REQUEST\n
if session_id is None: \n if session_id is None: \n
session_id = request.get(\'session_id\', None)\n session_id = request.get(\'session_id\', None)\n
\n \n
request.RESPONSE.expireCookie(\'session_id\')\n
return context.portal_sessions.manage_delObjects(session_id)\n return context.portal_sessions.manage_delObjects(session_id)\n
</string> </value> </string> </value>
</item> </item>
......
...@@ -90,7 +90,7 @@ kw.setdefault(\'reference\', kw[\'default_email_text\'])\n ...@@ -90,7 +90,7 @@ kw.setdefault(\'reference\', kw[\'default_email_text\'])\n
if \'password_confirm\' in kw:\n if \'password_confirm\' in kw:\n
del kw[\'password_confirm\']\n del kw[\'password_confirm\']\n
\n \n
#Check that user doesn\'t already exists\n # Check that user doesn\'t already exists\n
person_list = portal.acl_users.erp5_users.getUserByLogin(kw[\'reference\'])\n person_list = portal.acl_users.erp5_users.getUserByLogin(kw[\'reference\'])\n
if person_list:\n if person_list:\n
msg = translateString("This account already exists. Please provide another email address.")\n msg = translateString("This account already exists. Please provide another email address.")\n
...@@ -124,11 +124,19 @@ assignment = person.newContent(portal_type=\'Assignment\',\n ...@@ -124,11 +124,19 @@ assignment = person.newContent(portal_type=\'Assignment\',\n
site=person_site)\n site=person_site)\n
assignment.open()\n assignment.open()\n
\n \n
msg = translateString("Your account was successfully created.")\n is_shopping_cart = context.REQUEST.get(\'is_shopping_cart\')\n
if is_shopping_cart is None:\n
is_shopping_cart = context.REQUEST.get(\'field_your_is_shopping_cart\')\n
\n
if is_shopping_cart:\n
msg = translateString("Your account was successfully created, now you can proceed to payment.")\n
else:\n
msg = translateString("Your account was successfully created.")\n
\n \n
# Set owner local role for cart if needed\n # Set owner local role for cart if needed\n
shopping_cart = context.SaleOrder_getShoppingCart()\n shopping_cart = context.SaleOrder_getShoppingCart()\n
shopping_cart.manage_setLocalRoles(kw[\'reference\'], [\'Owner\'])\n if shopping_cart is not None:\n
shopping_cart.manage_setLocalRoles(kw[\'reference\'], [\'Owner\'])\n
\n \n
# Redirect if needed to coming_from_url\n # Redirect if needed to coming_from_url\n
came_from = kw[\'came_from\']\n came_from = kw[\'came_from\']\n
......
...@@ -10,6 +10,12 @@ ...@@ -10,6 +10,12 @@
<key> <string>Script_magic</string> </key> <key> <string>Script_magic</string> </key>
<value> <int>3</int> </value> <value> <int>3</int> </value>
</item> </item>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
...@@ -51,9 +57,13 @@ ...@@ -51,9 +57,13 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string># the goal of this script is to get all the related product of this section\n <value> <string># the goal of this script is to get all the related product of this section\n
from Products.ERP5Type.Cache import CachingMethod\n \n
current_web_section = context.REQUEST.get(\'current_web_section\', context)\n current_web_section = context.REQUEST.get(\'current_web_section\', context)\n
\n \n
# XXX Somehow Customize it Only list published products.\n
kw[\'validation_state\'] = \'published\'\n
\n
\n
if not kw.has_key(\'portal_type\'):\n if not kw.has_key(\'portal_type\'):\n
kw[\'portal_type\'] = \'Product\'\n kw[\'portal_type\'] = \'Product\'\n
\t \n \t \n
...@@ -69,20 +79,13 @@ if not kw.has_key(\'all_languages\'):\t\t \n ...@@ -69,20 +79,13 @@ if not kw.has_key(\'all_languages\'):\t\t \n
for key in [\'limit\',\'all_versions\',\'all_languages\']:\t\t \n for key in [\'limit\',\'all_versions\',\'all_languages\']:\t\t \n
kw[key] = int(kw[key])\n kw[key] = int(kw[key])\n
\n \n
\n # Gabriel: The condition was added to not break the paypal return\n
def getProductList(context_relative_url, limit, all_versions, all_languages):\n # after finish the payment. The verify_sign is checked because all\n
# Gabriel: The condition was added to not break the paypal return\n # data from paypal have this key\n
# after finish the payment. The verify_sign is checked because all\n if kw.has_key(\'quantity\') and kw.has_key("verify_sign"):\n
# data from paypal have this key\n
if kw.has_key(\'quantity\') and kw.has_key("verify_sign"):\n
del kw[\'quantity\']\n del kw[\'quantity\']\n
\t\t \n \t\t \n
return current_web_section.getDocumentValueList(**kw)\n return current_web_section.getDocumentValueList(**kw)\n
\n
\n
return CachingMethod(getProductList,\n
id="WebSection_getProductList_ecommerce",\n
cache_factory=\'erp5_ui_short\')(current_web_section.getRelativeUrl(),kw[\'limit\'],kw[\'all_versions\'], kw[\'all_languages\'])\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -318,7 +318,7 @@ python: "<br>" + "<br>".join([item.message for item in here.ERP5Site_getAuthenti ...@@ -318,7 +318,7 @@ python: "<br>" + "<br>".join([item.message for item in here.ERP5Site_getAuthenti
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: here.ERP5Site_getAuthenticatedMemberPersonValue().checkConsistency()</string> </value> <value> <string>python: not here.getPortalObject().portal_membership.isAnonymousUser() and here.ERP5Site_getAuthenticatedMemberPersonValue().checkConsistency()</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -54,30 +54,23 @@ ...@@ -54,30 +54,23 @@
# The goal of this script is to get all the products from all the visible Web Sections\n # The goal of this script is to get all the products from all the visible Web Sections\n
# and it must select randomly which product must be displayed for a given context.\n # and it must select randomly which product must be displayed for a given context.\n
from Products.ERP5Type.Cache import CachingMethod\n from random import choice\n
\n \n
if not kw.has_key(\'portal_type\'):\n if not kw.has_key(\'portal_type\'):\n
kw[\'portal_type\'] = \'Product\'\n kw[\'portal_type\'] = \'Product\'\n
\n
def getProductList(limit, portal_type):\n
from random import choice\n
\n \n
web_site = context.getWebSiteValue() or context.REQUEST.get(\'current_web_site\')\n web_site = context.getWebSiteValue() or context.REQUEST.get(\'current_web_site\')\n
\n \n
# Getting all the products from all the visible Web Section.\n # Getting all the products from all the visible Web Section.\n
product_dict = {}\n product_dict = {}\n
for web_section in web_site.WebSite_getMainSectionList():\n for web_section in web_site.WebSite_getMainSectionList():\n
for product in web_section.getDocumentValueList(all_versions=1, all_languages=1, **kw):\n for product in web_section.getDocumentValueList(all_versions=1, all_languages=1, **kw):\n
product_dict[product.uid] = product\n product_dict[product.uid] = product\n
\n \n
if len(product_dict) > limit:\n if len(product_dict) > limit:\n
return random.sample(product_dict.values(), limit)\n return random.sample(product_dict.values(), limit)\n
\n \n
return product_dict.values()\n return product_dict.values()\n
\n
return CachingMethod(getProductList,\n
id="WebSite_getProductList_ecommerce",\n
cache_factory=\'erp5_ui_short\')(limit, kw[\'portal_type\'])\n
]]></string> </value> ]]></string> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="StateDefinition" module="Products.DCWorkflow.States"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string> </string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>archived</string> </value>
</item>
<item>
<key> <string>permission_roles</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Archived</string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>invalidate</string>
<string>invalidate_action</string>
<string>publish</string>
<string>publish_action</string>
<string>validate</string>
<string>validate_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>type_list</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>Access contents information</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>Add portal content</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>Modify portal content</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>View</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
<key> <string>transitions</string> </key> <key> <string>transitions</string> </key>
<value> <value>
<tuple> <tuple>
<string>archive</string>
<string>archive_action</string>
<string>invalidate</string> <string>invalidate</string>
<string>invalidate_action</string> <string>invalidate_action</string>
<string>validate</string> <string>validate</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>archive</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string>archived</string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string>Archive</string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=archive_action</string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>archive</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>archive_action</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string>checkConsistency</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>roles</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Assignee</string>
<string>Manager</string>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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