|
@@ -2,15 +2,14 @@
|
|
# Part of AppJetty. See LICENSE file for full copyright and licensing details.
|
|
# Part of AppJetty. See LICENSE file for full copyright and licensing details.
|
|
|
|
|
|
import re
|
|
import re
|
|
-import math
|
|
|
|
-from odoo import http, SUPERUSER_ID, fields
|
|
|
|
-from odoo.http import request
|
|
|
|
-from odoo.addons.http_routing.models.ir_http import slug
|
|
|
|
-from odoo.addons.website.controllers.main import QueryURL
|
|
|
|
-from odoo.addons.website_sale.controllers import main
|
|
|
|
-from odoo.addons.website_sale.controllers import main as main_shop
|
|
|
|
-from odoo.addons.website_sale.controllers.main import WebsiteSale
|
|
|
|
-from odoo.addons.website_sale.controllers.main import TableCompute
|
|
|
|
|
|
+from openerp import http
|
|
|
|
+from openerp.http import request
|
|
|
|
+from openerp.addons.website.models.website import slug
|
|
|
|
+from openerp.addons.website_sale.controllers import main
|
|
|
|
+from openerp.addons.website_sale.controllers import main as main_shop
|
|
|
|
+from openerp.addons.website_sale.controllers.main import QueryURL
|
|
|
|
+from openerp.addons.website_sale.controllers.main import website_sale
|
|
|
|
+from openerp.addons.website_sale.controllers.main import table_compute
|
|
|
|
|
|
|
|
|
|
class KingfisherProSliderSettings(http.Controller):
|
|
class KingfisherProSliderSettings(http.Controller):
|
|
@@ -18,7 +17,7 @@ class KingfisherProSliderSettings(http.Controller):
|
|
@http.route(['/kingfisher_pro/pro_get_options'], type='json', auth="public", website=True)
|
|
@http.route(['/kingfisher_pro/pro_get_options'], type='json', auth="public", website=True)
|
|
def get_slider_options(self):
|
|
def get_slider_options(self):
|
|
slider_options = []
|
|
slider_options = []
|
|
- option = request.env['product.category.slider.config'].sudo().search(
|
|
|
|
|
|
+ option = request.env['product.category.slider.config'].search(
|
|
[('active', '=', True)], order="name asc")
|
|
[('active', '=', True)], order="name asc")
|
|
for record in option:
|
|
for record in option:
|
|
slider_options.append({'id': record.id,
|
|
slider_options.append({'id': record.id,
|
|
@@ -27,18 +26,9 @@ class KingfisherProSliderSettings(http.Controller):
|
|
|
|
|
|
@http.route(['/kingfisher_pro/pro_get_dynamic_slider'], type='http', auth='public', website=True)
|
|
@http.route(['/kingfisher_pro/pro_get_dynamic_slider'], type='http', auth='public', website=True)
|
|
def get_dynamic_slider(self, **post):
|
|
def get_dynamic_slider(self, **post):
|
|
- uid, context, pool = request.uid, dict(request.context), request.env
|
|
|
|
if post.get('slider-type'):
|
|
if post.get('slider-type'):
|
|
slider_header = request.env['product.category.slider.config'].sudo().search(
|
|
slider_header = request.env['product.category.slider.config'].sudo().search(
|
|
[('id', '=', int(post.get('slider-type')))])
|
|
[('id', '=', int(post.get('slider-type')))])
|
|
- if not context.get('pricelist'):
|
|
|
|
- pricelist = request.website.get_current_pricelist()
|
|
|
|
- context = dict(request.context, pricelist=int(pricelist))
|
|
|
|
- else:
|
|
|
|
- pricelist = pool.get('product.pricelist').browse(
|
|
|
|
- context['pricelist'])
|
|
|
|
-
|
|
|
|
- context.update({'pricelist': pricelist.id})
|
|
|
|
values = {
|
|
values = {
|
|
'slider_header': slider_header
|
|
'slider_header': slider_header
|
|
}
|
|
}
|
|
@@ -48,20 +38,12 @@ class KingfisherProSliderSettings(http.Controller):
|
|
if slider_header.prod_cat_type == 'category':
|
|
if slider_header.prod_cat_type == 'category':
|
|
values.update(
|
|
values.update(
|
|
{'slider_details': slider_header.collections_category})
|
|
{'slider_details': slider_header.collections_category})
|
|
-
|
|
|
|
- from_currency = pool['res.users'].sudo().browse(
|
|
|
|
- uid).company_id.currency_id
|
|
|
|
- to_currency = pricelist.currency_id
|
|
|
|
-
|
|
|
|
- def compute_currency(price): return pool['res.currency']._convert(
|
|
|
|
- price, from_currency, to_currency, fields.Date.today())
|
|
|
|
- values.update({'slider_type': slider_header.prod_cat_type,
|
|
|
|
- 'compute_currency': compute_currency, })
|
|
|
|
- return request.render("kingfisher_pro.kingfisher_pro_pro_cat_slider_view", values)
|
|
|
|
|
|
+ values.update({'slider_type': slider_header.prod_cat_type})
|
|
|
|
+ return request.website.render("kingfisher_pro.kingfisher_pro_pro_cat_slider_view", values)
|
|
|
|
|
|
@http.route(['/kingfisher_pro/pro_image_effect_config'], type='json', auth='public', website=True)
|
|
@http.route(['/kingfisher_pro/pro_image_effect_config'], type='json', auth='public', website=True)
|
|
def product_image_dynamic_slider(self, **post):
|
|
def product_image_dynamic_slider(self, **post):
|
|
- slider_data = request.env['product.category.slider.config'].sudo().search(
|
|
|
|
|
|
+ slider_data = request.env['product.category.slider.config'].search(
|
|
[('id', '=', int(post.get('slider_type')))])
|
|
[('id', '=', int(post.get('slider_type')))])
|
|
values = {
|
|
values = {
|
|
's_id': slider_data.prod_cat_type + str(slider_data.id),
|
|
's_id': slider_data.prod_cat_type + str(slider_data.id),
|
|
@@ -74,7 +56,7 @@ class KingfisherProSliderSettings(http.Controller):
|
|
@http.route(['/kingfisher_pro/blog_get_options'], type='json', auth="public", website=True)
|
|
@http.route(['/kingfisher_pro/blog_get_options'], type='json', auth="public", website=True)
|
|
def king_blog_get_slider_options(self):
|
|
def king_blog_get_slider_options(self):
|
|
slider_options = []
|
|
slider_options = []
|
|
- option = request.env['blog.slider.config'].sudo().search(
|
|
|
|
|
|
+ option = request.env['blog.slider.config'].search(
|
|
[('active', '=', True)], order="name asc")
|
|
[('active', '=', True)], order="name asc")
|
|
for record in option:
|
|
for record in option:
|
|
slider_options.append({'id': record.id,
|
|
slider_options.append({'id': record.id,
|
|
@@ -90,11 +72,11 @@ class KingfisherProSliderSettings(http.Controller):
|
|
'slider_header': slider_header,
|
|
'slider_header': slider_header,
|
|
'blog_slider_details': slider_header.collections_blog_post,
|
|
'blog_slider_details': slider_header.collections_blog_post,
|
|
}
|
|
}
|
|
- return request.render("kingfisher_pro.kingfisher_pro_blog_slider_view", values)
|
|
|
|
|
|
+ return request.website.render("kingfisher_pro.kingfisher_pro_blog_slider_view", values)
|
|
|
|
|
|
@http.route(['/kingfisher_pro/blog_image_effect_config'], type='json', auth='public', website=True)
|
|
@http.route(['/kingfisher_pro/blog_image_effect_config'], type='json', auth='public', website=True)
|
|
def king_blog_product_image_dynamic_slider(self, **post):
|
|
def king_blog_product_image_dynamic_slider(self, **post):
|
|
- slider_data = request.env['blog.slider.config'].sudo().search(
|
|
|
|
|
|
+ slider_data = request.env['blog.slider.config'].search(
|
|
[('id', '=', int(post.get('slider_type')))])
|
|
[('id', '=', int(post.get('slider_type')))])
|
|
values = {
|
|
values = {
|
|
's_id': slider_data.no_of_counts + '-' + str(slider_data.id),
|
|
's_id': slider_data.no_of_counts + '-' + str(slider_data.id),
|
|
@@ -125,7 +107,7 @@ class KingfisherProSliderSettings(http.Controller):
|
|
@http.route(['/kingfisher_pro/product_multi_get_options'], type='json', auth="public", website=True)
|
|
@http.route(['/kingfisher_pro/product_multi_get_options'], type='json', auth="public", website=True)
|
|
def product_multi_get_slider_options(self):
|
|
def product_multi_get_slider_options(self):
|
|
slider_options = []
|
|
slider_options = []
|
|
- option = request.env['multi.slider.config'].sudo().search(
|
|
|
|
|
|
+ option = request.env['multi.slider.config'].search(
|
|
[('active', '=', True)], order="name asc")
|
|
[('active', '=', True)], order="name asc")
|
|
for record in option:
|
|
for record in option:
|
|
slider_options.append({'id': record.id,
|
|
slider_options.append({'id': record.id,
|
|
@@ -134,35 +116,18 @@ class KingfisherProSliderSettings(http.Controller):
|
|
|
|
|
|
@http.route(['/kingfisher_pro/product_multi_get_dynamic_slider'], type='http', auth='public', website=True)
|
|
@http.route(['/kingfisher_pro/product_multi_get_dynamic_slider'], type='http', auth='public', website=True)
|
|
def product_multi_get_dynamic_slider(self, **post):
|
|
def product_multi_get_dynamic_slider(self, **post):
|
|
- context, pool = dict(request.context), request.env
|
|
|
|
if post.get('slider-type'):
|
|
if post.get('slider-type'):
|
|
slider_header = request.env['multi.slider.config'].sudo().search(
|
|
slider_header = request.env['multi.slider.config'].sudo().search(
|
|
[('id', '=', int(post.get('slider-type')))])
|
|
[('id', '=', int(post.get('slider-type')))])
|
|
-
|
|
|
|
- if not context.get('pricelist'):
|
|
|
|
- pricelist = request.website.get_current_pricelist()
|
|
|
|
- context = dict(request.context, pricelist=int(pricelist))
|
|
|
|
- else:
|
|
|
|
- pricelist = pool.get('product.pricelist').browse(
|
|
|
|
- context['pricelist'])
|
|
|
|
-
|
|
|
|
- context.update({'pricelist': pricelist.id})
|
|
|
|
- from_currency = pool['res.users'].sudo().browse(
|
|
|
|
- SUPERUSER_ID).company_id.currency_id
|
|
|
|
- to_currency = pricelist.currency_id
|
|
|
|
-
|
|
|
|
- def compute_currency(price): return pool['res.currency']._convert(
|
|
|
|
- price, from_currency, to_currency, fields.Date.today())
|
|
|
|
values = {
|
|
values = {
|
|
'slider_details': slider_header,
|
|
'slider_details': slider_header,
|
|
- 'slider_header': slider_header,
|
|
|
|
- 'compute_currency': compute_currency,
|
|
|
|
|
|
+ 'slider_header': slider_header
|
|
}
|
|
}
|
|
- return request.render("kingfisher_pro.kingfisher_pro_multi_cat_slider_view", values)
|
|
|
|
|
|
+ return request.website.render("kingfisher_pro.kingfisher_pro_multi_cat_slider_view", values)
|
|
|
|
|
|
@http.route(['/kingfisher_pro/product_multi_image_effect_config'], type='json', auth='public', website=True)
|
|
@http.route(['/kingfisher_pro/product_multi_image_effect_config'], type='json', auth='public', website=True)
|
|
def product_multi_product_image_dynamic_slider(self, **post):
|
|
def product_multi_product_image_dynamic_slider(self, **post):
|
|
- slider_data = request.env['multi.slider.config'].sudo().search(
|
|
|
|
|
|
+ slider_data = request.env['multi.slider.config'].search(
|
|
[('id', '=', int(post.get('slider_type')))])
|
|
[('id', '=', int(post.get('slider_type')))])
|
|
values = {
|
|
values = {
|
|
's_id': slider_data.no_of_collection + '-' + str(slider_data.id),
|
|
's_id': slider_data.no_of_collection + '-' + str(slider_data.id),
|
|
@@ -173,7 +138,7 @@ class KingfisherProSliderSettings(http.Controller):
|
|
return values
|
|
return values
|
|
|
|
|
|
|
|
|
|
-class KingfisherProBrandSlider(WebsiteSale):
|
|
|
|
|
|
+class KingfisherProBrandSlider(website_sale):
|
|
|
|
|
|
@http.route(['/shop/pager_selection/<model("product.per.page.no"):pl_id>'], type='http', auth="public", website=True)
|
|
@http.route(['/shop/pager_selection/<model("product.per.page.no"):pl_id>'], type='http', auth="public", website=True)
|
|
def product_page_change(self, pl_id, **post):
|
|
def product_page_change(self, pl_id, **post):
|
|
@@ -190,40 +155,29 @@ class KingfisherProBrandSlider(WebsiteSale):
|
|
auth='public',
|
|
auth='public',
|
|
website=True)
|
|
website=True)
|
|
def shop(self, page=0, category=None, brand=None, search='', ppg=False, **post):
|
|
def shop(self, page=0, category=None, brand=None, search='', ppg=False, **post):
|
|
- add_qty = int(post.get('add_qty', 1))
|
|
|
|
|
|
+ cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
|
if brand:
|
|
if brand:
|
|
- req_ctx = request.context.copy()
|
|
|
|
- req_ctx.setdefault('brand_id', int(brand))
|
|
|
|
- request.context = req_ctx
|
|
|
|
|
|
+ request.context.setdefault('brand_id', int(brand))
|
|
result = super(KingfisherProBrandSlider, self).shop(
|
|
result = super(KingfisherProBrandSlider, self).shop(
|
|
page=page, category=category, brand=brand, search=search, **post)
|
|
page=page, category=category, brand=brand, search=search, **post)
|
|
-
|
|
|
|
- # odoo11
|
|
|
|
- # for displaying after whishlist or add to cart button n product_detail page
|
|
|
|
- if request.env.get('product.attribute.category') != None:
|
|
|
|
- compare_tmpl_obj = request.env.ref(
|
|
|
|
- 'website_sale_comparison.product_add_to_compare')
|
|
|
|
- if compare_tmpl_obj and compare_tmpl_obj.priority != 20:
|
|
|
|
- compare_tmpl_obj.sudo().write({'priority': 20})
|
|
|
|
-
|
|
|
|
sort_order = ""
|
|
sort_order = ""
|
|
cat_id = []
|
|
cat_id = []
|
|
- page_no = request.env['product.per.page.no'].sudo().search(
|
|
|
|
- [('set_default_check', '=', True)])
|
|
|
|
|
|
+ page_obj = pool.get('product.per.page.no')
|
|
|
|
+ page_id = page_obj.search(
|
|
|
|
+ cr, uid, [('set_default_check', '=', True)], context=context)
|
|
|
|
+ page_no = page_obj.browse(cr, uid, page_id, context=context)
|
|
if page_no:
|
|
if page_no:
|
|
ppg = page_no.name
|
|
ppg = page_no.name
|
|
else:
|
|
else:
|
|
ppg = main_shop.PPG
|
|
ppg = main_shop.PPG
|
|
- product_tmp = []
|
|
|
|
|
|
+ product = []
|
|
newproduct = []
|
|
newproduct = []
|
|
- product_price = []
|
|
|
|
|
|
|
|
# product template object
|
|
# product template object
|
|
- product_obj = request.env['product.template']
|
|
|
|
|
|
+ product_obj = pool.get('product.template')
|
|
|
|
|
|
attrib_list = request.httprequest.args.getlist('attrib')
|
|
attrib_list = request.httprequest.args.getlist('attrib')
|
|
- attrib_values = [list(map(int, v.split("-")))
|
|
|
|
- for v in attrib_list if v]
|
|
|
|
|
|
+ attrib_values = [map(int, v.split("-")) for v in attrib_list if v]
|
|
attributes_ids = set([v[0] for v in attrib_values])
|
|
attributes_ids = set([v[0] for v in attrib_values])
|
|
attrib_set = set([v[1] for v in attrib_values])
|
|
attrib_set = set([v[1] for v in attrib_values])
|
|
domain = request.website.sale_product_domain()
|
|
domain = request.website.sale_product_domain()
|
|
@@ -231,8 +185,7 @@ class KingfisherProBrandSlider(WebsiteSale):
|
|
url = "/shop"
|
|
url = "/shop"
|
|
|
|
|
|
keep = QueryURL('/shop', category=category and int(category), search=search,
|
|
keep = QueryURL('/shop', category=category and int(category), search=search,
|
|
- attrib=attrib_list, order=post.get('order'))
|
|
|
|
- pricelist_context, pricelist = self._get_pricelist_context()
|
|
|
|
|
|
+ attrib=attrib_list, order=post.get('order'))
|
|
if post:
|
|
if post:
|
|
request.session.update(post)
|
|
request.session.update(post)
|
|
|
|
|
|
@@ -251,32 +204,29 @@ class KingfisherProBrandSlider(WebsiteSale):
|
|
request.session['pricerange'] = ""
|
|
request.session['pricerange'] = ""
|
|
request.session['min1'] = ""
|
|
request.session['min1'] = ""
|
|
request.session['max1'] = ""
|
|
request.session['max1'] = ""
|
|
- request.session['curr_category'] = ""
|
|
|
|
|
|
|
|
session = request.session
|
|
session = request.session
|
|
- cate_for_price = None
|
|
|
|
# for category filter
|
|
# for category filter
|
|
if category:
|
|
if category:
|
|
- cate_for_price = int(category)
|
|
|
|
- category = request.env['product.public.category'].sudo().browse(
|
|
|
|
- int(category))
|
|
|
|
|
|
+ category = pool['product.public.category'].browse(
|
|
|
|
+ cr, uid, int(category), context=context)
|
|
url = "/shop/category/%s" % slug(category)
|
|
url = "/shop/category/%s" % slug(category)
|
|
- if not category or not category.can_access_from_current_website():
|
|
|
|
- raise NotFound()
|
|
|
|
|
|
|
|
if category != None:
|
|
if category != None:
|
|
for ids in category:
|
|
for ids in category:
|
|
cat_id.append(ids.id)
|
|
cat_id.append(ids.id)
|
|
domain += ['|', ('public_categ_ids.id', 'in', cat_id),
|
|
domain += ['|', ('public_categ_ids.id', 'in', cat_id),
|
|
('public_categ_ids.parent_id', 'in', cat_id)]
|
|
('public_categ_ids.parent_id', 'in', cat_id)]
|
|
-
|
|
|
|
# for tag filter
|
|
# for tag filter
|
|
if session.get('tag'):
|
|
if session.get('tag'):
|
|
- session_tag = session.get('tag')[0]
|
|
|
|
- tag = session_tag
|
|
|
|
|
|
+ session_tag = session.get('tag')
|
|
|
|
+ tag = session_tag[0]
|
|
|
|
+ tags_obj = pool['biztech.product.tags']
|
|
|
|
+ tags_ids = tags_obj.search(cr, uid, [], context=context)
|
|
|
|
+ tags = tags_obj.browse(cr, uid, tags_ids, context=context)
|
|
if tag:
|
|
if tag:
|
|
- tag = request.env['biztech.product.tags'].sudo().browse(
|
|
|
|
- int(tag))
|
|
|
|
|
|
+ tag = pool['biztech.product.tags'].browse(
|
|
|
|
+ cr, uid, int(tag), context=context)
|
|
domain += [('biztech_tag_ids', '=', int(tag))]
|
|
domain += [('biztech_tag_ids', '=', int(tag))]
|
|
request.session["tag"] = [tag.id, tag.name]
|
|
request.session["tag"] = [tag.id, tag.name]
|
|
|
|
|
|
@@ -284,8 +234,11 @@ class KingfisherProBrandSlider(WebsiteSale):
|
|
if session.get('sort_id'):
|
|
if session.get('sort_id'):
|
|
session_sort = session.get('sort_id')
|
|
session_sort = session.get('sort_id')
|
|
sort = session_sort
|
|
sort = session_sort
|
|
- sort_field = request.env['biztech.product.sortby'].sudo().browse(
|
|
|
|
- int(sort))
|
|
|
|
|
|
+ sorts_obj = pool['biztech.product.sortby']
|
|
|
|
+ sorts_ids = sorts_obj.search(cr, uid, [], context=context)
|
|
|
|
+ sorts = sorts_obj.browse(cr, uid, sorts_ids, context=context)
|
|
|
|
+ sort_field = pool['biztech.product.sortby'].browse(
|
|
|
|
+ cr, uid, int(sort), context=context)
|
|
request.session['product_sort_name'] = sort_field.name
|
|
request.session['product_sort_name'] = sort_field.name
|
|
order_field = sort_field.sort_on.name
|
|
order_field = sort_field.sort_on.name
|
|
order_type = sort_field.sort_type
|
|
order_type = sort_field.sort_type
|
|
@@ -295,113 +248,77 @@ class KingfisherProBrandSlider(WebsiteSale):
|
|
sort, sort_order, sort_field.name, order_type]
|
|
sort, sort_order, sort_field.name, order_type]
|
|
|
|
|
|
# For Price slider
|
|
# For Price slider
|
|
- is_price_slider = request.env.ref(
|
|
|
|
- 'kingfisher_pro.kingfisher_pro_slider_layout')
|
|
|
|
- if is_price_slider:
|
|
|
|
-
|
|
|
|
- is_discount_hide = True if request.website.get_current_pricelist(
|
|
|
|
- ).discount_policy == 'with_discount' else False
|
|
|
|
-
|
|
|
|
- product_slider_ids = []
|
|
|
|
- asc_product_slider_ids = product_obj.search(
|
|
|
|
- domain, limit=1, order='list_price')
|
|
|
|
- desc_product_slider_ids = product_obj.search(
|
|
|
|
- domain, limit=1, order='list_price desc')
|
|
|
|
- if asc_product_slider_ids:
|
|
|
|
- # product_slider_ids.append(asc_product_slider_ids.website_price)
|
|
|
|
- product_slider_ids.append(
|
|
|
|
- asc_product_slider_ids.website_price if is_discount_hide else asc_product_slider_ids.list_price)
|
|
|
|
- if desc_product_slider_ids:
|
|
|
|
- # product_slider_ids.append(desc_product_slider_ids.website_price)
|
|
|
|
- product_slider_ids.append(
|
|
|
|
- desc_product_slider_ids.website_price if is_discount_hide else desc_product_slider_ids.list_price)
|
|
|
|
-
|
|
|
|
- if product_slider_ids:
|
|
|
|
- if post.get("range1") or post.get("range2") or not post.get("range1") or not post.get("range2"):
|
|
|
|
- range1 = min(product_slider_ids)
|
|
|
|
- range2 = max(product_slider_ids)
|
|
|
|
- result.qcontext['range1'] = math.floor(range1)
|
|
|
|
- result.qcontext['range2'] = math.ceil(range2)
|
|
|
|
-
|
|
|
|
- if request.session.get('pricerange'):
|
|
|
|
- if cate_for_price and request.session.get('curr_category') and request.session.get('curr_category') != int(cate_for_price):
|
|
|
|
- request.session["min1"] = math.floor(range1)
|
|
|
|
- request.session["max1"] = math.ceil(range2)
|
|
|
|
-
|
|
|
|
- if session.get("min1") and session["min1"]:
|
|
|
|
- post["min1"] = session["min1"]
|
|
|
|
- if session.get("max1") and session["max1"]:
|
|
|
|
- post["max1"] = session["max1"]
|
|
|
|
- if range1:
|
|
|
|
- post["range1"] = range1
|
|
|
|
- if range2:
|
|
|
|
- post["range2"] = range2
|
|
|
|
- if range1 == range2:
|
|
|
|
- post['range1'] = 0.0
|
|
|
|
-
|
|
|
|
- if request.session.get('min1') or request.session.get('max1'):
|
|
|
|
- if request.session.get('min1'):
|
|
|
|
- if request.session['min1'] != None:
|
|
|
|
- # domain += [('list_price', '>=', request.session.get('min1')), ('list_price', '<=', request.session.get('max1'))]
|
|
|
|
- # ========== for hide list-website price diffrence ====================
|
|
|
|
- if is_discount_hide:
|
|
|
|
- price_product_list = []
|
|
|
|
- product_withprice = product_obj.search(domain)
|
|
|
|
- for prod_id in product_withprice:
|
|
|
|
- if prod_id.website_price >= float(request.session['min1']) and prod_id.website_price <= float(request.session['max1']):
|
|
|
|
- price_product_list.append(prod_id.id)
|
|
|
|
-
|
|
|
|
- if price_product_list:
|
|
|
|
- domain += [('id', 'in',
|
|
|
|
- price_product_list)]
|
|
|
|
- else:
|
|
|
|
- domain += [('id', 'in', [])]
|
|
|
|
- else:
|
|
|
|
- domain += [('list_price', '>=', request.session.get('min1')),
|
|
|
|
- ('list_price', '<=', request.session.get('max1'))]
|
|
|
|
-# ==============================
|
|
|
|
- request.session["pricerange"] = str(
|
|
|
|
- request.session['min1'])+"-To-"+str(request.session['max1'])
|
|
|
|
-
|
|
|
|
- if session.get('min1') and session['min1']:
|
|
|
|
- result.qcontext['min1'] = session["min1"]
|
|
|
|
- result.qcontext['max1'] = session["max1"]
|
|
|
|
-
|
|
|
|
- if cate_for_price:
|
|
|
|
- request.session['curr_category'] = int(cate_for_price)
|
|
|
|
|
|
+ product_slider_ids = product_obj.search(cr, uid, [], context=context)
|
|
|
|
+ products_slider = product_obj.browse(
|
|
|
|
+ cr, uid, product_slider_ids, context=context)
|
|
|
|
+ product_withprice = products_slider._product_template_price(
|
|
|
|
+ products_slider, domain)
|
|
|
|
+
|
|
|
|
+ if product_withprice:
|
|
|
|
+ if post.get("range1") or post.get("range2") or not post.get("range1") or not post.get("range2"):
|
|
|
|
+ range1 = min(product_withprice.values())
|
|
|
|
+ range2 = max(product_withprice.values())
|
|
|
|
+ result.qcontext['range1'] = range1
|
|
|
|
+ result.qcontext['range2'] = range2
|
|
|
|
+
|
|
|
|
+ if session.get("min1") and session["min1"]:
|
|
|
|
+ post["min1"] = session["min1"]
|
|
|
|
+ if session.get("max1") and session["max1"]:
|
|
|
|
+ post["max1"] = session["max1"]
|
|
|
|
+ if range1:
|
|
|
|
+ post["range1"] = range1
|
|
|
|
+ if range1:
|
|
|
|
+ post["range2"] = range1
|
|
|
|
+
|
|
|
|
+ if request.session.get('min1') or request.session.get('max1'):
|
|
|
|
+ if request.session.get('min1'):
|
|
|
|
+ if request.session['min1'] != None:
|
|
|
|
+ for prod_id in product_withprice:
|
|
|
|
+ if product_withprice.get(prod_id) >= float(request.session['min1']) and product_withprice.get(prod_id) <= float(request.session['max1']):
|
|
|
|
+ product.append(prod_id)
|
|
|
|
+ request.session["pricerange"] = str(
|
|
|
|
+ request.session['min1'])+"-To-"+str(request.session['max1'])
|
|
|
|
+ newproduct = product
|
|
|
|
+ domain += [('id', 'in', newproduct)]
|
|
|
|
+
|
|
|
|
+ if session.get('min1') and session['min1']:
|
|
|
|
+ result.qcontext['min1'] = session["min1"]
|
|
|
|
+ result.qcontext['max1'] = session["max1"]
|
|
|
|
|
|
if request.session.get('default_paging_no'):
|
|
if request.session.get('default_paging_no'):
|
|
ppg = int(request.session.get('default_paging_no'))
|
|
ppg = int(request.session.get('default_paging_no'))
|
|
|
|
|
|
- product_count = product_obj.search_count(domain)
|
|
|
|
|
|
+ product_count = product_obj.search_count(
|
|
|
|
+ cr, uid, domain, context=context)
|
|
pager = request.website.pager(
|
|
pager = request.website.pager(
|
|
url=url, total=product_count, page=page, step=ppg, scope=7, url_args=post)
|
|
url=url, total=product_count, page=page, step=ppg, scope=7, url_args=post)
|
|
- products = product_obj.search(
|
|
|
|
- domain, limit=ppg, offset=pager['offset'], order=sort_order)
|
|
|
|
- compute_currency = self._get_compute_currency(pricelist, products[:1])
|
|
|
|
- result.qcontext.update({'product_count': product_count,
|
|
|
|
- 'products': products,
|
|
|
|
- 'category': category,
|
|
|
|
- 'pager': pager,
|
|
|
|
- 'add_qty': add_qty,
|
|
|
|
- 'compute_currency': compute_currency,
|
|
|
|
- 'keep': keep,
|
|
|
|
- 'search': search,
|
|
|
|
- 'bins': TableCompute().process(products, ppg)})
|
|
|
|
|
|
+ product_ids = product_obj.search(
|
|
|
|
+ cr, uid, domain, limit=ppg, offset=pager['offset'], order=sort_order, context=context)
|
|
|
|
+ products = product_obj.browse(cr, uid, product_ids, context=context)
|
|
|
|
+
|
|
|
|
+ result.qcontext.update({'product_count': product_count})
|
|
|
|
+ result.qcontext.update({'products': products})
|
|
|
|
+ result.qcontext.update({'category': category})
|
|
|
|
+ result.qcontext.update({'pager': pager})
|
|
|
|
+ result.qcontext.update({'keep': keep})
|
|
|
|
+ result.qcontext.update({'search': search})
|
|
|
|
+
|
|
|
|
+ result.qcontext.update(
|
|
|
|
+ {'bins': table_compute().process(products, ppg)})
|
|
|
|
|
|
result.qcontext['brand'] = brand
|
|
result.qcontext['brand'] = brand
|
|
- result.qcontext['domain'] = domain
|
|
|
|
- result.qcontext['brand_obj'] = request.env['product.brands'].sudo().search([
|
|
|
|
- ('id', '=', brand)])
|
|
|
|
|
|
+ result.qcontext['brand_obj'] = request.env[
|
|
|
|
+ 'product.brands'].search([('id', '=', brand)])
|
|
|
|
+
|
|
return result
|
|
return result
|
|
|
|
|
|
@http.route()
|
|
@http.route()
|
|
def cart_update_json(self, product_id, line_id=None, add_qty=None, set_qty=None, display=True):
|
|
def cart_update_json(self, product_id, line_id=None, add_qty=None, set_qty=None, display=True):
|
|
result = super(KingfisherProBrandSlider, self).cart_update_json(
|
|
result = super(KingfisherProBrandSlider, self).cart_update_json(
|
|
- product_id, line_id, add_qty, set_qty, display)
|
|
|
|
- order = request.website.sale_get_order()
|
|
|
|
- result.update({'kingfisher_pro.hover_total': request.env['ir.ui.view'].render_template("kingfisher_pro.hover_total", {
|
|
|
|
- 'website_sale_order': order})
|
|
|
|
|
|
+ product_id=product_id, line_id=line_id, add_qty=add_qty, set_qty=set_qty, display=display)
|
|
|
|
+ result.update({'kingfisher_pro.hover_total': request.website._render("kingfisher_pro.hover_total", {
|
|
|
|
+ 'website_sale_order': request.website.sale_get_order()
|
|
|
|
+ })
|
|
})
|
|
})
|
|
return result
|
|
return result
|
|
|
|
|
|
@@ -416,7 +333,7 @@ class KingfisherProBrandSlider(WebsiteSale):
|
|
}
|
|
}
|
|
|
|
|
|
if post.get('product_count'):
|
|
if post.get('product_count'):
|
|
- brand_data = request.env['product.brands'].sudo().search(
|
|
|
|
|
|
+ brand_data = request.env['product.brands'].search(
|
|
[], limit=int(post.get('product_count')))
|
|
[], limit=int(post.get('product_count')))
|
|
if brand_data:
|
|
if brand_data:
|
|
value['website_brands'] = brand_data
|
|
value['website_brands'] = brand_data
|
|
@@ -424,7 +341,7 @@ class KingfisherProBrandSlider(WebsiteSale):
|
|
if post.get('product_label'):
|
|
if post.get('product_label'):
|
|
value['brand_header'] = post.get('product_label')
|
|
value['brand_header'] = post.get('product_label')
|
|
|
|
|
|
- return request.render("kingfisher_pro.kingfisher_pro_brand_slider_view", value)
|
|
|
|
|
|
+ return request.website.render("kingfisher_pro.kingfisher_pro_brand_slider_view", value)
|
|
|
|
|
|
@http.route(['/kingfisher_pro/removeattribute'], type='json', auth='public', website=True)
|
|
@http.route(['/kingfisher_pro/removeattribute'], type='json', auth='public', website=True)
|
|
def remove_selected_attribute(self, **post):
|
|
def remove_selected_attribute(self, **post):
|