website sale refactor
bzr revid: al@openerp.com-20140130233951-55ttup4ohmp4i0nf
This commit is contained in:
parent
c1739bfb8d
commit
ff37d0ebca
|
@ -12,7 +12,7 @@ OpenERP Website CMS
|
|||
'depends': ['web', 'share', 'mail'],
|
||||
'installable': True,
|
||||
'data': [
|
||||
'data/website_data.xml',
|
||||
'data/data.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/ir_ui_view.xml',
|
||||
'views/website_templates.xml',
|
||||
|
@ -22,7 +22,7 @@ OpenERP Website CMS
|
|||
'views/res_config.xml',
|
||||
],
|
||||
'demo': [
|
||||
'data/website_demo.xml',
|
||||
'data/demo.xml',
|
||||
],
|
||||
'js': ['static/src/js/website.backend.js'],
|
||||
'qweb' : ['static/src/xml/website.backend.xml'],
|
||||
|
|
|
@ -31,6 +31,13 @@ class ir_http(orm.AbstractModel):
|
|||
page=PageConverter,
|
||||
)
|
||||
|
||||
def _auth_method_public(self):
|
||||
# TODO: select user_id from matching website
|
||||
if not request.session.uid:
|
||||
request.uid = self.pool['ir.model.data'].xmlid_to_res_id(request.cr, openerp.SUPERUSER_ID, 'base.public_user')
|
||||
else:
|
||||
request.uid = request.session.uid
|
||||
|
||||
def _dispatch(self):
|
||||
first_pass = not hasattr(request, 'website')
|
||||
request.website = None
|
||||
|
|
|
@ -106,10 +106,6 @@ class website(osv.osv):
|
|||
menu = menus and menus[0] or False
|
||||
return dict( map(lambda x: (x, menu), ids) )
|
||||
|
||||
def _get_public_user(self, cr, uid, ids, name='public_user', arg=(), context=None):
|
||||
ref = self.get_public_user(cr, uid, context=context)
|
||||
return dict( map(lambda x: (x, ref), ids) )
|
||||
|
||||
_name = "website" # Avoid website.website convention for conciseness (for new api). Got a special authorization from xmo and rco
|
||||
_description = "Website"
|
||||
_columns = {
|
||||
|
@ -126,7 +122,7 @@ class website(osv.osv):
|
|||
'social_googleplus': fields.char('Google+ Account'),
|
||||
'google_analytics_key': fields.char('Google Analytics Key'),
|
||||
'user_id': fields.many2one('res.users', string='Public User'),
|
||||
'public_user': fields.function(_get_public_user, relation='res.users', type='many2one', string='Public User'),
|
||||
'partner_id': fields.related('user_id','partner_id', type='many2one', relation='res.partner', string='Public Partner'),
|
||||
'menu_id': fields.function(_get_menu, relation='website.menu', type='many2one', string='Main Menu',
|
||||
store= {
|
||||
'website.menu': (_get_menu_website, ['sequence','parent_id','website_id'], 10)
|
||||
|
@ -185,11 +181,6 @@ class website(osv.osv):
|
|||
except:
|
||||
return False
|
||||
|
||||
def get_public_user(self, cr, uid, context=None):
|
||||
uid = openerp.SUPERUSER_ID
|
||||
res = self.pool['ir.model.data'].get_object_reference(cr, uid, 'base', 'public_user')
|
||||
return res and res[1] or False
|
||||
|
||||
@openerp.tools.ormcache(skiparg=3)
|
||||
def _get_languages(self, cr, uid, id, context=None):
|
||||
website = self.browse(cr, uid, id)
|
||||
|
@ -380,7 +371,8 @@ class website(osv.osv):
|
|||
"""
|
||||
router = request.httprequest.app.get_db_router(request.db)
|
||||
# Force enumeration to be performed as public user
|
||||
uid = self.get_public_user(cr, uid, context=context)
|
||||
# TODO: use website.user_id instead
|
||||
uid = self.pool['ir.model.data'].xmlid_to_res_id(request.cr, openerp.SUPERUSER_ID, 'base.public_user')
|
||||
for rule in router.iter_rules():
|
||||
if not self.rule_is_enumerable(rule):
|
||||
continue
|
||||
|
|
|
@ -5,6 +5,6 @@ from openerp.osv import orm
|
|||
class Website(orm.Model):
|
||||
_inherit = 'website'
|
||||
|
||||
def ecommerce_get_product_domain(self):
|
||||
def sale_product_domain(self):
|
||||
# remove product event from the website content grid and list view (not removed in detail view)
|
||||
return ['&'] + super(Website, self).ecommerce_get_product_domain() + [('event_ok', '=', False)]
|
||||
return ['&'] + super(Website, self).sale_product_domain() + [('event_ok', '=', False)]
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="mycart" inherit_id="website_sale.mycart" name="My Cart Event's Price">
|
||||
<template id="cart" inherit_id="website_sale.cart" name="My Cart Event's Price">
|
||||
<xpath expr="//td[@name='price']/t" position="attributes">
|
||||
<attribute name="t-if">abs(line.product_id.lst_price - line.price_unit) > 0.2 and not line.product_id.event_ok</attribute>
|
||||
</xpath>
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
.. _changelog:
|
||||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
`trunk (saas-3)`
|
||||
----------------
|
||||
|
||||
- created ``website_mail`` menu, holding website-related stuff about mail module
|
|
@ -1,10 +0,0 @@
|
|||
Website Mail Module documentation topics
|
||||
''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
Changelog
|
||||
'''''''''
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
changelog.rst
|
|
@ -32,7 +32,7 @@
|
|||
'views/website_partner_view.xml',
|
||||
'data/website_data.xml',
|
||||
],
|
||||
'demo': ['website_partner_demo.xml'],
|
||||
'demo': ['data/demo.xml'],
|
||||
'css': [
|
||||
],
|
||||
'js': [
|
||||
|
|
|
@ -11,14 +11,14 @@ OpenERP E-Commerce
|
|||
'author': 'OpenERP SA',
|
||||
'depends': ['website', 'sale', 'payment'],
|
||||
'data': [
|
||||
'data/website_sale_data.xml',
|
||||
'views/website_sale.xml',
|
||||
'views/website_sale_backend.xml',
|
||||
'data/data.xml',
|
||||
'views/views.xml',
|
||||
'views/templates.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/website_sale.xml',
|
||||
],
|
||||
'demo': [
|
||||
'data/website_sale_demo.xml',
|
||||
'data/demo.xml',
|
||||
],
|
||||
'qweb': ['static/src/xml/*.xml'],
|
||||
'installable': True,
|
||||
|
|
|
@ -7,50 +7,9 @@ from openerp import SUPERUSER_ID
|
|||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
|
||||
PPG = 20 # Products Per Page
|
||||
PPR = 4 # Products Per Row
|
||||
PPG = 20 # Products Per Page
|
||||
PPR = 4 # Products Per Row
|
||||
|
||||
|
||||
class CheckoutInfo(object):
|
||||
mandatory_billing_fields = ["name", "phone", "email", "street", "city", "country_id", "zip"]
|
||||
optional_billing_fields = ["company", "state_id"]
|
||||
string_billing_fields = ["name", "phone", "email", "street", "city", "zip"]
|
||||
|
||||
mandatory_shipping_fields = ["shipping_name", "shipping_phone", "shipping_street", "shipping_city", "shipping_country_id", "shipping_zip"]
|
||||
optional_shipping_field = ["shipping_state_id"]
|
||||
string_shipping_fields = ["shipping_name", "shipping_phone", "shipping_street", "shipping_city", "shipping_zip"]
|
||||
|
||||
def mandatory_fields(self):
|
||||
return self.mandatory_billing_fields + self.mandatory_shipping_fields
|
||||
|
||||
def optional_fields(self):
|
||||
return self.optional_billing_fields + self.optional_shipping_field
|
||||
|
||||
def all_fields(self):
|
||||
return self.mandatory_fields() + self.optional_fields()
|
||||
|
||||
def empty(self):
|
||||
return dict.fromkeys(self.all_fields(), '')
|
||||
|
||||
def from_partner(self, partner, address_type='billing'):
|
||||
assert address_type in ('billing', 'shipping')
|
||||
if address_type == 'billing':
|
||||
prefix = ''
|
||||
else:
|
||||
prefix = 'shipping_'
|
||||
result = dict((prefix + field_name, getattr(partner, field_name)) for field_name in self.string_billing_fields if getattr(partner, field_name))
|
||||
result[prefix + 'state_id'] = partner.state_id and partner.state_id.id or ''
|
||||
result[prefix + 'country_id'] = partner.country_id and partner.country_id.id or ''
|
||||
result[prefix + 'company'] = partner.parent_id and partner.parent_id.name or ''
|
||||
return result
|
||||
|
||||
def from_post(self, post):
|
||||
return dict((field_name, post[field_name]) for field_name in self.all_fields() if post[field_name])
|
||||
|
||||
|
||||
#
|
||||
# Compute grid of products according to their sizes
|
||||
#
|
||||
class table_compute(object):
|
||||
def __init__(self):
|
||||
self.table = {}
|
||||
|
@ -107,91 +66,42 @@ class table_compute(object):
|
|||
rows[col] = map(lambda x: x[1], cols)
|
||||
return filter(bool, rows)
|
||||
|
||||
# TODO keep with input type hidden
|
||||
|
||||
class Ecommerce(http.Controller):
|
||||
|
||||
_order = 'website_published desc, website_sequence desc'
|
||||
class QueryURL(object):
|
||||
def __init__(self, path='', **args):
|
||||
self.path = path
|
||||
self.args = args
|
||||
|
||||
def get_attribute_ids(self):
|
||||
attributes_obj = request.registry['product.attribute']
|
||||
attributes_ids = attributes_obj.search(request.cr, request.uid, [], context=request.context)
|
||||
return attributes_obj.browse(request.cr, request.uid, attributes_ids, context=request.context)
|
||||
def __call__(self, path=None, **kw):
|
||||
if not path:
|
||||
path = self.path
|
||||
for k,v in self.args.items():
|
||||
kw.setdefault(k,v)
|
||||
l = []
|
||||
for k,v in kw.items():
|
||||
if v:
|
||||
if isinstance(v, list) or isinstance(v, set):
|
||||
l.append(werkzeug.url_encode([(k,i) for i in v]))
|
||||
else:
|
||||
l.append(werkzeug.url_encode([(k,v)]))
|
||||
if l:
|
||||
path += '?' + '&'.join(l)
|
||||
return path
|
||||
|
||||
|
||||
class website_sale(http.Controller):
|
||||
|
||||
def get_pricelist(self):
|
||||
""" Shortcut to get the pricelist from the website model """
|
||||
return request.registry['website'].ecommerce_get_pricelist_id(request.cr, request.uid, None, context=request.context)
|
||||
|
||||
def get_order(self):
|
||||
""" Shortcut to get the current ecommerce quotation from the website model """
|
||||
return request.registry['website'].ecommerce_get_current_order(request.cr, request.uid, context=request.context)
|
||||
|
||||
def get_products(self, product_ids):
|
||||
product_obj = request.registry.get('product.template')
|
||||
request.context['pricelist'] = self.get_pricelist()
|
||||
# search for checking of access rules and keep order
|
||||
product_ids = [id for id in product_ids if id in product_obj.search(request.cr, request.uid, [("id", 'in', product_ids)], context=request.context)]
|
||||
return product_obj.browse(request.cr, request.uid, product_ids, context=request.context)
|
||||
|
||||
def has_search_filter(self, attribute_id, value_id=None):
|
||||
if request.httprequest.args.get('filters'):
|
||||
filters = simplejson.loads(request.httprequest.args['filters'])
|
||||
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
||||
sale_order = context.get('sale_order')
|
||||
if sale_order:
|
||||
pricelist = sale_order.pricelist_id
|
||||
else:
|
||||
filters = []
|
||||
for key_val in filters:
|
||||
if key_val[0] == attribute_id and (not value_id or value_id in key_val[1:]):
|
||||
return key_val
|
||||
return False
|
||||
|
||||
@http.route(['/shop/filters/'], type='http', auth="public", website=True, multilang=True)
|
||||
def filters(self, **post):
|
||||
index = []
|
||||
filters = []
|
||||
for key, val in post.items():
|
||||
cat = key.split("-")
|
||||
if len(cat) < 3 or cat[2] in ('max','minmem','maxmem'):
|
||||
continue
|
||||
cat_id = int(cat[1])
|
||||
if cat[2] == 'min':
|
||||
minmem = float(post.pop("att-%s-minmem" % cat[1]))
|
||||
maxmem = float(post.pop("att-%s-maxmem" % cat[1]))
|
||||
_max = int(post.pop("att-%s-max" % cat[1]))
|
||||
_min = int(val)
|
||||
if (minmem != _min or maxmem != _max) and cat_id not in index:
|
||||
filters.append([cat_id , [_min, _max] ])
|
||||
index.append(cat_id)
|
||||
elif cat_id not in index:
|
||||
filters.append([ cat_id, int(cat[2]) ])
|
||||
index.append(cat_id)
|
||||
else:
|
||||
cat[2] = int(cat[2])
|
||||
if cat[2] not in filters[index.index(cat_id)][1:]:
|
||||
filters[index.index(cat_id)].append( cat[2] )
|
||||
post.pop(key)
|
||||
|
||||
return request.redirect("/shop/?filters=%s%s%s" % (
|
||||
simplejson.dumps(filters),
|
||||
post.get("search") and ("&search=%s" % post.get("search")) or "",
|
||||
post.get("category") and ("&category=%s" % post.get("category")) or ""
|
||||
))
|
||||
|
||||
def attributes_to_ids(self, attributes):
|
||||
obj = request.registry.get('product.attribute.line')
|
||||
domain = []
|
||||
for key_val in attributes:
|
||||
domain.append(("attribute_id", "=", key_val[0]))
|
||||
if isinstance(key_val[1], list):
|
||||
domain.append(("value", ">=", key_val[1][0]))
|
||||
domain.append(("value", "<=", key_val[1][1]))
|
||||
else:
|
||||
domain.append(("value_id", "in", key_val[1:]))
|
||||
att_ids = obj.search(request.cr, request.uid, domain, context=request.context)
|
||||
att = obj.read(request.cr, request.uid, att_ids, ["product_tmpl_id"], context=request.context)
|
||||
return [r["product_tmpl_id"][0] for r in att]
|
||||
|
||||
@http.route(['/shop/pricelist'], type='http', auth="public", website=True, multilang=True)
|
||||
def shop_promo(self, promo=None, **post):
|
||||
request.registry['website']._ecommerce_change_pricelist(request.cr, request.uid, code=promo, context=request.context)
|
||||
return request.redirect("/shop/mycart/")
|
||||
partner = pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=context).partner_id
|
||||
pricelist = partner.property_product_pricelist
|
||||
return pricelist
|
||||
|
||||
@http.route([
|
||||
'/shop/',
|
||||
|
@ -199,89 +109,89 @@ class Ecommerce(http.Controller):
|
|||
'/shop/category/<model("product.public.category"):category>/',
|
||||
'/shop/category/<model("product.public.category"):category>/page/<int:page>/'
|
||||
], type='http', auth="public", website=True, multilang=True)
|
||||
def shop(self, category=None, page=0, filters='', search='', **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
product_obj = request.registry.get('product.template')
|
||||
domain = request.registry.get('website').ecommerce_get_product_domain()
|
||||
if search:
|
||||
domain += ['|',
|
||||
('name', 'ilike', search),
|
||||
('description', 'ilike', search)]
|
||||
if category:
|
||||
domain.append(('product_variant_ids.public_categ_id', 'child_of', category.id))
|
||||
if filters:
|
||||
filters = simplejson.loads(filters)
|
||||
if filters:
|
||||
ids = self.attributes_to_ids(filters)
|
||||
domain.append(('id', 'in', ids or [0]))
|
||||
def shop(self, page=0, category=None, search='', **post):
|
||||
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
||||
|
||||
domain = request.website.sale_product_domain()
|
||||
if search:
|
||||
domain += ['|', ('name', 'ilike', search), ('description', 'ilike', search)]
|
||||
if category:
|
||||
domain += [('product_variant_ids.public_categ_id', 'child_of', category.id)]
|
||||
|
||||
attrib_values = map(int,request.httprequest.args.getlist('attrib'))
|
||||
if attrib_values:
|
||||
domain += [('attribute_lines.value_id', 'in', attrib_values)]
|
||||
attrib_set = set(attrib_values)
|
||||
keep = QueryURL('/shop', category=category and category.id, search=search, attrib=attrib_set)
|
||||
|
||||
product_obj = pool.get('product.template')
|
||||
product_count = product_obj.search_count(cr, uid, domain, context=context)
|
||||
pager = request.website.pager(url="/shop/", total=product_count, page=page, step=PPG, scope=7, url_args=post)
|
||||
product_ids = product_obj.search(cr, uid, domain, limit=PPG+10, offset=pager['offset'], order='website_published desc, website_sequence desc', context=context)
|
||||
products = product_obj.browse(cr, uid, product_ids, context=context)
|
||||
|
||||
request.context['pricelist'] = self.get_pricelist()
|
||||
style_obj = pool['product.style']
|
||||
style_ids = style_obj.search(cr, uid, [], context=context)
|
||||
styles = style_obj.browse(cr, uid, style_ids, context=context)
|
||||
|
||||
pids = product_obj.search(cr, uid, domain, limit=PPG+10, offset=pager['offset'], order=self._order, context=context)
|
||||
products = product_obj.browse(cr, uid, pids, context=context)
|
||||
|
||||
styles = []
|
||||
try:
|
||||
style_obj = request.registry.get('product.style')
|
||||
style_ids = style_obj.search(request.cr, request.uid, [], context=request.context)
|
||||
styles = style_obj.browse(request.cr, request.uid, style_ids, context=request.context)
|
||||
except:
|
||||
pass
|
||||
|
||||
category_obj = request.registry.get('product.public.category')
|
||||
category_obj = pool['product.public.category']
|
||||
category_ids = category_obj.search(cr, uid, [], context=context)
|
||||
categories = category_obj.browse(cr, uid, category_ids, context=context)
|
||||
categs = filter(lambda x: not x.parent_id, categories)
|
||||
|
||||
attributes_obj = request.registry['product.attribute']
|
||||
attributes_ids = attributes_obj.search(cr, uid, [], context=request.context)
|
||||
attributes = attributes_obj.browse(cr, uid, attributes_ids, context=request.context)
|
||||
|
||||
values = {
|
||||
'search': search,
|
||||
'category': category and category.id,
|
||||
'attrib_set': attrib_set,
|
||||
'pager': pager,
|
||||
'pricelist': self.get_pricelist(),
|
||||
'products': products,
|
||||
'bins': table_compute().process(products),
|
||||
'rows': PPR,
|
||||
'range': range,
|
||||
'search': {
|
||||
'search': search,
|
||||
'category': category and category.id,
|
||||
'filters': filters,
|
||||
},
|
||||
'pager': pager,
|
||||
'styles': styles,
|
||||
'categories': categs,
|
||||
'Ecommerce': self, # TODO fp: Should be removed
|
||||
'attributes': attributes,
|
||||
'keep': keep,
|
||||
'style_in_product': lambda style, product: style.id in [s.id for s in product.website_style_ids],
|
||||
'attrib_encode': lambda attribs: werkzeug.url_encode([('attrib',i) for i in attribs]),
|
||||
}
|
||||
|
||||
return request.website.render("website_sale.products", values)
|
||||
|
||||
@http.route(['/shop/product/<model("product.template"):product>/'], type='http', auth="public", website=True, multilang=True)
|
||||
def product(self, product, search='', category='', filters='', **kwargs):
|
||||
category_obj = request.registry.get('product.public.category')
|
||||
|
||||
category_ids = category_obj.search(request.cr, request.uid, [], context=request.context)
|
||||
category_list = category_obj.name_get(request.cr, request.uid, category_ids, context=request.context)
|
||||
category_list = sorted(category_list, key=lambda category: category[1])
|
||||
def product(self, product, category='', search='', **kwargs):
|
||||
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
||||
|
||||
if category:
|
||||
category = category_obj.browse(request.cr, request.uid, int(category), context=request.context)
|
||||
|
||||
request.context['pricelist'] = self.get_pricelist()
|
||||
attrib_values = map(int,request.httprequest.args.getlist('attrib'))
|
||||
attrib_set = set(attrib_values)
|
||||
|
||||
keep = QueryURL('/shop', category=category and category.id, search=search, attrib=attrib_set)
|
||||
|
||||
category_obj = pool['product.public.category']
|
||||
category_ids = category_obj.search(cr, uid, [], context=context)
|
||||
category_list = category_obj.name_get(cr, uid, category_ids, context=context)
|
||||
category_list = sorted(category_list, key=lambda category: category[1])
|
||||
|
||||
values = {
|
||||
'Ecommerce': self,
|
||||
'search': search,
|
||||
'category': category,
|
||||
'pricelist': self.get_pricelist(),
|
||||
'attrib_set': attrib_set,
|
||||
'keep': keep,
|
||||
'category_list': category_list,
|
||||
'main_object': product,
|
||||
'product': product,
|
||||
'search': {
|
||||
'search': search,
|
||||
'category': category and str(category.id),
|
||||
'filters': filters,
|
||||
}
|
||||
}
|
||||
return request.website.render("website_sale.product", values)
|
||||
|
||||
@http.route(['/shop/product/comment'], type='http', auth="public", methods=['POST'], website=True)
|
||||
@http.route(['/shop/product/comment/<int:product_template_id>'], type='http', auth="public", methods=['POST'], website=True)
|
||||
def product_comment(self, product_template_id, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
if post.get('comment'):
|
||||
|
@ -293,111 +203,59 @@ class Ecommerce(http.Controller):
|
|||
context=dict(context, mail_create_nosubcribe=True))
|
||||
return werkzeug.utils.redirect(request.httprequest.referrer + "#comments")
|
||||
|
||||
@http.route(['/shop/add_product/'], type='http', auth="user", methods=['POST'], website=True, multilang=True)
|
||||
def add_product(self, name="New Product", category=0, **post):
|
||||
Product = request.registry.get('product.product')
|
||||
product_id = Product.create(request.cr, request.uid, {
|
||||
'name': name, 'public_categ_id': category
|
||||
}, context=request.context)
|
||||
product = Product.browse(request.cr, request.uid, product_id, context=request.context)
|
||||
|
||||
return request.redirect("/shop/product/%s/?enable_editor=1" % product.product_tmpl_id.id)
|
||||
|
||||
@http.route(['/shop/mycart/'], type='http', auth="public", website=True, multilang=True)
|
||||
def mycart(self, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
prod_obj = request.registry.get('product.product')
|
||||
|
||||
# must have a draft sale order with lines at this point, otherwise reset
|
||||
order = self.get_order()
|
||||
if order and order.state != 'draft':
|
||||
request.registry['website'].sale_reset_order(cr, uid, context=context)
|
||||
return request.redirect('/shop/')
|
||||
|
||||
self.get_pricelist()
|
||||
|
||||
suggested_ids = []
|
||||
product_ids = []
|
||||
if order:
|
||||
for line in order.order_line:
|
||||
suggested_ids += [p.id for p in line.product_id and line.product_id.accessory_product_ids or []]
|
||||
product_ids.append(line.product_id.id)
|
||||
suggested_ids = list(set(suggested_ids) - set(product_ids))
|
||||
if suggested_ids:
|
||||
suggested_ids = prod_obj.search(cr, uid, [('id', 'in', suggested_ids)], context=context)
|
||||
|
||||
# select 3 random products
|
||||
suggested_products = []
|
||||
while len(suggested_products) < 3 and suggested_ids:
|
||||
index = random.randrange(0, len(suggested_ids))
|
||||
suggested_products.append(suggested_ids.pop(index))
|
||||
|
||||
context = dict(context or {}, pricelist=request.registry['website'].ecommerce_get_pricelist_id(cr, uid, None, context=context))
|
||||
|
||||
@http.route(['/shop/cart'], type='http', auth="public", website=True, multilang=True)
|
||||
def cart(self, **post):
|
||||
order = request.website.sale_get_order()
|
||||
values = {
|
||||
'int': int,
|
||||
'suggested_products': prod_obj.browse(cr, uid, suggested_products, context),
|
||||
'order': order,
|
||||
'suggested_products': [],
|
||||
}
|
||||
return request.website.render("website_sale.mycart", values)
|
||||
if order:
|
||||
values['suggested_products'] = order._cart_accessories()
|
||||
return request.website.render("website_sale.cart", values)
|
||||
|
||||
@http.route(['/shop/add_cart/'], type='http', auth="public", methods=['POST'], website=True, multilang=True)
|
||||
def add_cart(self, product_id, remove=None, **kw):
|
||||
request.registry['website']._ecommerce_add_product_to_cart(request.cr, request.uid,
|
||||
product_id=int(product_id),
|
||||
context=request.context)
|
||||
return request.redirect("/shop/mycart/")
|
||||
@http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True, multilang=True)
|
||||
def cart_update(self, product_id, add_qty=None, set_qty=None, **kw):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
request.website.sale_get_order(force_create=1)._cart_update(product_id=product_id, add_qty=add_qty, set_qty=set_qty)
|
||||
return request.redirect("/shop/cart")
|
||||
|
||||
@http.route(['/shop/change_cart/<int:order_line_id>/'], type='http', auth="public", website=True, multilang=True)
|
||||
def add_cart_order_line(self, order_line_id=None, remove=None, **kw):
|
||||
request.registry['website']._ecommerce_add_product_to_cart(request.cr, request.uid,
|
||||
order_line_id=order_line_id, number=(remove and -1 or 1),
|
||||
context=request.context)
|
||||
return request.redirect("/shop/mycart/")
|
||||
@http.route(['/shop/cart/update_json'], type='json', auth="public", website=True, multilang=True)
|
||||
def cart_update_json(self, product_id, add_qty=None, set_qty=None):
|
||||
order = request.website.sale_get_order(force_create=1)
|
||||
quantity = order._cart_update(product_id=product_id, add_qty=add_qty, set_qty=set_qty)
|
||||
return request.website._render("website_sale.total", {'website_sale_order': order}) # FIXME good template
|
||||
|
||||
@http.route(['/shop/add_cart_json/'], type='json', auth="public", website=True, multilang=True)
|
||||
def add_cart_json(self, product_id=None, order_line_id=None, remove=None):
|
||||
quantity = request.registry['website']._ecommerce_add_product_to_cart(request.cr, request.uid,
|
||||
product_id=product_id, order_line_id=order_line_id, number=(remove and -1 or 1),
|
||||
context=request.context)
|
||||
order = self.get_order()
|
||||
return [quantity,
|
||||
order.get_number_of_products(),
|
||||
order.amount_total,
|
||||
request.website._render("website_sale.total", {'website_sale_order': order})]
|
||||
|
||||
@http.route(['/shop/set_cart_json/'], type='json', auth="public")
|
||||
def set_cart_json(self, path=None, product_id=None, order_line_id=None, set_number=0, json=None):
|
||||
quantity = request.registry['website']._ecommerce_add_product_to_cart(request.cr, request.uid,
|
||||
product_id=product_id, order_line_id=order_line_id, set_number=set_number,
|
||||
context=request.context)
|
||||
return quantity
|
||||
|
||||
@http.route(['/shop/checkout/'], type='http', auth="public", website=True, multilang=True)
|
||||
def checkout(self, **post):
|
||||
#------------------------------------------------------
|
||||
# Checkout
|
||||
#------------------------------------------------------
|
||||
def checkout_redirection(self, order):
|
||||
cr, uid, context, registry = request.cr, request.uid, request.context, request.registry
|
||||
|
||||
# must have a draft sale order with lines at this point, otherwise reset
|
||||
order = self.get_order()
|
||||
if not order or order.state != 'draft' or not order.order_line:
|
||||
request.registry['website'].ecommerce_reset(cr, uid, context=context)
|
||||
return request.redirect('/shop/')
|
||||
if order.state != 'draft':
|
||||
request.website_sale_reset(cr, uid, context=context)
|
||||
return request.redirect('/shop')
|
||||
|
||||
# if transaction pending / done: redirect to confirmation
|
||||
tx = context.get('website_sale_transaction')
|
||||
if tx and tx.state != 'draft':
|
||||
return request.redirect('/shop/payment/confirmation/%s' % order.id)
|
||||
|
||||
self.get_pricelist()
|
||||
|
||||
def checkout_values(self):
|
||||
cr, uid, context, registry = request.cr, request.uid, request.context, request.registry
|
||||
orm_partner = registry.get('res.partner')
|
||||
orm_user = registry.get('res.users')
|
||||
orm_country = registry.get('res.country')
|
||||
state_orm = registry.get('res.country.state')
|
||||
|
||||
country_ids = orm_country.search(cr, SUPERUSER_ID, [], context=context)
|
||||
countries = orm_country.browse(cr, SUPERUSER_ID, country_ids, context)
|
||||
state_orm = registry.get('res.country.state')
|
||||
states_ids = state_orm.search(cr, SUPERUSER_ID, [], context=context)
|
||||
states = state_orm.browse(cr, SUPERUSER_ID, states_ids, context)
|
||||
|
||||
info = CheckoutInfo()
|
||||
|
||||
values = {
|
||||
'countries': countries,
|
||||
'states': states,
|
||||
|
@ -405,65 +263,60 @@ class Ecommerce(http.Controller):
|
|||
'shipping': post.get("shipping_different"),
|
||||
'error': {},
|
||||
}
|
||||
checkout = values['checkout']
|
||||
return values
|
||||
|
||||
partner = None
|
||||
public_id = request.registry['website'].get_public_user(cr, uid, context)
|
||||
if not request.uid == public_id:
|
||||
partner = orm_user.browse(cr, uid, uid, context).partner_id
|
||||
elif order.partner_id:
|
||||
domain = [("active", "=", False), ("partner_id", "=", order.partner_id.id)]
|
||||
user_ids = request.registry['res.users'].search(cr, SUPERUSER_ID, domain, context=context)
|
||||
if not user_ids or public_id not in user_ids:
|
||||
partner = orm_partner.browse(cr, SUPERUSER_ID, order.partner_id.id, context)
|
||||
|
||||
if partner:
|
||||
partner_info = info.from_partner(partner)
|
||||
checkout.update(partner_info)
|
||||
shipping_ids = orm_partner.search(cr, SUPERUSER_ID, [("parent_id", "=", partner.id), ('type', "=", 'delivery')], limit=1, context=context)
|
||||
if shipping_ids:
|
||||
values['shipping'] = "true"
|
||||
shipping_partner = orm_partner.browse(cr, SUPERUSER_ID, shipping_ids[0], context)
|
||||
checkout.update(info.from_partner(shipping_partner, address_type='shipping'))
|
||||
|
||||
return request.website.render("website_sale.checkout", values)
|
||||
|
||||
@http.route(['/shop/confirm_order/'], type='http', auth="public", website=True, multilang=True)
|
||||
def confirm_order(self, **post):
|
||||
def checkout_form_parse(self):
|
||||
cr, uid, context, registry = request.cr, request.uid, request.context, request.registry
|
||||
order_line_obj = request.registry.get('sale.order')
|
||||
|
||||
# must have a draft sale order with lines at this point, otherwise redirect to shop
|
||||
order = self.get_order()
|
||||
if not order or order.state != 'draft' or not order.order_line:
|
||||
request.registry['website'].ecommerce_reset(cr, uid, context=context)
|
||||
return request.redirect('/shop/')
|
||||
# if transaction pending / done: redirect to confirmation
|
||||
tx = context.get('website_sale_transaction')
|
||||
if tx and tx.state != 'draft':
|
||||
return request.redirect('/shop/payment/confirmation/%s' % order.id)
|
||||
#public_id = request.registry['website'].get_public_user(cr, uid, context)
|
||||
#if not request.uid == public_id:
|
||||
# partner = orm_user.browse(cr, uid, uid, context).partner_id
|
||||
|
||||
orm_partner = registry.get('res.partner')
|
||||
orm_user = registry.get('res.users')
|
||||
orm_country = registry.get('res.country')
|
||||
country_ids = orm_country.search(cr, SUPERUSER_ID, [], context=context)
|
||||
countries = orm_country.browse(cr, SUPERUSER_ID, country_ids, context)
|
||||
orm_state = registry.get('res.country.state')
|
||||
states_ids = orm_state.search(cr, SUPERUSER_ID, [], context=context)
|
||||
states = orm_state.browse(cr, SUPERUSER_ID, states_ids, context)
|
||||
#elif order.partner_id:
|
||||
# domain = [("active", "=", False), ("partner_id", "=", order.partner_id.id)]
|
||||
|
||||
info = CheckoutInfo()
|
||||
values = {
|
||||
'countries': countries,
|
||||
'states': states,
|
||||
'checkout': info.empty(),
|
||||
'shipping': post.get("shipping_different"),
|
||||
'error': {},
|
||||
}
|
||||
checkout = values['checkout']
|
||||
checkout.update(post)
|
||||
error = values['error']
|
||||
# user_ids = request.registry['res.users'].search(cr, SUPERUSER_ID, domain, context=context)
|
||||
# if not user_ids or public_id not in user_ids:
|
||||
# partner = orm_partner.browse(cr, SUPERUSER_ID, order.partner_id.id, context)
|
||||
|
||||
#if partner:
|
||||
# partner_info = info.from_partner(partner)
|
||||
# checkout.update(partner_info)
|
||||
# shipping_ids = orm_partner.search(cr, SUPERUSER_ID, [("parent_id", "=", partner.id), ('type', "=", 'delivery')], limit=1, context=context)
|
||||
# if shipping_ids:
|
||||
# values['shipping'] = "true"
|
||||
# shipping_partner = orm_partner.browse(cr, SUPERUSER_ID, shipping_ids[0], context)
|
||||
# checkout.update(info.from_partner(shipping_partner, address_type='shipping'))
|
||||
|
||||
# from query
|
||||
query = dict((field_name, post[field_name]) for field_name in self.all_fields() if post[field_name])
|
||||
|
||||
# fill with partner
|
||||
assert address_type in ('billing', 'shipping')
|
||||
if address_type == 'billing':
|
||||
prefix = ''
|
||||
else:
|
||||
prefix = 'shipping_'
|
||||
result = dict((prefix + field_name, getattr(partner, field_name)) for field_name in self.string_billing_fields if getattr(partner, field_name))
|
||||
result[prefix + 'state_id'] = partner.state_id and partner.state_id.id or ''
|
||||
result[prefix + 'country_id'] = partner.country_id and partner.country_id.id or ''
|
||||
result[prefix + 'company'] = partner.parent_id and partner.parent_id.name or ''
|
||||
return result
|
||||
|
||||
mandatory_billing_fields = ["name", "phone", "email", "street", "city", "country_id", "zip"]
|
||||
optional_billing_fields = ["company", "state_id"]
|
||||
#string_billing_fields = ["name", "phone", "email", "street", "city", "zip"]
|
||||
|
||||
mandatory_shipping_fields = ["name", "phone", "street", "city", "country_id", "zip"]
|
||||
optional_shipping_field = ["state_id"]
|
||||
#string_shipping_fields = ["name", "phone", "street", "city", "zip"]
|
||||
|
||||
return values
|
||||
|
||||
def checkout_form_validate(self):
|
||||
cr, uid, context, registry = request.cr, request.uid, request.context, request.registry
|
||||
|
||||
# Validation
|
||||
for field_name in info.mandatory_billing_fields:
|
||||
if not checkout[field_name]:
|
||||
error[field_name] = 'missing'
|
||||
|
@ -471,9 +324,12 @@ class Ecommerce(http.Controller):
|
|||
for field_name in info.mandatory_shipping_fields:
|
||||
if not checkout[field_name]:
|
||||
error[field_name] = 'missing'
|
||||
if error:
|
||||
return request.website.render("website_sale.checkout", values)
|
||||
|
||||
return values
|
||||
|
||||
def checkout_form_save(self):
|
||||
|
||||
# save partner for order
|
||||
company_name = checkout['company']
|
||||
company_id = None
|
||||
if post['company']:
|
||||
|
@ -533,9 +389,50 @@ class Ecommerce(http.Controller):
|
|||
|
||||
order_line_obj.write(cr, SUPERUSER_ID, [order.id], order_info, context=context)
|
||||
|
||||
return request.redirect("/shop/payment/")
|
||||
@http.route(['/shop/checkout'], type='http', auth="public", website=True, multilang=True)
|
||||
def checkout(self, **post):
|
||||
cr, uid, context, registry = request.cr, request.uid, request.context, request.registry
|
||||
|
||||
@http.route(['/shop/payment/'], type='http', auth="public", website=True, multilang=True)
|
||||
order = request.website.sale_get_order(cr, uid, force_create=1, context=context)
|
||||
|
||||
redirection = checkout_redirection(order)
|
||||
if redirection:
|
||||
return redirection
|
||||
|
||||
values = self.checkout_values()
|
||||
checkout = values['checkout']
|
||||
|
||||
partner = None
|
||||
return request.website.render("website_sale.checkout", values)
|
||||
|
||||
@http.route(['/shop/confirm_order'], type='http', auth="public", website=True, multilang=True)
|
||||
def confirm_order(self, **post):
|
||||
cr, uid, context, registry = request.cr, request.uid, request.context, request.registry
|
||||
order_line_obj = request.registry.get('sale.order')
|
||||
|
||||
order = request.website.sale_get_order(cr, uid, context=context)
|
||||
|
||||
redirection = checkout_redirection(order)
|
||||
if redirection:
|
||||
return redirection
|
||||
|
||||
values = self.checkout_values()
|
||||
checkout = values['checkout']
|
||||
checkout.update(post)
|
||||
error = values['error']
|
||||
|
||||
if error:
|
||||
return request.website.render("website_sale.checkout", values)
|
||||
|
||||
checkout_form_save()
|
||||
|
||||
return request.redirect("/shop/payment")
|
||||
|
||||
#------------------------------------------------------
|
||||
# Payment
|
||||
#------------------------------------------------------
|
||||
|
||||
@http.route(['/shop/payment'], type='http', auth="public", website=True, multilang=True)
|
||||
def payment(self, **post):
|
||||
""" Payment step. This page proposes several payment means based on available
|
||||
payment.acquirer. State at this point :
|
||||
|
@ -549,15 +446,9 @@ class Ecommerce(http.Controller):
|
|||
cr, uid, context = request.cr, request.uid, request.context
|
||||
payment_obj = request.registry.get('payment.acquirer')
|
||||
|
||||
# if no sale order at this stage: back to checkout beginning
|
||||
order = self.get_order()
|
||||
if not order or order.state != 'draft' or not order.order_line:
|
||||
request.registry['website'].ecommerce_reset(cr, uid, context=context)
|
||||
return request.redirect("/shop/")
|
||||
# alread a transaction: forward to confirmation
|
||||
tx = context.get('website_sale_transaction')
|
||||
if tx and tx.state != 'draft':
|
||||
return request.redirect('/shop/confirmation/%s' % order.id)
|
||||
redirection = checkout_redirection(order)
|
||||
if redirection:
|
||||
return redirection
|
||||
|
||||
shipping_partner_id = False
|
||||
if order:
|
||||
|
@ -593,8 +484,7 @@ class Ecommerce(http.Controller):
|
|||
|
||||
return request.website.render("website_sale.payment", values)
|
||||
|
||||
@http.route(['/shop/payment/transaction/<int:acquirer_id>'],
|
||||
type='http', methods=['POST'], auth="public", website=True)
|
||||
@http.route(['/shop/payment/transaction/<int:acquirer_id>'], type='http', methods=['POST'], auth="public", website=True)
|
||||
def payment_transaction(self, acquirer_id, **post):
|
||||
""" Hook method that creates a payment.transaction and redirect to the
|
||||
acquirer, using post values to re-create the post action.
|
||||
|
@ -609,7 +499,7 @@ class Ecommerce(http.Controller):
|
|||
cr, uid, context = request.cr, request.uid, request.context
|
||||
payment_obj = request.registry.get('payment.acquirer')
|
||||
transaction_obj = request.registry.get('payment.transaction')
|
||||
order = self.get_order()
|
||||
order = request.website.sale_get_order(cr, uid, context=context)
|
||||
|
||||
if not order or not order.order_line or acquirer_id is None:
|
||||
return request.redirect("/shop/checkout/")
|
||||
|
@ -684,7 +574,7 @@ class Ecommerce(http.Controller):
|
|||
'validation': validation
|
||||
}
|
||||
|
||||
@http.route('/shop/payment/validate/', type='http', auth="public", website=True, multilang=True)
|
||||
@http.route('/shop/payment/validate', type='http', auth="public", website=True, multilang=True)
|
||||
def payment_validate(self, transaction_id=None, sale_order_id=None, **post):
|
||||
""" Method that should be called by the server when receiving an update
|
||||
for a transaction. State at this point :
|
||||
|
@ -701,7 +591,7 @@ class Ecommerce(http.Controller):
|
|||
tx = request.registry['payment.transaction'].browse(cr, uid, transaction_id, context=context)
|
||||
|
||||
if sale_order_id is None:
|
||||
order = self.get_order()
|
||||
order = request.website.sale_get_order(cr, uid, context=context)
|
||||
else:
|
||||
order = request.registry['sale.order'].browse(cr, SUPERUSER_ID, sale_order_id, context=context)
|
||||
assert order.website_session_id == request.httprequest.session['website_session_id']
|
||||
|
@ -744,19 +634,24 @@ class Ecommerce(http.Controller):
|
|||
|
||||
return request.website.render("website_sale.confirmation", {'order': order})
|
||||
|
||||
@http.route(['/shop/change_sequence/'], type='json', auth="public")
|
||||
def change_sequence(self, id, sequence):
|
||||
product_obj = request.registry.get('product.template')
|
||||
if sequence == "top":
|
||||
product_obj.set_sequence_top(request.cr, request.uid, [id], context=request.context)
|
||||
elif sequence == "bottom":
|
||||
product_obj.set_sequence_bottom(request.cr, request.uid, [id], context=request.context)
|
||||
elif sequence == "up":
|
||||
product_obj.set_sequence_up(request.cr, request.uid, [id], context=request.context)
|
||||
elif sequence == "down":
|
||||
product_obj.set_sequence_down(request.cr, request.uid, [id], context=request.context)
|
||||
#------------------------------------------------------
|
||||
# Edit
|
||||
#------------------------------------------------------
|
||||
|
||||
@http.route(['/shop/change_styles/'], type='json', auth="public")
|
||||
@http.route(['/shop/add_product'], type='http', auth="user", methods=['POST'], website=True, multilang=True)
|
||||
def add_product(self, name="New Product", category=0, **post):
|
||||
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
||||
product_obj = pool['product.product']
|
||||
product_id = product_obj.create(cr, uid, { 'name': name, 'public_categ_id': category }, context=context)
|
||||
product = product_obj.browse(cr, uid, product_id, context=request.context)
|
||||
|
||||
return request.redirect("/shop/product/%s/?enable_editor=1" % product.product_tmpl_id.id)
|
||||
|
||||
@http.route(['/shop/reorder'], type='json', auth="public")
|
||||
def reorder(self, product_id, operation):
|
||||
request.registry['product.template'].website_reorder(request.cr, request.uid, [id], operation, context=request.context)
|
||||
|
||||
@http.route(['/shop/change_styles'], type='json', auth="public")
|
||||
def change_styles(self, id, style_id):
|
||||
product_obj = request.registry.get('product.template')
|
||||
product = product_obj.browse(request.cr, request.uid, id, context=request.context)
|
||||
|
@ -778,10 +673,11 @@ class Ecommerce(http.Controller):
|
|||
|
||||
return not active
|
||||
|
||||
@http.route(['/shop/change_size/'], type='json', auth="public")
|
||||
@http.route(['/shop/change_size'], type='json', auth="public")
|
||||
def change_size(self, id, x, y):
|
||||
product_obj = request.registry.get('product.template')
|
||||
product = product_obj.browse(request.cr, request.uid, id, context=request.context)
|
||||
return product.write({'website_size_x': x, 'website_size_y': y})
|
||||
|
||||
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<data noupdate="1">
|
||||
|
||||
<record id="product.group_product_attributes" model="res.groups">
|
||||
<field name="name">Product attribute (not supported)</field>
|
||||
<field name="name">Product Attributes</field>
|
||||
<field name="category_id" ref="base.module_category_hidden"/>
|
||||
</record>
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
<field name="website_size_x">2</field>
|
||||
<field name="website_size_y">2</field>
|
||||
<field name="website_sequence">5</field>
|
||||
<field name="website_style_ids" eval="[(6,0,[ref('website_sale.image_full')])]"/>
|
||||
<field name="website_style_ids" eval="[(6,0,[ref('website_sale.style_image_full')])]"/>
|
||||
<field name="website_description" type="html">
|
||||
<section data-snippet-id="text-image" class="mt16 mb16 oe_dark">
|
||||
<div class="container">
|
||||
|
@ -59,7 +59,7 @@
|
|||
<record id="product.product_product_5" model="product.product">
|
||||
<field name="website_published" eval="True"/>
|
||||
<field name="website_size_x">2</field>
|
||||
<field name="website_style_ids" eval="[(6,0,[ref('website_sale.image_promo')])]"/>
|
||||
<field name="website_style_ids" eval="[(6,0,[ref('website_sale.style_image_promo')])]"/>
|
||||
<field name="website_description" type="html">
|
||||
<section data-snippet-id="text-image" class="mt16 mb16">
|
||||
<div class="container">
|
||||
|
@ -165,7 +165,7 @@
|
|||
<record id="product.product_product_6" model="product.product">
|
||||
<field name="website_published" eval="True"/>
|
||||
<field name="website_sequence">4</field>
|
||||
<field name="website_style_ids" eval="[(6,0,[ref('website_sale.image_full')])]"/>
|
||||
<field name="website_style_ids" eval="[(6,0,[ref('website_sale.style_image_full')])]"/>
|
||||
<field name="description_sale">Color: White
|
||||
Capacity: 16GB
|
||||
Connectivity: Wifi
|
||||
|
@ -273,7 +273,7 @@ iOS7
|
|||
</section>
|
||||
</field>
|
||||
<field name="website_sequence">4</field>
|
||||
<field name="website_style_ids" eval="[(6,0,[ref('website_sale.image_full')])]"/>
|
||||
<field name="website_style_ids" eval="[(6,0,[ref('website_sale.style_image_full')])]"/>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_7" model="product.product">
|
|
@ -1,7 +1,3 @@
|
|||
import website_styles
|
||||
import payment_transaction
|
||||
import product
|
||||
import product_characteristics
|
||||
import res_config
|
||||
import sale_order
|
||||
import website
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class PaymentTransaction(orm.Model):
|
||||
_inherit = 'payment.transaction'
|
||||
|
||||
_columns = {
|
||||
# link with the sale order
|
||||
'sale_order_id': fields.many2one('sale.order', 'Sale Order'),
|
||||
}
|
|
@ -21,6 +21,39 @@
|
|||
|
||||
from openerp.osv import osv, fields
|
||||
|
||||
class product_attribue(osv.Model):
|
||||
# TODO merge product.attribute, mrp.properties product_manufacturer_attributes
|
||||
_name = "product.attribute"
|
||||
_columns = {
|
||||
'name': fields.char('Name', translate=True, required=True),
|
||||
'value_ids': fields.one2many('product.attribute.value', 'attribute_id', 'Values'),
|
||||
}
|
||||
|
||||
class product_attribute_value(osv.Model):
|
||||
_name = "product.attribute.value"
|
||||
_columns = {
|
||||
'attribute_id': fields.many2one('product.attribute', 'attribute', required=True),
|
||||
'name': fields.char('Value', translate=True, required=True),
|
||||
}
|
||||
|
||||
class product_attribute_line(osv.Model):
|
||||
_name = "product.attribute.line"
|
||||
_order = 'attribute_id, value_id'
|
||||
_columns = {
|
||||
'product_tmpl_id': fields.many2one('product.template', 'Product', required=True),
|
||||
'attribute_id': fields.many2one('product.attribute', 'attribute', required=True),
|
||||
'value_id': fields.many2one('product.attribute.value', 'Textual Value'),
|
||||
}
|
||||
|
||||
def onchange_attribute_id(self, cr, uid, ids, attribute_id, context=None):
|
||||
return {'value': {'value_id': False}}
|
||||
|
||||
class product_style(osv.Model):
|
||||
_name = "product.style"
|
||||
_columns = {
|
||||
'name' : fields.char('Style Name', required=True),
|
||||
'html_class': fields.char('HTML Classes'),
|
||||
}
|
||||
|
||||
class product_pricelist(osv.Model):
|
||||
_inherit = "product.pricelist"
|
||||
|
@ -28,7 +61,6 @@ class product_pricelist(osv.Model):
|
|||
'code': fields.char('Promotional Code'),
|
||||
}
|
||||
|
||||
|
||||
class product_template(osv.Model):
|
||||
_inherit = ["product.template", "website.seo.metadata"]
|
||||
_order = 'website_published desc, website_sequence desc, name'
|
||||
|
@ -42,104 +74,77 @@ class product_template(osv.Model):
|
|||
return res
|
||||
|
||||
_columns = {
|
||||
'website_published': fields.boolean('Available in the website'),
|
||||
'website_description': fields.html('Description for the website'),
|
||||
# TDE TODO FIXME: when website_mail/mail_thread.py inheritance work -> this field won't be necessary
|
||||
'attribute_lines': fields.one2many('product.attribute.line', 'product_tmpl_id', 'Product attributes'),
|
||||
# TODO FIXME tde: when website_mail/mail_thread.py inheritance work -> this field won't be necessary
|
||||
'website_message_ids': fields.one2many(
|
||||
'mail.message', 'res_id',
|
||||
domain=lambda self: [
|
||||
'&', ('model', '=', self._name), ('type', '=', 'comment')
|
||||
],
|
||||
string='Website Messages',
|
||||
help="Website communication history",
|
||||
string='Website Comments',
|
||||
),
|
||||
'website_published': fields.boolean('Available in the website'),
|
||||
'website_description': fields.html('Description for the website'),
|
||||
'alternative_product_ids': fields.many2many('product.template','product_alternative_rel','src_id','dest_id', string='Alternative Products', help='Appear on the product page'),
|
||||
'accessory_product_ids': fields.many2many('product.template','product_accessory_rel','src_id','dest_id', string='Accessory Products', help='Appear on the shopping cart'),
|
||||
'website_size_x': fields.integer('Size X'),
|
||||
'website_size_y': fields.integer('Size Y'),
|
||||
'website_style_ids': fields.many2many('product.style', 'product_website_style_rel', 'product_id', 'style_id', 'Styles'),
|
||||
'website_style_ids': fields.many2many('product.style', string='Styles'),
|
||||
'website_sequence': fields.integer('Sequence', help="Determine the display order in the Website E-commerce"),
|
||||
'website_url': fields.function(_website_url, string="Website url", type="char"),
|
||||
}
|
||||
|
||||
def __defaults_website_sequence(self, cr, uid, *kwargs):
|
||||
cr.execute('SELECT MAX(website_sequence) FROM product_template')
|
||||
max_sequence = cr.fetchone()[0] or 0
|
||||
return max_sequence + 1
|
||||
def _defaults_website_sequence(self, cr, uid, *l, **kwargs):
|
||||
cr.execute('SELECT MAX(website_sequence)+1 FROM product_template')
|
||||
next_sequence = cr.fetchone()[0] or 0
|
||||
return next_sequence
|
||||
|
||||
_defaults = {
|
||||
'website_size_x': 1,
|
||||
'website_size_y': 1,
|
||||
'website_sequence': __defaults_website_sequence,
|
||||
'website_sequence': _defaults_website_sequence,
|
||||
'website_published': False,
|
||||
}
|
||||
|
||||
def set_sequence_top(self, cr, uid, ids, context=None):
|
||||
cr.execute('SELECT MAX(website_sequence) FROM product_template')
|
||||
max_sequence = cr.fetchone()[0] or 0
|
||||
return self.write(cr, uid, ids, {'website_sequence': max_sequence + 1}, context=context)
|
||||
|
||||
def set_sequence_bottom(self, cr, uid, ids, context=None):
|
||||
cr.execute('SELECT MIN(website_sequence) FROM product_template')
|
||||
min_sequence = cr.fetchone()[0] or 0
|
||||
return self.write(cr, uid, ids, {'website_sequence': min_sequence -1}, context=context)
|
||||
|
||||
def set_sequence_up(self, cr, uid, ids, context=None):
|
||||
product = self.browse(cr, uid, ids[0], context=context)
|
||||
cr.execute(""" SELECT id, website_sequence FROM product_template
|
||||
WHERE website_sequence > %s AND website_published = %s ORDER BY website_sequence ASC LIMIT 1""" % (product.website_sequence, product.website_published))
|
||||
prev = cr.fetchone()
|
||||
if prev:
|
||||
self.write(cr, uid, [prev[0]], {'website_sequence': product.website_sequence}, context=context)
|
||||
return self.write(cr, uid, [ids[0]], {'website_sequence': prev[1]}, context=context)
|
||||
else:
|
||||
return self.set_sequence_top(cr, uid, ids, context=context)
|
||||
|
||||
def set_sequence_down(self, cr, uid, ids, context=None):
|
||||
product = self.browse(cr, uid, ids[0], context=context)
|
||||
cr.execute(""" SELECT id, website_sequence FROM product_template
|
||||
WHERE website_sequence < %s AND website_published = %s ORDER BY website_sequence DESC LIMIT 1""" % (product.website_sequence, product.website_published))
|
||||
next = cr.fetchone()
|
||||
if next:
|
||||
self.write(cr, uid, [next[0]], {'website_sequence': product.website_sequence}, context=context)
|
||||
return self.write(cr, uid, [ids[0]], {'website_sequence': next[1]}, context=context)
|
||||
else:
|
||||
return self.set_sequence_bottom(cr, uid, ids, context=context)
|
||||
|
||||
def recommended_products(self, cr, uid, ids, context=None):
|
||||
id = ids[0]
|
||||
product_ids = []
|
||||
query = """
|
||||
SELECT sol.product_id
|
||||
FROM sale_order_line as my
|
||||
LEFT JOIN sale_order_line as sol
|
||||
ON sol.order_id = my.order_id
|
||||
WHERE my.product_id in (%s)
|
||||
AND sol.product_id not in (%s)
|
||||
GROUP BY sol.product_id
|
||||
ORDER BY COUNT(sol.order_id) DESC
|
||||
LIMIT 10
|
||||
"""
|
||||
cr.execute(query, (id, id))
|
||||
for p in cr.fetchall():
|
||||
product_ids.append(p[0])
|
||||
|
||||
# search to apply access rules
|
||||
product_ids = self.search(cr, uid, [("id", "in", product_ids)], limit=3)
|
||||
return self.browse(cr, uid, product_ids)
|
||||
def website_reorder(self, cr, uid, ids, operation=None, context=None):
|
||||
if operation == "top":
|
||||
cr.execute('SELECT MAX(website_sequence) FROM product_template')
|
||||
seq = (cr.fetchone()[0] or 0) + 1
|
||||
if operation == "bottom":
|
||||
cr.execute('SELECT MIN(website_sequence) FROM product_template')
|
||||
seq = (cr.fetchone()[0] or 0) -1
|
||||
if operation == "up":
|
||||
product = self.browse(cr, uid, ids[0], context=context)
|
||||
cr.execute(""" SELECT id, website_sequence FROM product_template
|
||||
WHERE website_sequence > %s AND website_published = %s ORDER BY website_sequence ASC LIMIT 1""" % (product.website_sequence, product.website_published))
|
||||
prev = cr.fetchone()
|
||||
if prev:
|
||||
self.write(cr, uid, [prev[0]], {'website_sequence': product.website_sequence}, context=context)
|
||||
return self.write(cr, uid, [ids[0]], {'website_sequence': prev[1]}, context=context)
|
||||
else:
|
||||
return self.website_reorder(cr, uid, ids, operation='top', context=context)
|
||||
if operation == "down":
|
||||
product = self.browse(cr, uid, ids[0], context=context)
|
||||
cr.execute(""" SELECT id, website_sequence FROM product_template
|
||||
WHERE website_sequence < %s AND website_published = %s ORDER BY website_sequence DESC LIMIT 1""" % (product.website_sequence, product.website_published))
|
||||
next = cr.fetchone()
|
||||
if next:
|
||||
self.write(cr, uid, [next[0]], {'website_sequence': product.website_sequence}, context=context)
|
||||
return self.write(cr, uid, [ids[0]], {'website_sequence': next[1]}, context=context)
|
||||
else:
|
||||
return self.website_reorder(cr, uid, ids, operation='bottom', context=context)
|
||||
return self.write(cr, uid, ids, {'website_sequence': seq}, context=context)
|
||||
|
||||
def img(self, cr, uid, ids, field='image_small', context=None):
|
||||
return "/website/image?model=%s&field=%s&id=%s" % (self._name, field, ids[0])
|
||||
|
||||
|
||||
class product_product(osv.Model):
|
||||
_inherit = "product.product"
|
||||
|
||||
def _website_url(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = {}
|
||||
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
|
||||
for product in self.browse(cr, uid, ids, context=context):
|
||||
res[product.id] = "%s/shop/product/%s/" % (base_url, product.product_tmpl_id.id)
|
||||
res[product.id] = "/shop/product/%s" % (product.product_tmpl_id.id)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
|
@ -149,3 +154,5 @@ class product_product(osv.Model):
|
|||
def img(self, cr, uid, ids, field='image_small', context=None):
|
||||
temp_id = self.browse(cr, uid, ids[0], context=context).product_tmpl_id.id
|
||||
return "/website/image?model=product.template&field=%s&id=%s" % (field, temp_id)
|
||||
|
||||
# vim:et:
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
|
||||
from openerp.osv import osv, fields
|
||||
|
||||
|
||||
class attributes(osv.Model):
|
||||
_name = "product.attribute"
|
||||
|
||||
def _get_float_max(self, cr, uid, ids, field_name, arg, context=None):
|
||||
result = dict.fromkeys(ids, 0)
|
||||
if ids:
|
||||
cr.execute("""
|
||||
SELECT attribute_id, MAX(value)
|
||||
FROM product_attribute_line
|
||||
WHERE attribute_id in (%s)
|
||||
GROUP BY attribute_id
|
||||
""" % ",".join(map(str, ids)))
|
||||
result.update(dict(cr.fetchall()))
|
||||
return result
|
||||
|
||||
def _get_float_min(self, cr, uid, ids, field_name, arg, context=None):
|
||||
result = dict.fromkeys(ids, 0)
|
||||
if ids:
|
||||
cr.execute("""
|
||||
SELECT attribute_id, MIN(value)
|
||||
FROM product_attribute_line
|
||||
WHERE attribute_id in (%s)
|
||||
GROUP BY attribute_id
|
||||
""" % ",".join(map(str, ids)))
|
||||
result.update(dict(cr.fetchall()))
|
||||
return result
|
||||
|
||||
def _get_min_max(self, cr, uid, ids, context=None):
|
||||
result = {}
|
||||
for value in self.pool.get('product.attribute.line').browse(cr, uid, ids, context=context):
|
||||
if value.type == 'float':
|
||||
result[value.attribute_id.id] = True
|
||||
return result.keys()
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', translate=True, required=True),
|
||||
'type': fields.selection([('distinct', 'Textual Value'), ('float', 'Numeric Value')], "Type", required=True),
|
||||
'value_ids': fields.one2many('product.attribute.value', 'attribute_id', 'Values'),
|
||||
'attr_product_ids': fields.one2many('product.attribute.line', 'attribute_id', 'Products'),
|
||||
|
||||
'float_max': fields.function(_get_float_max, type='float', string="Max", store={
|
||||
'product.attribute.line': (_get_min_max, ['value','attribute_id'], 20),
|
||||
}),
|
||||
'float_min': fields.function(_get_float_min, type='float', string="Min", store={
|
||||
'product.attribute.line': (_get_min_max, ['value','attribute_id'], 20),
|
||||
}),
|
||||
'visible': fields.boolean('Display Filter on Website'),
|
||||
}
|
||||
_defaults = {
|
||||
'type': 'distinct',
|
||||
'visible': True,
|
||||
}
|
||||
|
||||
class attributes_value(osv.Model):
|
||||
_name = "product.attribute.value"
|
||||
_columns = {
|
||||
'name': fields.char('Value', translate=True, required=True),
|
||||
'attribute_id': fields.many2one('product.attribute', 'attribute', required=True),
|
||||
'atr_product_ids': fields.one2many('product.attribute.line', 'value_id', 'Products'),
|
||||
}
|
||||
|
||||
class attributes_product(osv.Model):
|
||||
_name = "product.attribute.line"
|
||||
_order = 'attribute_id, value_id, value'
|
||||
_columns = {
|
||||
'value': fields.float('Numeric Value'),
|
||||
'value_id': fields.many2one('product.attribute.value', 'Textual Value'),
|
||||
'attribute_id': fields.many2one('product.attribute', 'attribute', required=True),
|
||||
'product_tmpl_id': fields.many2one('product.template', 'Product', required=True),
|
||||
|
||||
'type': fields.related('attribute_id', 'type', type='selection',
|
||||
selection=[('distinct', 'Distinct'), ('float', 'Float')], string='Type'),
|
||||
}
|
||||
|
||||
def onchange_attribute_id(self, cr, uid, ids, attribute_id, context=None):
|
||||
attribute = self.pool.get('product.attribute').browse(cr, uid, attribute_id, context=context)
|
||||
return {'value': {'type': attribute.type, 'value_id': False, 'value': ''}}
|
||||
|
||||
class product_template(osv.Model):
|
||||
_inherit = "product.template"
|
||||
_columns = {
|
||||
'attribute_lines': fields.one2many('product.attribute.line', 'product_tmpl_id', 'Product attributes'),
|
||||
}
|
|
@ -1,14 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import random
|
||||
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.osv import osv, fields
|
||||
from openerp.osv import osv, orm, fields
|
||||
from openerp.addons.web.http import request
|
||||
|
||||
class payment_transaction(orm.Model):
|
||||
_inherit = 'payment.transaction'
|
||||
|
||||
class SaleOrder(osv.Model):
|
||||
_columns = {
|
||||
# link with the sale order
|
||||
'sale_order_id': fields.many2one('sale.order', 'Sale Order'),
|
||||
}
|
||||
|
||||
class sale_order(osv.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
_columns = {
|
||||
'website_session_id': fields.char('Session UUID4'),
|
||||
'website_order_line': fields.one2many(
|
||||
'sale.order.line', 'order_id',
|
||||
string='Order Lines displayed on Website', readonly=True,
|
||||
|
@ -22,29 +30,144 @@ class SaleOrder(osv.Model):
|
|||
'order': order
|
||||
}
|
||||
|
||||
def get_number_of_products(self, cr, uid, ids, context=None):
|
||||
order = self.browse(cr, uid, ids[0], context=context)
|
||||
return int(sum(l.product_uom_qty for l in (order.website_order_line or [])))
|
||||
# TODO make a function field instead
|
||||
def _cart_qty(self, cr, uid, ids, context=None):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
return int(sum(l.product_uom_qty for l in (order.website_order_line or [])))
|
||||
|
||||
def _cart_find_product_line(self, cr, uid, ids, product_id=None, context=None):
|
||||
for so in self.browse(cr, uid, ids, context=context):
|
||||
line_id = None
|
||||
line_ids = self.pool.get('sale.order.line').search(cr, SUPERUSER_ID, [('order_id', '=', so.id), ('product_id', '=', product_id)], context=context)
|
||||
if line_ids:
|
||||
line_id = line_ids[0]
|
||||
return line_id
|
||||
|
||||
class SaleOrderLine(osv.Model):
|
||||
_inherit = "sale.order.line"
|
||||
def _cart_update(self, cr, uid, ids, product_id=None, add_qty=None, set_qty=None, context=None):
|
||||
""" Add or set product quantity, add_qty can be negative """
|
||||
for so in self.browse(cr, uid, ids, context=context):
|
||||
sol = self.pool.get('sale.order.line')
|
||||
|
||||
def _recalculate_product_values(self, cr, uid, ids, product_id=0, context=None):
|
||||
# TDE FIXME: seems to be defined several times -> fix me ?
|
||||
if context is None:
|
||||
context = {}
|
||||
user_obj = self.pool.get('res.users')
|
||||
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
|
||||
line_id = so._cart_find_product_line(product_id)
|
||||
|
||||
if ids and not product_id:
|
||||
order_line = self.browse(cr, SUPERUSER_ID, ids[0], context=context)
|
||||
assert order_line.order_id.website_session_id == request.httprequest.session['website_session_id']
|
||||
product_id = product_id or order_line.product_id.id
|
||||
# Create line if no line with product_id can be located
|
||||
if not line_id:
|
||||
values = self.pool['sale.order.line'].product_id_change(cr, SUPERUSER_ID, [],
|
||||
pricelist=so.pricelist_id.id,
|
||||
product=product_id,
|
||||
partner_id=so.partner_id.id,
|
||||
context=context
|
||||
)['value']
|
||||
values['name'] = "%s: %s" % (product.name, product.variants) if product.variants else product.name
|
||||
# Maybe it's better to do this ? create and then link ?
|
||||
#order_line_id = sol.create(cr, SUPERUSER_ID, values, context=context)
|
||||
#self.write(cr, SUPERUSER_ID, [order.id], {'order_line': [(4, order_line_id)]}, context=context)
|
||||
so.write({'order_line': (0, 0, values)})
|
||||
line_id = so._cart_find_product_line(product_id)
|
||||
|
||||
return self.product_id_change(
|
||||
cr, SUPERUSER_ID, ids,
|
||||
pricelist=context.pop('pricelist'),
|
||||
product=product_id,
|
||||
partner_id=user_obj.browse(cr, SUPERUSER_ID, uid).partner_id.id,
|
||||
context=context
|
||||
)['value']
|
||||
# compute new quantity
|
||||
if set_qty:
|
||||
quantity = set_qty
|
||||
else:
|
||||
quantity = line_id.product_uom_qty + add_qty
|
||||
|
||||
# Remove zero of negative lines
|
||||
if quantity <= 0:
|
||||
sol.unlink(cr, SUPERUSER_ID, line_id, context=context)
|
||||
else:
|
||||
# update line
|
||||
values = self.pool['sale.order.line'].product_id_change(cr, SUPERUSER_ID, [],
|
||||
pricelist=so.pricelist_id.id,
|
||||
product=product_id,
|
||||
partner_id=so.partner_id.id,
|
||||
context=context
|
||||
)['value']
|
||||
values['name'] = "%s: %s" % (product.name, product.variants) if product.variants else product.name
|
||||
values['product_uom_qty'] = quantity
|
||||
sol.write(cr, SUPERUSER_ID, [line_id], values, context=context)
|
||||
|
||||
return quantity
|
||||
|
||||
def _cart_accessories(self, cr, uid, ids, context=None):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
s = set(j for l in (order.website_order_line or []) for j in (l.product_id.accessory_product_ids or []))
|
||||
product_ids = random.sample(s, min(len(s),3))
|
||||
return self.pool['product.product'].browse(cr, uid, product_ids, context=context)
|
||||
|
||||
class website(orm.Model):
|
||||
_inherit = 'website'
|
||||
|
||||
_columns = {
|
||||
'pricelist_id': fields.related('user_id','partner_id','property_product_pricelist',
|
||||
type='many2one', relation='product.pricelist', string='Default pricelist')
|
||||
}
|
||||
|
||||
def sale_product_domain(self, cr, uid, ids, context=None):
|
||||
return [("sale_ok", "=", True)]
|
||||
|
||||
def sale_get_order(self, cr, uid, ids, force_create=False, code=None, context=None):
|
||||
sale_order_id = request.httprequest.session.get('sale_order_id')
|
||||
sale_order = None
|
||||
# create so if needed
|
||||
if not sale_order_id and (force_create or code):
|
||||
for w in self.browse(cr, uid, ids):
|
||||
# TODO cache partner_id session
|
||||
partner = self.pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=context).partner_id
|
||||
values = {
|
||||
'user_id': w.user_id.id,
|
||||
'partner_id': partner.id,
|
||||
'pricelist_id': partner.property_product_pricelist.id,
|
||||
}
|
||||
sale_order_id = self.pool['sale.order'].create(cr, SUPERUSER_ID, values, context=context)
|
||||
values = self.pool['sale.order'].onchange_partner_id(cr, SUPERUSER_ID, [], partner.id, context=context)['value']
|
||||
self.pool['sale.order'].write(cr, SUPERUSER_ID, [sale_order_id], values, context=context)
|
||||
request.httprequest.session['sale_order_id'] = sale_order_id
|
||||
if sale_order_id:
|
||||
# TODO cache partner_id session
|
||||
partner = self.pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=context).partner_id
|
||||
sale_order = self.pool['sale.order'].browse(cr, SUPERUSER_ID, sale_order_id, context=context)
|
||||
|
||||
# check for change of pricelist with a coupon
|
||||
# TODO cache sale_order.pricelist_id.code in session
|
||||
if code and code != sale_order.pricelist_id.code:
|
||||
pricelist_ids = self.pool['product.pricelist'].search(cr, SUPERUSER_ID, [('code', '=', code)], context=context)
|
||||
if pricelist_ids:
|
||||
pricelist_id = pricelist_ids[0]
|
||||
values = {'pricelist_id': pricelist_id}
|
||||
values.update(order.onchange_pricelist_id(pricelist_id, None)['value'])
|
||||
order.write(values)
|
||||
for line in order.order_line:
|
||||
sale_order._cart_update(cr, uid, order.product_id, add_qty=0)
|
||||
|
||||
# check for change of partner_id ie after signup
|
||||
if sale_order.partner_id.id != partner.id:
|
||||
values = self.pool['sale.order'].onchange_partner_id(cr, SUPERUSER_ID, [], partner.id, context=context)['value']
|
||||
self.pool['sale.order'].write(cr, SUPERUSER_ID, [sale_order_id], values, context=context)
|
||||
return sale_order
|
||||
|
||||
def sale_get_transaction(self, cr, uid, context=None):
|
||||
transaction_obj = self.pool.get('payment.transaction')
|
||||
tx_id = request.httprequest.session.get('payment_transaction_id')
|
||||
if tx_id:
|
||||
tx_ids = transaction_obj.search(cr, uid, [('id', '=', tx_id), ('state', 'not in', ['cancel'])], context=context)
|
||||
if tx_ids:
|
||||
return transaction_obj.browse(cr, uid, tx_ids[0], context=context)
|
||||
else:
|
||||
request.httprequest.session['payment_transaction_id'] = False
|
||||
return False
|
||||
|
||||
def sale_reset(self, cr, uid, context=None):
|
||||
request.httprequest.session.update({
|
||||
'sale_order_id': False,
|
||||
'sale_transaction_id': False,
|
||||
})
|
||||
|
||||
def preprocess_request(self, cr, uid, ids, request, context=None):
|
||||
request.context.update({
|
||||
'sale_order': self.sale_get_order(cr, uid, ids, context=context),
|
||||
#'website_sale_transaction': self.ecommerce_get_current_transaction(cr, uid, context=context)
|
||||
})
|
||||
return super(website, self).preprocess_request(cr, uid, ids, request, context=None)
|
||||
|
||||
# vim:et:
|
||||
|
|
|
@ -1,222 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import uuid
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.addons.web.http import request
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
|
||||
class Website(orm.Model):
|
||||
_inherit = 'website'
|
||||
|
||||
def _get_pricelist_id(self, cr, uid, ids, field_name, arg, context=None):
|
||||
pricelist_id = self.ecommerce_get_pricelist_id(cr, uid, None, context=context)
|
||||
return dict.fromkeys(ids, pricelist_id)
|
||||
|
||||
_columns = {
|
||||
'pricelist_id': fields.function(
|
||||
_get_pricelist_id, type='many2one', obj='product.pricelist')
|
||||
}
|
||||
|
||||
# ************************************************************
|
||||
# Ecommerce pricelist management
|
||||
# ***********************************************************
|
||||
|
||||
def ecommerce_get_pricelist_id(self, cr, uid, ids, context=None):
|
||||
if not request.httprequest.session.get('ecommerce_pricelist'):
|
||||
self._ecommerce_change_pricelist(cr, uid, None, context=context)
|
||||
return request.httprequest.session.get('ecommerce_pricelist')
|
||||
|
||||
def _ecommerce_change_pricelist(self, cr, uid, code=None, context=None):
|
||||
request.httprequest.session.setdefault('ecommerce_pricelist', False)
|
||||
|
||||
pricelist_id = False
|
||||
if code:
|
||||
pricelist_obj = self.pool.get('product.pricelist')
|
||||
pricelist_ids = pricelist_obj.search(cr, SUPERUSER_ID, [('code', '=', code)], context=context)
|
||||
if pricelist_ids:
|
||||
pricelist_id = pricelist_ids[0]
|
||||
|
||||
if not pricelist_id:
|
||||
partner_id = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context).partner_id.id
|
||||
pricelist_id = self.pool.get('sale.order').onchange_partner_id(cr, SUPERUSER_ID, [], partner_id, context=context)['value']['pricelist_id']
|
||||
|
||||
request.httprequest.session['ecommerce_pricelist'] = pricelist_id
|
||||
|
||||
order = self.ecommerce_get_current_order(cr, uid, context=context)
|
||||
if order:
|
||||
values = {'pricelist_id': pricelist_id}
|
||||
values.update(order.onchange_pricelist_id(pricelist_id, None)['value'])
|
||||
order.write(values)
|
||||
for line in order.order_line:
|
||||
self._ecommerce_add_product_to_cart(cr, uid, order_line_id=line.id, number=0)
|
||||
|
||||
# ************************************************************
|
||||
# Ecommerce quotation management
|
||||
# ************************************************************
|
||||
|
||||
def _ecommerce_add_product_to_cart(self, cr, uid, product_id=0, order_line_id=0, number=1, set_number=-1, context=None):
|
||||
order = self.ecommerce_get_current_order(cr, uid, context=context)
|
||||
if not order:
|
||||
order = self.ecommerce_get_new_order(cr, uid, context=context)
|
||||
|
||||
order_line_obj = self.pool.get('sale.order.line')
|
||||
order_obj = self.pool.get('sale.order')
|
||||
|
||||
context = dict(context or {}, pricelist=self.ecommerce_get_pricelist_id(cr, uid, None, context=context))
|
||||
|
||||
# set order_line_id and product_id
|
||||
if order_line_id:
|
||||
order_line = None
|
||||
for line in order.order_line:
|
||||
if line.id == order_line_id:
|
||||
order_line = line
|
||||
break
|
||||
if order_line:
|
||||
product_id = order_line.product_id.id
|
||||
else:
|
||||
order_line_id = None
|
||||
else:
|
||||
order_line_ids = order_line_obj.search(cr, SUPERUSER_ID,
|
||||
[('order_id', '=', order.id), ('product_id', '=', product_id)], context=context)
|
||||
if order_line_ids:
|
||||
order_line_id = order_line_ids[0]
|
||||
|
||||
if not order_line_id and not product_id:
|
||||
return 0
|
||||
|
||||
# values initialisation
|
||||
quantity = 0
|
||||
values = {}
|
||||
order_line_ids = []
|
||||
if order_line_id:
|
||||
order_line_val = order_line_obj.read(cr, SUPERUSER_ID, [order_line_id], [], context=context)[0]
|
||||
if not product_id:
|
||||
product_id = order_line_val['product_id'][0]
|
||||
if set_number >= 0:
|
||||
quantity = set_number
|
||||
else:
|
||||
quantity = order_line_val['product_uom_qty'] + number
|
||||
if quantity < 0:
|
||||
quantity = 0
|
||||
order_line_ids = [order_line_id]
|
||||
else:
|
||||
fields = [k for k, v in order_line_obj._columns.items()]
|
||||
values = order_line_obj.default_get(cr, SUPERUSER_ID, fields, context=context)
|
||||
quantity = 1
|
||||
|
||||
# change and record value
|
||||
if quantity:
|
||||
vals = order_line_obj._recalculate_product_values(cr, uid, order_line_ids, product_id, context=context)
|
||||
values.update(vals)
|
||||
values['product_uom_qty'] = quantity
|
||||
values['product_id'] = product_id
|
||||
values['order_id'] = order.id
|
||||
|
||||
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
|
||||
values['name'] = "%s: %s" % (product.name, product.variants) if product.variants else product.name
|
||||
values['tax_id'] = [(6, 0, [tax.id for tax in product.taxes_id])]
|
||||
if order_line_id:
|
||||
order_line_obj.write(cr, SUPERUSER_ID, order_line_ids, values, context=context)
|
||||
else:
|
||||
order_line_id = order_line_obj.create(cr, SUPERUSER_ID, values, context=context)
|
||||
order_obj.write(cr, SUPERUSER_ID, [order.id], {'order_line': [(4, order_line_id)]}, context=context)
|
||||
elif order_line_ids:
|
||||
order_line_obj.unlink(cr, SUPERUSER_ID, order_line_ids, context=context)
|
||||
|
||||
order = self.ecommerce_get_current_order(cr, uid, context=context)
|
||||
if not order or not order.order_line:
|
||||
self._ecommerce_change_pricelist(cr, uid, None, context=context)
|
||||
|
||||
return quantity
|
||||
|
||||
def _ecommerce_get_quotation_values(self, cr, uid, context=None):
|
||||
""" Generate the values for a new ecommerce quotation. """
|
||||
SaleOrder = self.pool.get('sale.order')
|
||||
fields = [k for k, v in SaleOrder._columns.items()]
|
||||
values = SaleOrder.default_get(cr, SUPERUSER_ID, fields, context=context)
|
||||
if request.httprequest.session.get('ecommerce_pricelist'):
|
||||
values['pricelist_id'] = request.httprequest.session['ecommerce_pricelist']
|
||||
values['partner_id'] = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context).partner_id.id
|
||||
values.update(SaleOrder.onchange_partner_id(cr, SUPERUSER_ID, [], values['partner_id'], context=context)['value'])
|
||||
values['website_session_id'] = request.httprequest.session['website_session_id']
|
||||
return values
|
||||
|
||||
def _ecommerce_create_quotation(self, cr, uid, context=None):
|
||||
""" Create a new quotation used in the ecommerce (event, sale) """
|
||||
SaleOrder = self.pool.get('sale.order')
|
||||
quotation_values = self._ecommerce_get_quotation_values(cr, uid, context=context)
|
||||
quotation_values['user_id'] = False
|
||||
return SaleOrder.create(cr, SUPERUSER_ID, quotation_values, context=context)
|
||||
|
||||
def ecommerce_get_new_order(self, cr, uid, context=None):
|
||||
""" Create a new quotation for the ecommerce and update the session
|
||||
accordingly: website_session_id if not set, ecommerce_order_id """
|
||||
SaleOrder = self.pool.get('sale.order')
|
||||
|
||||
# add website_session_id key for access rules
|
||||
if not request.httprequest.session.get('website_session_id'):
|
||||
request.httprequest.session['website_session_id'] = str(uuid.uuid4())
|
||||
|
||||
order_id = self._ecommerce_create_quotation(cr, uid, context=context)
|
||||
request.httprequest.session['ecommerce_order_id'] = order_id
|
||||
context = dict(context or {}, pricelist=self.ecommerce_get_pricelist_id(cr, uid, None, context=context))
|
||||
return SaleOrder.browse(cr, SUPERUSER_ID, order_id, context=context)
|
||||
|
||||
def ecommerce_get_current_order(self, cr, uid, context=None):
|
||||
SaleOrder = self.pool.get('sale.order')
|
||||
context = dict(context or {}, pricelist=self.ecommerce_get_pricelist_id(cr, uid, None, context=context))
|
||||
order_id = request.httprequest.session.get('ecommerce_order_id')
|
||||
if not order_id:
|
||||
request.httprequest.session['ecommerce_order_id'] = False
|
||||
return False
|
||||
if not order_id in SaleOrder.exists(cr, uid, [order_id], context=context):
|
||||
request.httprequest.session['ecommerce_order_id'] = False
|
||||
return False
|
||||
try:
|
||||
order = SaleOrder.browse(cr, SUPERUSER_ID, order_id, context=context)
|
||||
assert order.website_session_id == request.httprequest.session['website_session_id']
|
||||
return order
|
||||
except:
|
||||
request.httprequest.session['ecommerce_order_id'] = False
|
||||
return False
|
||||
|
||||
# ************************************************************
|
||||
# Ecommerce transaction management
|
||||
# ************************************************************
|
||||
|
||||
def _get_transaction(self, cr, uid, tx_id=None, context=None):
|
||||
transaction_obj = self.pool.get('payment.transaction')
|
||||
if tx_id:
|
||||
tx_ids = transaction_obj.search(cr, uid, [('id', '=', tx_id), ('state', 'not in', ['cancel'])], context=context)
|
||||
if tx_ids:
|
||||
return transaction_obj.browse(cr, uid, tx_ids[0], context=context)
|
||||
return False
|
||||
|
||||
def ecommerce_get_current_transaction(self, cr, uid, context=None):
|
||||
if request.httprequest.session.get('website_sale_transaction_id'):
|
||||
tx = self._get_transaction(cr, uid, tx_id=request.httprequest.session['website_sale_transaction_id'], context=context)
|
||||
if not tx:
|
||||
request.httprequest.session['website_sale_transaction_id'] = False
|
||||
return tx
|
||||
return False
|
||||
|
||||
def ecommerce_reset(self, cr, uid, context=None):
|
||||
request.httprequest.session.update({
|
||||
'ecommerce_order_id': False,
|
||||
'ecommerce_pricelist': False,
|
||||
'website_sale_transaction_id': False,
|
||||
})
|
||||
request.context.update({
|
||||
'website_sale_order': False,
|
||||
'website_sale_transaction': False,
|
||||
})
|
||||
|
||||
def preprocess_request(self, cr, uid, ids, request, context=None):
|
||||
request.context.update({
|
||||
'website_sale_order': self.ecommerce_get_current_order(cr, uid, context=context),
|
||||
'website_sale_transaction': self.ecommerce_get_current_transaction(cr, uid, context=context)
|
||||
})
|
||||
return super(Website, self).preprocess_request(cr, uid, ids, request, context=None)
|
||||
|
||||
def ecommerce_get_product_domain(self):
|
||||
return [("sale_ok", "=", True),("product_variant_ids","!=",False)]
|
|
@ -1,30 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import osv, fields
|
||||
|
||||
|
||||
class product_style(osv.Model):
|
||||
_name = "product.style"
|
||||
_columns = {
|
||||
'name' : fields.char('Style Name', required=True, translate=True),
|
||||
'html_class': fields.char('HTML Classes'),
|
||||
}
|
|
@ -20,7 +20,7 @@ $(document).ready(function () {
|
|||
.fadeIn(600);
|
||||
}
|
||||
|
||||
$(".oe_website_sale .oe_mycart input.js_quantity").change(function () {
|
||||
$(".oe_website_sale .oe_cart input.js_quantity").change(function () {
|
||||
var $input = $(this);
|
||||
var value = parseInt($input.val(), 10);
|
||||
if (isNaN(value)) value = 0;
|
||||
|
@ -55,7 +55,7 @@ $(document).ready(function () {
|
|||
}
|
||||
set_my_cart_quantity(data[1]);
|
||||
$link.parents(".input-group:first").find(".js_quantity").val(data[0]);
|
||||
$('#mycart_total').replaceWith(data[3]);
|
||||
$('#cart_total').replaceWith(data[3]);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
@ -76,39 +76,6 @@ $(document).ready(function () {
|
|||
var js_slider_time = null;
|
||||
var $form = $("form.attributes");
|
||||
$form.on("change", "label input", function () {
|
||||
clearTimeout(js_slider_time);
|
||||
$form.submit();
|
||||
});
|
||||
$(".js_slider", $form).each(function() {
|
||||
var $slide = $(this);
|
||||
var $slider = $('<div>'+
|
||||
'<input type="hidden" name="att-'+$slide.data("id")+'-minmem" value="'+$slide.data("min")+'"/>'+
|
||||
'<input type="hidden" name="att-'+$slide.data("id")+'-maxmem" value="'+$slide.data("max")+'"/>'+
|
||||
'</div>');
|
||||
var $min = $("<input readonly name='att-"+$slide.data("id")+"-min'/>")
|
||||
.css("border", "0").css("width", "50%")
|
||||
.val($slide.data("min"));
|
||||
var $max = $("<input readonly name='att-"+$slide.data("id")+"-max'/>")
|
||||
.css("border", "0").css("width", "50%").css("text-align", "right")
|
||||
.val($slide.data("max"));
|
||||
$slide.append($min);
|
||||
$slide.append($max);
|
||||
$slide.append($slider);
|
||||
$slider.slider({
|
||||
range: true,
|
||||
min: +$slide.data("min"),
|
||||
max: +$slide.data("max"),
|
||||
values: [
|
||||
$slide.data("value-min") ? +$slide.data("value-min") : +$slide.data("min"),
|
||||
$slide.data("value-max") ? +$slide.data("value-max") : +$slide.data("max")
|
||||
],
|
||||
change: function( event, ui ) {
|
||||
$min.val( ui.values[ 0 ] );
|
||||
$max.val( ui.values[ 1 ] );
|
||||
$form.submit();
|
||||
}
|
||||
});
|
||||
$min.val( $slider.slider( "values", 0 ) );
|
||||
$max.val( $slider.slider( "values", 1 ) );
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import openerp
|
||||
import openerp.addons.website.tests.test_ui as test_ui
|
||||
|
||||
def load_tests(loader, base, _):
|
||||
jsfile = openerp.modules.module.get_module_resource('website_sale','tests','test_sale_process1.js')
|
||||
base.addTest(test_ui.WebsiteUiSuite(jsfile,{ 'action': 'website.action_website_homepage' }, 120.0))
|
||||
jsfile = openerp.modules.module.get_module_resource('website_sale','tests','test_sale_process2.js')
|
||||
base.addTest(test_ui.WebsiteUiSuite(jsfile,{ 'action': 'website.action_website_homepage' }, 120.0))
|
||||
return base
|
|
@ -1,8 +0,0 @@
|
|||
import openerp.addons.website.tests.test_ui as test_ui
|
||||
|
||||
def load_tests(loader, base, _):
|
||||
base.addTest(test_ui.WebsiteUiSuite(test_ui.full_path(__file__,'website_sale-sale_process-test.js'),
|
||||
{ 'action': 'website.action_website_homepage' }))
|
||||
base.addTest(test_ui.WebsiteUiSuite(test_ui.full_path(__file__,'website_sale-sale_process-test-2.js'),
|
||||
{ 'action': 'website.action_website_homepage' }))
|
||||
return base
|
|
@ -2,7 +2,7 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Layout add nav and footer -->
|
||||
<!-- Layout and common templates -->
|
||||
|
||||
<template id="editor_head" inherit_id="website.editor_head" name="Shop Editor" groups="base.group_sale_manager">
|
||||
<xpath expr="//script[@id='website_tour_js']" position="after">
|
||||
|
@ -13,43 +13,41 @@
|
|||
|
||||
<template id="header" inherit_id="website.layout" name="Header Shop My Cart Link">
|
||||
<xpath expr="//header//ul[@id='top_menu']/li" position="before">
|
||||
<li t-att-class="(not website_sale_order or not website_sale_order.get_number_of_products()) and 'hidden' or ''">
|
||||
<a href="/shop/mycart/">
|
||||
<li t-att-class="'' if sale_order and sale_order._cart_qty() else 'hidden'">
|
||||
<a href="/shop/cart/">
|
||||
<i class="fa fa-shopping-cart"></i>
|
||||
My cart <sup t-attf-class="my_cart_quantity label label-primary"
|
||||
t-esc="website_sale_order and website_sale_order.get_number_of_products() or ''"/>
|
||||
My cart <sup t-attf-class="my_cart_quantity label label-primary" t-esc="sale_order and sale_order._cart_qty() or ''"/>
|
||||
</a>
|
||||
</li>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- List of categories -->
|
||||
|
||||
<template id="categories_recursive" name="Category list">
|
||||
<li t-att-class="category.id == search.get('category') and 'active' or ''">
|
||||
<a t-attf-href="/shop/category/#{ slug(category) }/" t-field="category.name"></a>
|
||||
<ul t-if="category.child_id" class="nav nav-pills nav-stacked nav-hierarchy">
|
||||
<t t-foreach="category.child_id" t-as="category">
|
||||
<t t-call="website_sale.categories_recursive"/>
|
||||
</t>
|
||||
</ul>
|
||||
</li>
|
||||
</template>
|
||||
|
||||
<!-- Product list -->
|
||||
|
||||
<template id="search" name="Search hidden fields">
|
||||
<input type="hidden" name="category" t-att-value="search.get('category') or ''"/>
|
||||
<input type="hidden" name="filters" t-att-value="search.get('filters') or ''"/>
|
||||
<div class="input-group">
|
||||
<input type="text" name="search" class="search-query form-control" placeholder="Search..." t-att-value="search.get('search') or ''"/>
|
||||
<input type="text" name="search" class="search-query form-control" placeholder="Search..." t-att-value="search"/>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="submit"><i class="fa fa-search"/></button>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="products_cart" name="Shopping cart">
|
||||
<template id="404">
|
||||
<t t-call="website.layout">
|
||||
<div id="wrap">
|
||||
<div class="oe_structure oe_empty">
|
||||
<div class="container">
|
||||
<h1 class="mt32">Product not found!</h1>
|
||||
<p>Sorry, this product is not available anymore.</p>
|
||||
<p><a t-attf-href="/shop/">Return to the product list.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<!-- Product item used by /shop and /shop/cart -->
|
||||
|
||||
<template id="products_item" name="Product item">
|
||||
<div class="ribbon-wrapper">
|
||||
<div class="ribbon btn btn-danger">Sale</div>
|
||||
</div>
|
||||
|
@ -63,21 +61,32 @@
|
|||
<div class="product_price" t-if="product.product_variant_ids">
|
||||
<b>
|
||||
<t t-if="abs(product.product_variant_ids[0].lst_price - product.product_variant_ids[0].price) > 0.2">
|
||||
<del class="text-danger"
|
||||
t-field="product.product_variant_ids[0].lst_price" t-field-options='{
|
||||
"widget": "monetary",
|
||||
"display_currency": "website.pricelist_id.currency_id"
|
||||
}'/>&nbsp;
|
||||
<del class="text-danger" t-field="product.product_variant_ids[0].lst_price" t-field-options='{ "widget": "monetary", "display_currency": "pricelist.currency_id" }'/>&nbsp;
|
||||
</t>
|
||||
<span t-field="product.product_variant_ids[0].price" t-field-options='{
|
||||
"widget": "monetary",
|
||||
"display_currency": "website.pricelist_id.currency_id"
|
||||
}'/>
|
||||
<span t-field="product.product_variant_ids[0].price" t-field-options='{ "widget": "monetary", "display_currency": "pricelist.currency_id" }'/>
|
||||
</b>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<template id="products_description" inherit_option_id="website_sale.products_item" name="Product Description">
|
||||
<xpath expr="//div[@class='product_price']" position="before">
|
||||
<div class="text-info oe_subdescription oe_shadow" t-field="product.description_sale"/>
|
||||
<div class="text-info oe_subdescription" t-field="product.description_sale"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="products_add_to_cart" inherit_option_id="website_sale.products_item" name="Add to Cart">
|
||||
<xpath expr="//div[@class='product_price']" position="inside">
|
||||
<form action="/shop/cart/update" method="post" style="display: inline-block;">
|
||||
<input name="product_id" t-att-value="product.product_variant_ids[0].id" type="hidden"/>
|
||||
<button type="submit" class="fa fa-shopping-cart"/>
|
||||
</form>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- /shop product listing -->
|
||||
|
||||
<template id="products" name="Products">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
|
@ -93,7 +102,7 @@
|
|||
<div class="container oe_website_sale">
|
||||
<div class="products_pager">
|
||||
<div class="row">
|
||||
<form action="/shop/" method="get" class="pagination form-inline col-md-3">
|
||||
<form t-att-action="keep('/shop',search=0)" method="get" class="pagination form-inline col-md-3">
|
||||
<t t-call="website_sale.search" />
|
||||
</form>
|
||||
<t t-call="website.pager"/>
|
||||
|
@ -176,7 +185,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<t t-call="website_sale.products_cart"/>
|
||||
<t t-call="website_sale.products_item"/>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
@ -210,53 +219,75 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<!-- Product Description-->
|
||||
<template id="categories_recursive" name="Category list">
|
||||
<li t-att-class="'active' if c.id == category else ''">
|
||||
<a t-att-href="keep('/shop/category/' + slug(c), category=0)" t-field="c.name"></a>
|
||||
<ul t-if="c.child_id" class="nav nav-pills nav-stacked nav-hierarchy">
|
||||
<t t-foreach="c.child_id" t-as="c">
|
||||
<t t-call="website_sale.categories_recursive"/>
|
||||
</t>
|
||||
</ul>
|
||||
</li>
|
||||
</template>
|
||||
|
||||
<template id="product_description" inherit_option_id="website_sale.products_cart" name="Product Description">
|
||||
<xpath expr="//div[@class='product_price']" position="before">
|
||||
<div class="text-info oe_subdescription oe_shadow" t-field="product.description_sale"/>
|
||||
<div class="text-info oe_subdescription" t-field="product.description_sale"/>
|
||||
<template id="products_categories" inherit_option_id="website_sale.products" name="Product Categories">
|
||||
<xpath expr="//div[@id='products_grid_before']" position="inside">
|
||||
<ul class="nav nav-pills nav-stacked mt16">
|
||||
<li t-att-class=" '' if category else 'active' "><a t-att-href="keep('/shop',category=0)">All Products</a></li>
|
||||
<t t-foreach="categories" t-as="c">
|
||||
<t t-call="website_sale.categories_recursive"/>
|
||||
</t>
|
||||
</ul>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='products_grid_before']" position="attributes">
|
||||
<attribute name="class">col-md-3 hidden-xs</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='products_grid']" position="attributes">
|
||||
<attribute name="class">col-md-9</attribute>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Add to cart button-->
|
||||
|
||||
<template id="add_to_basket" inherit_option_id="website_sale.products_cart" name="Add to Cart">
|
||||
<xpath expr="//div[@class='product_price']" position="inside">
|
||||
<form action="/shop/add_cart/" method="post" style="display: inline-block;">
|
||||
<input name="product_id" t-att-value="product.product_variant_ids[0].id" type="hidden"/>
|
||||
<button type="submit" class="fa fa-shopping-cart"/>
|
||||
<template id="products_attributes" inherit_id="website_sale.products" inherit_option_id="website_sale.products" name="Product Attribute's Filters" groups="product.group_product_attributes">
|
||||
<xpath expr="//div[@id='products_grid_before']" position="inside">
|
||||
<form t-att-action="keep('shop',attrib=0)" class="attributes" method="get">
|
||||
<ul class="nav nav-pills nav-stacked mt16">
|
||||
<t t-foreach="attributes" t-as="a">
|
||||
<li t-if="a.value_ids">
|
||||
<div t-field="a.name"/>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<t t-foreach="a.value_ids" t-as="v">
|
||||
<li t-att-class="'active' if v.id in attrib_set else ''">
|
||||
<label style="margin: 0 20px;">
|
||||
<input type="checkbox" name="attrib" t-att-value="v.id" t-att-checked="'checked' if v.id in attrib_set else ''"/>
|
||||
<span style="font-weight: normal" t-field="v.name"/>
|
||||
</label>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
</form>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='products_grid_before']" position="attributes">
|
||||
<attribute name="class">col-md-3 hidden-xs</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='products_grid']" position="attributes">
|
||||
<attribute name="class">col-md-9</attribute>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- List view of products -->
|
||||
|
||||
<template id="list_view" inherit_option_id="website_sale.products" name="List View">
|
||||
<template id="products_list_view" inherit_option_id="website_sale.products" name="List View">
|
||||
<xpath expr="//div[@id='products_grid']//table" position="replace">
|
||||
<t t-foreach="products" t-as="product">
|
||||
<div class="oe_product oe_list oe_product_cart" t-att-data-publish="product.website_published and 'on' or 'off'">
|
||||
<t t-call="website_sale.products_cart"/>
|
||||
<t t-call="website_sale.products_item"/>
|
||||
</div>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
<!-- product -->
|
||||
<template id="404">
|
||||
<t t-call="website.layout">
|
||||
<div id="wrap">
|
||||
<div class="oe_structure oe_empty">
|
||||
<div class="container">
|
||||
<h1 class="mt32">Product not found!</h1>
|
||||
<p>Sorry, this product is not available anymore.</p>
|
||||
<p><a t-attf-href="/shop/">Return to the product list.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
<!-- /shop/product product page -->
|
||||
|
||||
<template id="product" name="Product">
|
||||
<t t-call="website.layout">
|
||||
|
@ -272,14 +303,14 @@
|
|||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<ol class="breadcrumb">
|
||||
<li><a t-attf-href="/shop?{{ keep_query('search', 'filters') }}" onclick="history.go(-1); return false;">Products</a></li>
|
||||
<li t-if="search.get('category')"><a t-attf-href="/shop/?{{ keep_query('search', 'filters', 'category') }}" t-field="category.name"/></li>
|
||||
<li><a t-att-href="keep(category=0)" onclick="history.go(-1); return false;">Products</a></li>
|
||||
<li t-if="category"><a t-att-href="keep()" t-field="category.name"/></li>
|
||||
<li class="active"><span t-field="product.name"/></li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<form action="/shop/" method="get" class="pull-right">
|
||||
<t t-call="website_sale.search" />
|
||||
<form t-att-action="keep(search=0)" method="get" class="pull-right">
|
||||
<t t-call="website_sale.search"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-sm-4" groups="base.group_sale_manager">
|
||||
|
@ -298,17 +329,14 @@
|
|||
</div><div class="col-sm-5 col-md-5 col-lg-4 col-lg-offset-1">
|
||||
<h1 t-field="product.name">Product Name</h1>
|
||||
|
||||
<form action="/shop/add_cart/" class="js_add_cart_json" method="POST">
|
||||
<form action="/shop/cart/update" class="js_add_cart_json" method="POST">
|
||||
<input type="hidden" t-if="len(product.product_variant_ids) == 1" name="product_id" t-att-value="product.product_variant_ids[0].id"/>
|
||||
<t t-if="len(product.product_variant_ids) > 1">
|
||||
<label label-default="label-default" class="radio" t-foreach="product.product_variant_ids" t-as="variant_id">
|
||||
<input type="radio" name="product_id" t-att-value="variant_id.id" t-att-checked="variant_id == product.product_variant_ids[0] or None"/>
|
||||
<t t-esc="variant_id.variants or ''">Standard</t>
|
||||
<span class="badge" t-if="variant_id.price_extra">
|
||||
<t t-esc="variant_id.price_extra > 0 and '+' or ''"/><span t-field="variant_id.price_extra" t-field-options='{
|
||||
"widget": "monetary",
|
||||
"display_currency": "website.pricelist_id.currency_id"
|
||||
}'/>
|
||||
<t t-esc="variant_id.price_extra > 0 and '+' or ''"/><span t-field="variant_id.price_extra" t-field-options='{ "widget": "monetary", "display_currency": "pricelist.currency_id" }'/>
|
||||
</span>
|
||||
</label>
|
||||
</t>
|
||||
|
@ -318,17 +346,11 @@
|
|||
<t t-if="product.product_variant_ids[0].lst_price != product.product_variant_ids[0].price">
|
||||
<span class="text-danger" style="text-decoration: line-through;"
|
||||
t-field="product.product_variant_ids[0].lst_price"
|
||||
t-field-options='{
|
||||
"widget": "monetary",
|
||||
"display_currency": "website.pricelist_id.currency_id"
|
||||
}'/><br/>
|
||||
t-field-options='{ "widget": "monetary", "display_currency": "pricelist.currency_id" }'/><br/>
|
||||
</t>
|
||||
<b class="oe_price"
|
||||
t-field="product.product_variant_ids[0].price"
|
||||
t-field-options='{
|
||||
"widget": "monetary",
|
||||
"display_currency": "website.pricelist_id.currency_id"
|
||||
}'/>
|
||||
t-field-options='{ "widget": "monetary", "display_currency": "pricelist.currency_id" }'/>
|
||||
</h4>
|
||||
</div>
|
||||
<button class="btn btn-primary btn-lg mt8">Add to Cart</button>
|
||||
|
@ -349,21 +371,18 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<!-- Product option: related / recommended products -->
|
||||
<template id="recommended_products" inherit_id="website_sale.product" inherit_option_id="website_sale.product" name="Recommended Products">
|
||||
<template id="recommended_products" inherit_id="website_sale.product" inherit_option_id="website_sale.product" name="Alternative Products">
|
||||
<xpath expr="//div[@id='product_full_description']" position="after">
|
||||
<div class="container mt32" t-if="product.recommended_products()">
|
||||
<h3>Customers who have bought this product also bought:</h3>
|
||||
<div class="container mt32" t-if="product.alternative_product_ids">
|
||||
<h3>Suggested alternatives:</h3>
|
||||
<div class='row mt16' style="margin-left: 15px !important;">
|
||||
<t t-foreach="product.recommended_products()" t-as="product">
|
||||
<t t-foreach="product.alternative_product_ids" t-as="product">
|
||||
<div class='col-md-2 thumbnail' style='width: 170px; margin-right: 16px;'>
|
||||
<div class='mt16 text-center'>
|
||||
<span t-field="product.image_small" t-field-options='{"widget": "image", "class": "img-rounded shadow" }'/>
|
||||
<h5>
|
||||
<a t-attf-href="/shop/product/#{ slug(product) }/"
|
||||
style="display: block">
|
||||
<span t-field='product.name'
|
||||
style="display: block"/>
|
||||
<a t-attf-href="/shop/product/#{ slug(product) }/" style="display: block">
|
||||
<span t-field='product.name' style="display: block"/>
|
||||
</a>
|
||||
</h5>
|
||||
</div>
|
||||
|
@ -374,19 +393,18 @@
|
|||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Product option: attributes -->
|
||||
<template id="product_attributes" inherit_id="website_sale.product" inherit_option_id="website_sale.product" name="Product attributes" groups="product.group_product_attributes">
|
||||
<xpath expr="//p[@t-field='product.description_sale']" position="after">
|
||||
<hr t-if="product.attribute_lines"/>
|
||||
<p class="text-muted">
|
||||
<t t-set="attr" t-value="None"/>
|
||||
<t t-foreach="product.attribute_lines" t-as="attribute"><br t-if="attr and attribute.attribute_id.id != attr"/><t t-if="attribute.attribute_id.id != attr"><span t-field="attribute.attribute_id"/>: </t><t t-if="attribute.attribute_id.id == attr">, </t><t t-if="attribute.attribute_id.type == 'distinct'"><span t-field="attribute.value_id"/></t><t t-if="attribute.attribute_id.type == 'float'"><span t-field="attribute.value"/></t><t t-set="attr" t-value="attribute.attribute_id.id"/></t>
|
||||
<t t-foreach="product.attribute_lines" t-as="l">
|
||||
<span t-field="l.attribute_id.name"/>: <span t-field="l.value_id.name"/> <br/>
|
||||
</t>
|
||||
</p>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Product options: OpenChatter -->
|
||||
<template id="product_option_openchatter" inherit_option_id="website_sale.product" name="Discussion">
|
||||
<template id="product_comment" inherit_option_id="website_sale.product" name="Discussion">
|
||||
<xpath expr="//div[@t-field='product.website_description']" position="after">
|
||||
<hr class="mb32"/>
|
||||
<section class="container">
|
||||
|
@ -431,8 +449,7 @@
|
|||
</li>
|
||||
</ul>
|
||||
<div class="css_editable_mode_hidden">
|
||||
<form id="comment" t-attf-action="/shop/product/#{product.id}/comment"
|
||||
method="POST">
|
||||
<form id="comment" t-attf-action="/shop/product/comment/#{product.id}" method="POST">
|
||||
<img class="img pull-left img-rounded" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(user_id.partner_id.id)" style="width: 50px; margin-right: 10px;"/>
|
||||
<div class="pull-left mb32" style="width: 75%%">
|
||||
<textarea rows="3" name="comment" class="form-control" placeholder="Write a comment..."></textarea>
|
||||
|
@ -445,9 +462,9 @@
|
|||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Page Shop my cart -->
|
||||
<!-- /shop/cart -->
|
||||
|
||||
<template id="mycart" name="Your Cart">
|
||||
<template id="cart" name="Shopping Cart">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale.js"></script>
|
||||
|
@ -465,11 +482,11 @@
|
|||
</ul>
|
||||
<h1 class="mb32">Shopping Cart</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-sm-9 oe_mycart">
|
||||
<div class="col-md-8 col-sm-9 oe_cart">
|
||||
<div t-if="not website_sale_order or not website_sale_order.website_order_line" class="well well-lg">
|
||||
Your cart is empty!
|
||||
</div>
|
||||
<table class='table table-striped table-condensed' id="mycart_products" t-if="website_sale_order and website_sale_order.website_order_line">
|
||||
<table class='table table-striped table-condensed' id="cart_products" t-if="website_sale_order and website_sale_order.website_order_line">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" width="100">Product</th>
|
||||
|
@ -508,14 +525,14 @@
|
|||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">
|
||||
<a t-attf-href="../change_cart/#{ line.id }/?remove=True" class="mb8 js_add_cart_json">
|
||||
<a t-attf-href="/shop/cart/update?product_id={{ line.product_id.id }&add_qty=-1" class="mb8 js_add_cart_json">
|
||||
<i class="fa fa-minus"></i>
|
||||
</a>
|
||||
</span>
|
||||
<input type="text" class="js_quantity form-control"
|
||||
t-att-data-id="line.id" t-att-value="int(line.product_uom_qty)"/>
|
||||
<span class="input-group-addon">
|
||||
<a t-attf-href="../change_cart/#{ line.id }/" class="mb8 float_left js_add_cart_json">
|
||||
<a t-attf-href="/shop/cart/update?product_id={{ line.product_id.id }&add_qty=1" class="mb8 float_left js_add_cart_json">
|
||||
<i class="fa fa-plus"></i>
|
||||
</a>
|
||||
</span>
|
||||
|
@ -550,79 +567,8 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
|
||||
<template id="continue_shopping" inherit_id="website_sale.mycart" inherit_option_id="website_sale.mycart" name="Continue Shopping Button">
|
||||
<xpath expr="//a[@href='/shop/checkout/']" position="before">
|
||||
<a href="/shop" class="btn btn-default mb32"><span class="fa fa-long-arrow-left"/> Continue Shopping</a>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
<!-- Page Shop -->
|
||||
|
||||
<template id="products_categories" inherit_option_id="website_sale.products" name="Product Categories">
|
||||
<xpath expr="//div[@id='products_grid_before']" position="inside">
|
||||
<ul class="nav nav-pills nav-stacked mt16">
|
||||
<li t-att-class=" '' if search.get('category') else 'active' "><a href="/shop/">All Products</a></li>
|
||||
<t t-foreach="categories" t-as="category">
|
||||
<t t-call="website_sale.categories_recursive"/>
|
||||
</t>
|
||||
</ul>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='products_grid_before']" position="attributes">
|
||||
<attribute name="class">col-md-3 hidden-xs</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='products_grid']" position="attributes">
|
||||
<attribute name="class">col-md-9</attribute>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="products_attributes" inherit_id="website_sale.products" inherit_option_id="website_sale.products" name="Product attribute's Filters" groups="product.group_product_attributes">
|
||||
<xpath expr="//div[@id='products_grid_before']" position="inside">
|
||||
<form t-attf-action="/shop/filters/?{{ keep_query('category', 'search') }}" class="attributes" method="post">
|
||||
<ul class="nav nav-pills nav-stacked mt16">
|
||||
<t t-set="attribute_ids" t-value="Ecommerce.get_attribute_ids()"/>
|
||||
<t t-foreach="attribute_ids" t-as="attribute_id">
|
||||
<t t-if="attribute_id.visible">
|
||||
<li t-if="attribute_id.value_ids and attribute_id.type == 'distinct'">
|
||||
<div t-field="attribute_id.name"/>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<t t-foreach="attribute_id.value_ids" t-as="value_id">
|
||||
<li t-att-class="Ecommerce.has_search_filter(attribute_id.id, value_id.id) and 'active' or ''">
|
||||
<label style="margin: 0 20px;">
|
||||
<input type="checkbox" t-att-name="'att-%s-%s' % (attribute_id.id, value_id.id)"
|
||||
t-att-checked="Ecommerce.has_search_filter(attribute_id.id, value_id.id) and 'checked' or ''"/>
|
||||
<span style="font-weight: normal" t-field="value_id.name"/>
|
||||
</label>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
</li>
|
||||
<li t-if="attribute_id.type == 'float' and attribute_id.float_min != attribute_id.float_max">
|
||||
<div t-field="attribute_id.name"/>
|
||||
<t t-set="attribute" t-value="Ecommerce.has_search_filter(attribute_id.id)"/>
|
||||
<div style="margin: 0 20px;" class="js_slider"
|
||||
t-att-data-id="attribute_id.id"
|
||||
t-att-data-value-min="attribute and attribute[1][0] or attribute_id.float_min"
|
||||
t-att-data-value-max="attribute and attribute[1][1] or attribute_id.float_max"
|
||||
t-att-data-min="attribute_id.float_min"
|
||||
t-att-data-max="attribute_id.float_max"></div>
|
||||
</li>
|
||||
</t>
|
||||
</t>
|
||||
</ul>
|
||||
</form>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='products_grid_before']" position="attributes">
|
||||
<attribute name="class">col-md-3 hidden-xs</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='products_grid']" position="attributes">
|
||||
<attribute name="class">col-md-9</attribute>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="suggested_products_list" inherit_id="website_sale.mycart" inherit_option_id="website_sale.mycart" name="Suggested Products in my cart">
|
||||
<xpath expr="//table[@id='mycart_products']" position="after">
|
||||
<template id="suggested_products_list" inherit_id="website_sale.cart" inherit_option_id="website_sale.cart" name="Suggested Products in my cart">
|
||||
<xpath expr="//table[@id='cart_products']" position="after">
|
||||
<table t-if="suggested_products" class='table table-striped table-condensed'>
|
||||
<colgroup>
|
||||
<col width="80"/>
|
||||
|
@ -666,7 +612,7 @@
|
|||
}'/>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<form action="/shop/add_cart/" method="post">
|
||||
<form action="/shop/cart/update" method="post">
|
||||
<input name="product_id" t-att-value="product.product_variant_ids[0].id" type="hidden"/>
|
||||
<button type="submit" class="btn btn-link"><strong>Add to Cart</strong></button>
|
||||
</form>
|
||||
|
@ -677,7 +623,13 @@
|
|||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="reduction_code" inherit_option_id="website_sale.mycart" name="Reduction Code">
|
||||
<template id="continue_shopping" inherit_id="website_sale.cart" inherit_option_id="website_sale.cart" name="Continue Shopping Button">
|
||||
<xpath expr="//a[@href='/shop/checkout/']" position="before">
|
||||
<a href="/shop" class="btn btn-default mb32"><span class="fa fa-long-arrow-left"/> Continue Shopping</a>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="reduction_code" inherit_option_id="website_sale.cart" name="Reduction Code">
|
||||
<xpath expr="//div[@id='right_column']" position="inside">
|
||||
<h4>Coupon Code</h4>
|
||||
<p>
|
||||
|
@ -694,8 +646,7 @@
|
|||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
<!-- Page confirm my cart -->
|
||||
<!-- /shop/checkout -->
|
||||
|
||||
<template id="checkout">
|
||||
<t t-call="website.layout">
|
||||
|
@ -708,7 +659,7 @@
|
|||
<div id="wrap">
|
||||
<div class="container oe_website_sale">
|
||||
<ul class="wizard pull-right">
|
||||
<li><a href="/shop/mycart" class="text-success">Review Order<span class="chevron"></span></a></li>
|
||||
<li><a href="/shop/cart" class="text-success">Review Order<span class="chevron"></span></a></li>
|
||||
<li class="text-primary">Shipping & Billing<span class="chevron"></span></li>
|
||||
<li class="text-muted">Payment<span class="chevron"></span></li>
|
||||
<li class="text-muted">Confirmation<span class="chevron"></span></li>
|
||||
|
@ -717,7 +668,7 @@
|
|||
<form action="/shop/confirm_order/" method="post">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8 oe_mycart">
|
||||
<div class="col-md-8 oe_cart">
|
||||
<h3 class="page-header mt16">Billing Information
|
||||
<small groups="base.group_public"> or
|
||||
<a class='btn btn-primary' t-if="not partner" t-attf-href="/web?redirect=#{ request.httprequest.url }">Sign in</a>
|
||||
|
@ -829,7 +780,7 @@
|
|||
<button type="submit" class="btn btn-default btn-primary pull-right mb32">Confirm <span class="fa fa-long-arrow-right"/></button>
|
||||
</div>
|
||||
<div class="col-lg-offset-1 col-lg-3 text-muted">
|
||||
<h3 class="page-header mt16">Your Order <small><a href="/shop/mycart"><span class="fa fa-arrow-right"/> change</a></small></h3>
|
||||
<h3 class="page-header mt16">Your Order <small><a href="/shop/cart"><span class="fa fa-arrow-right"/> change</a></small></h3>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 text-right">Subtotal:</div>
|
||||
<div class="col-sm-6"><span t-esc="website_sale_order.amount_untaxed" t-field-options='{
|
||||
|
@ -855,6 +806,8 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<!-- /shop/payment -->
|
||||
|
||||
<template id="payment">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
|
@ -868,15 +821,15 @@
|
|||
<div class="container oe_website_sale">
|
||||
|
||||
<ul class="wizard pull-right">
|
||||
<li><a href="/shop/mycart" class="text-success">Review Order<span class="chevron"></span></a></li>
|
||||
<li><a href="/shop/cart" class="text-success">Review Order<span class="chevron"></span></a></li>
|
||||
<li><a href="/shop/checkout" class="text-success">Shipping & Billing<span class="chevron"></span></a></li>
|
||||
<li class="text-primary">Payment<span class="chevron"></span></li>
|
||||
<li class="text-muted">Confirmation<span class="chevron"></span></li>
|
||||
</ul>
|
||||
<h1 class="mb32">Validate Order</h1>
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-sm-9 oe_mycart">
|
||||
<table class='table table-striped table-condensed' id="mycart_products" t-if="website_sale_order and website_sale_order.website_order_line">
|
||||
<div class="col-lg-8 col-sm-9 oe_cart">
|
||||
<table class='table table-striped table-condensed' id="cart_products" t-if="website_sale_order and website_sale_order.website_order_line">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" width="80">Product</th>
|
||||
|
@ -997,7 +950,7 @@
|
|||
</ul>
|
||||
<h1 class="mb32">Order <em t-field="order.name"/> Confirmed</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-8 oe_mycart">
|
||||
<div class="col-md-8 oe_cart">
|
||||
<h2>Thank you for your order.</h2>
|
||||
<div class="oe_website_sale_tx_status" t-att-data-order-id="order.id">
|
||||
</div>
|
||||
|
@ -1033,7 +986,7 @@
|
|||
<!-- Page Shop my cart and payment total -->
|
||||
|
||||
<template id="total">
|
||||
<table class='pull-right mb16' id="mycart_total" t-if="website_sale_order">
|
||||
<table class='pull-right mb16' id="cart_total" t-if="website_sale_order">
|
||||
<thead>
|
||||
<tr width="100" style="border-top: 1px solid #000" id="order_total">
|
||||
<th><h3>Total:</h3></th>
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
<group name="sale" position="inside">
|
||||
<group name="website" string="Website">
|
||||
<field name="alternative_product_ids" widget="many2many_tags"/>
|
||||
<field name="accessory_product_ids" widget="many2many_tags"/>
|
||||
<field name="website_style_ids" widget="many2many_tags"/>
|
||||
<field name="website_sequence"/>
|
||||
|
@ -61,15 +62,13 @@
|
|||
</xpath>
|
||||
<xpath expr="//field[@name='description']" position="before">
|
||||
<group colspan="4" string="Website Options">
|
||||
<field name="alternative_product_ids" widget="many2many_tags"/>
|
||||
<field name="accessory_product_ids" widget="many2many_tags"/>
|
||||
<field name="website_style_ids" widget="many2many_tags"/>
|
||||
<field colspan="4" name="attribute_lines" nolabel="1" groups="product.group_product_attributes">
|
||||
<tree string="Product attributes" editable="bottom">
|
||||
<field name="attribute_id" on_change="onchange_attribute_id(attribute_id)"/>
|
||||
<field name="type" invisible="1"/>
|
||||
<field name="value" attrs="{'required': [('type','=','float')]}"/>
|
||||
<field name="value_id"
|
||||
attrs="{'required': [('type','=','distinct')]}"
|
||||
context="{'default_attribute_id': attribute_id}"
|
||||
domain="[('attribute_id', '=', attribute_id)]"/>
|
||||
</tree>
|
||||
|
@ -87,12 +86,10 @@
|
|||
<form string="Product attributes" version="7.0">
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
<field name="visible"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</data>
|
||||
</openerp>
|
|
@ -16,5 +16,5 @@ Delivery Costs
|
|||
],
|
||||
'demo': [],
|
||||
'qweb': [],
|
||||
'installable': True,
|
||||
'installable': False,
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from openerp.addons.website_sale.controllers.main import Ecommerce
|
||||
import openerp
|
||||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
|
||||
class Ecommerce(Ecommerce):
|
||||
class website_sale(openerp.addons.website_sale.controllers.main.website_sale):
|
||||
|
||||
@http.route(['/shop/payment/'], type='http', auth="public", website=True, multilang=True)
|
||||
def payment(self, **post):
|
||||
|
@ -18,5 +17,5 @@ class Ecommerce(Ecommerce):
|
|||
request.registry['website']._check_carrier_quotation(cr,uid,order,carrier_id,context=context)
|
||||
return request.redirect("/shop/payment/")
|
||||
|
||||
res = super(Ecommerce, self).payment(**post)
|
||||
res = super(website_sale, self).payment(**post)
|
||||
return res
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<template id="mycart_delivery" name="Delivery Costs" inherit_id="website_sale.total">
|
||||
<template id="cart_delivery" name="Delivery Costs" inherit_id="website_sale.total">
|
||||
<xpath expr="//tr[@id='order_total_taxes']" position="after">
|
||||
<tr class="text-muted" id="order_delivery">
|
||||
<td><abbr title="Delivery will be updated after choosing a new delivery method">Delivery:</abbr></td>
|
||||
|
|
Loading…
Reference in New Issue