[IMP] website_sale: cleaning of outdated code
- remove field complete_name
is the same as the ORM field display_name, compute the name_get
- website_publish_button is duplicated
- write outdated, according to TODO (field color already renamed)
- Instead of open_website_url, should use website_publish_button
- styles, style_in_product, attrib_encode: are no longer used in templates
- remove unnecessary rebrowse
This check was added at d3678bf5 either
- to prevent browsing as public user (wrong as always browsed with SUPERUSER_ID)
- to refresh fields of the record (I find your lack of faith in the cache
invalidation distrubing)
- remove get_pricelist method
equivalent to call request.website.get_current_pricelist
This commit is contained in:
@@ -5,7 +5,6 @@ from openerp import SUPERUSER_ID
|
||||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
from openerp.addons.website_event.controllers.main import website_event
|
||||
from openerp.addons.website_sale.controllers.main import get_pricelist
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
@@ -13,7 +12,7 @@ class website_event(website_event):
|
||||
|
||||
@http.route(['/event/<model("event.event"):event>/register'], type='http', auth="public", website=True)
|
||||
def event_register(self, event, **post):
|
||||
pricelist_id = int(get_pricelist())
|
||||
pricelist_id = int(request.website.get_current_pricelist())
|
||||
values = {
|
||||
'event': event.with_context(pricelist=pricelist_id),
|
||||
'main_object': event.with_context(pricelist=pricelist_id),
|
||||
|
||||
@@ -103,14 +103,8 @@ class QueryURL(object):
|
||||
return path
|
||||
|
||||
|
||||
def get_pricelist():
|
||||
return request.website.get_current_pricelist()
|
||||
|
||||
class website_sale(http.Controller):
|
||||
|
||||
def get_pricelist(self):
|
||||
return get_pricelist()
|
||||
|
||||
def get_attribute_value_ids(self, product):
|
||||
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
||||
currency_obj = pool['res.currency']
|
||||
@@ -120,7 +114,7 @@ class website_sale(http.Controller):
|
||||
if len(l.value_ids) > 1)
|
||||
if request.website.pricelist_id.id != context['pricelist']:
|
||||
website_currency_id = request.website.currency_id.id
|
||||
currency_id = self.get_pricelist().currency_id.id
|
||||
currency_id = request.website.get_current_pricelist().currency_id.id
|
||||
for p in product.product_variant_ids:
|
||||
price = currency_obj.compute(cr, uid, website_currency_id, currency_id, p.lst_price)
|
||||
attribute_value_ids.append([p.id, [v.id for v in p.attribute_value_ids if v.attribute_id.id in visible_attrs], p.price, price])
|
||||
@@ -196,7 +190,7 @@ class website_sale(http.Controller):
|
||||
|
||||
pricelist_context = dict(context)
|
||||
if not pricelist_context.get('pricelist'):
|
||||
pricelist = self.get_pricelist()
|
||||
pricelist = request.website.get_current_pricelist()
|
||||
pricelist_context['pricelist'] = int(pricelist)
|
||||
else:
|
||||
pricelist = pool.get('product.pricelist').browse(cr, uid, pricelist_context['pricelist'], context)
|
||||
@@ -209,10 +203,6 @@ class website_sale(http.Controller):
|
||||
if attrib_list:
|
||||
post['attrib'] = attrib_list
|
||||
|
||||
style_obj = pool['product.style']
|
||||
style_ids = style_obj.search(cr, uid, [], context=context)
|
||||
styles = style_obj.browse(cr, uid, style_ids, context=context)
|
||||
|
||||
category_obj = pool['product.public.category']
|
||||
category_ids = category_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
|
||||
categs = category_obj.browse(cr, uid, category_ids, context=context)
|
||||
@@ -251,14 +241,11 @@ class website_sale(http.Controller):
|
||||
'products': products,
|
||||
'bins': table_compute().process(products, ppg),
|
||||
'rows': PPR,
|
||||
'styles': styles,
|
||||
'categories': categs,
|
||||
'attributes': attributes,
|
||||
'compute_currency': compute_currency,
|
||||
'keep': keep,
|
||||
'parent_category_ids': parent_category_ids,
|
||||
'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]),
|
||||
}
|
||||
if category:
|
||||
values['main_object'] = category
|
||||
@@ -285,7 +272,7 @@ class website_sale(http.Controller):
|
||||
category_ids = category_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
|
||||
categs = category_obj.browse(cr, uid, category_ids, context=context)
|
||||
|
||||
pricelist = self.get_pricelist()
|
||||
pricelist = request.website.get_current_pricelist()
|
||||
|
||||
from_currency = pool['res.users'].browse(cr, uid, uid, context=context).company_id.currency_id
|
||||
to_currency = pricelist.currency_id
|
||||
|
||||
@@ -41,13 +41,8 @@ class product_public_category(osv.osv):
|
||||
res.append((cat.id, ' / '.join(reversed(names))))
|
||||
return res
|
||||
|
||||
def _name_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None):
|
||||
res = self.name_get(cr, uid, ids, context=context)
|
||||
return dict(res)
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', required=True, translate=True),
|
||||
'complete_name': fields.function(_name_get_fnc, type="char", string='Name'),
|
||||
'parent_id': fields.many2one('product.public.category','Parent Category', select=True),
|
||||
'child_id': fields.one2many('product.public.category', 'parent_id', string='Children Categories'),
|
||||
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of product categories."),
|
||||
@@ -163,18 +158,10 @@ class product_template(osv.Model):
|
||||
class product_product(osv.Model):
|
||||
_inherit = "product.product"
|
||||
|
||||
# Wrappers for call_kw with inherits
|
||||
def open_website_url(self, cr, uid, ids, context=None):
|
||||
template_id = self.browse(cr, uid, ids, context=context).product_tmpl_id.id
|
||||
return self.pool['product.template'].open_website_url(cr, uid, [template_id], context=context)
|
||||
|
||||
def website_publish_button(self, cr, uid, ids, context=None):
|
||||
template_id = self.browse(cr, uid, ids, context=context).product_tmpl_id.id
|
||||
return self.pool['product.template'].website_publish_button(cr, uid, [template_id], context=context)
|
||||
|
||||
def website_publish_button(self, cr, uid, ids, context=None):
|
||||
template_id = self.browse(cr, uid, ids, context=context).product_tmpl_id.id
|
||||
return self.pool['product.template'].website_publish_button(cr, uid, [template_id], context=context)
|
||||
|
||||
class product_attribute(osv.Model):
|
||||
_inherit = "product.attribute"
|
||||
@@ -193,10 +180,3 @@ class product_attribute_value(osv.Model):
|
||||
"specific HTML color index (e.g. #ff0000) to display the color on the website if the "
|
||||
"attibute type is 'Color'."),
|
||||
}
|
||||
|
||||
# TODO in master: remove this function and change 'color' field name
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
# ignore write coming from many2many_tags color system
|
||||
if vals.keys() == ['color'] and isinstance(vals['color'], (int, long)):
|
||||
vals = {}
|
||||
return super(product_attribute_value, self).write(cr, uid, ids, vals, context=context)
|
||||
|
||||
@@ -373,10 +373,6 @@ class website(orm.Model):
|
||||
if line.exists():
|
||||
sale_order._cart_update(product_id=line.product_id.id, line_id=line.id, add_qty=0)
|
||||
|
||||
# update browse record
|
||||
if (code and code != sale_order.pricelist_id.code) or sale_order.partner_id.id != partner.id or force_pricelist:
|
||||
sale_order = sale_order_obj.browse(cr, SUPERUSER_ID, sale_order.id, context=context)
|
||||
|
||||
else:
|
||||
request.session['sale_order_id'] = None
|
||||
return None
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Product Public Categories">
|
||||
<field name="sequence" invisible="1"/>
|
||||
<field name="complete_name"/>
|
||||
<field name="display_name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -56,7 +56,7 @@ class website_sale_options(website_sale):
|
||||
@http.route(['/shop/modal'], type='json', auth="public", methods=['POST'], website=True)
|
||||
def modal(self, product_id, **kw):
|
||||
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
||||
pricelist = self.get_pricelist()
|
||||
pricelist = request.website.get_current_pricelist()
|
||||
if not context.get('pricelist'):
|
||||
context['pricelist'] = int(pricelist)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user