def blogs(self, page=1, **post): domain = request.website.website_domain() Blog = request.env['blog.blog'] blogs = Blog.search(domain, limit=2) if len(blogs) == 1: return werkzeug.utils.redirect('/blog/%s' % slug(blogs[0]), code=302) BlogPost = request.env['blog.post'] total = BlogPost.search_count(domain) pager = request.website.pager( url='/blog', total=total, page=page, step=self._blog_post_per_page, ) posts = BlogPost.search(domain, offset=(page - 1) * self._blog_post_per_page, limit=self._blog_post_per_page) blog_url = QueryURL('', ['blog', 'tag']) return request.render("website_blog.latest_blogs", { 'posts': posts, 'pager': pager, 'blog_url': blog_url, })
def _show_optional_products(self, **kwargs): ks_pid = kwargs.get("product_id") pricelist = request.website.get_current_pricelist() product = request.env['product.template'].browse(ks_pid) ProductCategory = request.env['product.public.category'] categs = ProductCategory.search([('parent_id', '=', False)]) add_qty = int(kwargs.get('add_qty', 1)) product_context = dict(request.env.context, quantity=add_qty, active_id=product.id, partner=request.env.user.partner_id) if not product_context.get('pricelist'): product_context['pricelist'] = pricelist.id product = product.with_context(product_context) keep = QueryURL('/shop', category=product.categ_id and product.categ_id.id, search=[], attrib=[]) values = { 'search': [], 'category': product.categ_id, 'pricelist': pricelist, 'attrib_values': [], # compute_currency deprecated, get from product 'compute_currency': request.website.get_current_pricelist().currency_id, 'attrib_set': (), 'keep': keep, 'image_url': "/web/image/product.template/"+str(product.id)+"/image", 'categories': product.categ_id, 'main_object': product, 'product': product, 'add_qty': add_qty, 'optional_product_ids': [p.with_context({'active_id': p.id}) for p in product.optional_product_ids], # get_attribute_exclusions deprecated, use product method # 'get_attribute_exclusions': self._get_attribute_exclusions, } return [request.env['ir.ui.view'].render_template("eagle_theme_ecomm.product",values),len(values['optional_product_ids'])]
def blog(self, blog=None, tag=None, page=1, **opt): Blog = request.env['blog.blog'] if blog and not blog.can_access_from_current_website(): raise werkzeug.exceptions.NotFound() blogs = Blog.search(request.website.website_domain(), order="create_date asc, id asc") if not blog and len(blogs) == 1: return werkzeug.utils.redirect('/blog/%s' % slug(blogs[0]), code=302) date_begin, date_end, state = opt.get('date_begin'), opt.get('date_end'), opt.get('state') values = self._prepare_blog_values(blogs=blogs, blog=blog, date_begin=date_begin, date_end=date_end, tags=tag, state=state, page=page) if blog: values['main_object'] = blog values['edit_in_backend'] = True values['blog_url'] = QueryURL('', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end) else: values['blog_url'] = QueryURL('/blog', ['tag'], date_begin=date_begin, date_end=date_end) return request.render("website_blog.blog_post_short", values)
def shop(self, page=0, category=None, search='', ppg=False, **post): if request.env['website'].sudo().get_current_website( ).theme_id.name == 'eagle_theme': result = super(EagleshopEcommerceShop, self).shop(page=page, category=category, search=search, **post) # eagle11 # 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 = "" cat_id = [] ppg = 18 product_temp = [] newproduct = [] # product template object product_obj = request.env['product.template'] attrib_list = request.httprequest.args.getlist('attrib') attrib_values = [ list(map(int, v.split("-"))) for v in attrib_list if v ] attributes_ids = set([v[0] for v in attrib_values]) attrib_set = set([v[1] for v in attrib_values]) domain = request.website.sale_product_domain() domain += self._get_search_domain(search, category, attrib_values) url = "/shop" keep = QueryURL('/shop', category=category and int(category), search=search, attrib=attrib_list, order=post.get('order')) if post: request.session.update(post) if search: post["search"] = search prevurl = request.httprequest.referrer if prevurl: if not re.search('/shop', prevurl, re.IGNORECASE): request.session['sortid'] = "" request.session['sort_id'] = "" request.session['pricerange'] = "" request.session['min1'] = "" request.session['max1'] = "" request.session['curr_category'] = "" session = request.session cate_for_price = None # for category filter Category = request.env['product.public.category'] search_categories = False if search: categories = product_obj.search(domain).mapped( 'public_categ_ids') search_categories = Category.search( [('id', 'parent_of', categories.ids)] + request.website.website_domain()) categs = search_categories.filtered(lambda c: not c.parent_id) else: categs = Category.search([('parent_id', '=', False)] + request.website.website_domain()) if category: cate_for_price = int(category) category = request.env['product.public.category'].browse( int(category)) url = "/shop/category/%s" % slug(category) if category != None: for ids in category: cat_id.append(ids.id) domain += [ '|', ('public_categ_ids.id', 'in', cat_id), ('public_categ_ids.parent_id', 'in', cat_id) ] # For Product Sorting if session.get('sort_id'): session_sort = session.get('sort_id') sort = session_sort sort_field = request.env['biztech.product.sortby'].sudo( ).search([('id', '=', int(sort))]) request.session['product_sort_name'] = sort_field.name order_field = sort_field.sort_on.name order_type = sort_field.sort_type sort_order = '%s %s' % (order_field, order_type) if post.get("sort_id"): request.session["sortid"] = [ sort, sort_order, sort_field.name, order_type ] is_price_slider = request.env.ref( 'eagle_theme.product_price_slider') # if is_price_slider and is_price_slider.active: if is_price_slider: # For 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: # ========== 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_count = product_obj.search_count(domain) pager = request.website.pager(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) search_for_category = False if category: search_for_category = True result.qcontext.update({ 'search_count': product_count, 'products': products, 'category': category, 'categories': categs, 'search_for_category': search_for_category, 'pager': pager, 'keep ': keep, 'search': search, 'search_categories_ids': search_categories and search_categories.ids, 'bins': TableCompute().process(products, ppg) }) result.qcontext['domain'] = domain return result else: return super(EagleshopEcommerceShop, self).shop(page=page, category=category, search=search, **post)
def shop(self, page=0, category=None, search='', ppg=False, **post): res = super(emiproThemeBaseExtended, self).shop(page=page, category=category, search=search, ppg=ppg, **post) cust_min_val = request.httprequest.values.get('min_val', False) cust_max_val = request.httprequest.values.get('max_val', False) attrib_list = request.httprequest.args.getlist('attrib') if cust_max_val and cust_min_val: try: tmp_cust_min_val = float(cust_min_val) tmp_cust_max_val = float(cust_max_val) if tmp_cust_min_val > tmp_cust_max_val: return request.redirect('/shop') except Exception as e: return request.redirect('/shop') if not post.get('filter_id', False): return res # If the filter found replace domain with the filter domain and render the shop with default functionality slider_filter = request.env['slider.filter'].sudo().search([ ('id', '=', int(post.get('filter_id'))) ]) if not slider_filter: return request.redirect("/shop") domain = safe_eval(slider_filter.filter_id.domain) if category: category = request.env['product.public.category'].search( [('id', '=', int(category))], limit=1) if not category or not category.can_access_from_current_website(): raise NotFound() if ppg: try: ppg = int(ppg) except ValueError: ppg = PPG post["ppg"] = ppg else: ppg = PPG attrib_list = request.httprequest.args.getlist('attrib') attrib_values = [[int(x) for x in v.split("-")] for v in attrib_list if v] attributes_ids = {v[0] for v in attrib_values} attrib_set = {v[1] for v in attrib_values} keep = QueryURL('/shop', category=category and int(category), search=search, attrib=attrib_list, order=post.get('order')) compute_currency, pricelist_context, pricelist = self._get_compute_currency_and_context( ) request.context = dict(request.context, pricelist=pricelist.id, partner=request.env.user.partner_id) url = "/shop" if search: post["search"] = search if attrib_list: post['attrib'] = attrib_list Product = request.env['product.template'] Category = request.env['product.public.category'] search_categories = False if search: categories = Product.search(domain).mapped('public_categ_ids') search_categories = Category.search( [('id', 'parent_of', categories.ids)] + request.website.website_domain()) categs = search_categories.filtered(lambda c: not c.parent_id) else: categs = Category.search([('parent_id', '=', False)] + request.website.website_domain()) parent_category_ids = [] if category: url = "/shop/category/%s" % slug(category) parent_category_ids = [category.id] current_category = category while current_category.parent_id: parent_category_ids.append(current_category.parent_id.id) current_category = current_category.parent_id product_count = Product.search_count(domain) pager = request.website.pager(url=url, total=product_count, page=page, step=ppg, scope=7, url_args=post) products = Product.search(domain, limit=ppg, offset=pager['offset'], order=self._get_search_order(post)) ProductAttribute = request.env['product.attribute'] if products: # get all products without limit selected_products = Product.search(domain, limit=False) attributes = ProductAttribute.search([ ('attribute_line_ids.product_tmpl_id', 'in', selected_products.ids) ]) else: attributes = ProductAttribute.browse(attributes_ids) values = { 'search': search, 'category': category, 'attrib_values': attrib_values, 'attrib_set': attrib_set, 'pager': pager, 'pricelist': pricelist, 'products': products, 'search_count': product_count, # common for all searchbox 'bins': TableCompute().process(products, ppg), 'rows': PPR, 'categories': categs, 'attributes': attributes, 'compute_currency': compute_currency, 'keep': keep, 'parent_category_ids': parent_category_ids, 'search_categories_ids': search_categories and search_categories.ids, } if category: values['main_object'] = category return request.render("website_sale.products", values)
def blog(self, blog=None, tag=None, page=1, **opt): """ Prepare all values to display the blog. :return dict values: values for the templates, containing - 'blog': current blog - 'blogs': all blogs for navigation - 'pager': pager of posts - 'active_tag_ids' : list of active tag ids, - 'tags_list' : function to built the comma-separated tag list ids (for the url), - 'tags': all tags, for navigation - 'state_info': state of published/unpublished filter - 'nav_list': a dict [year][month] for archives navigation - 'date': date_begin optional parameter, used in archives navigation - 'blog_url': help object to create URLs """ if not blog.can_access_from_current_website(): raise werkzeug.exceptions.NotFound() date_begin, date_end, state = opt.get('date_begin'), opt.get( 'date_end'), opt.get('state') published_count, unpublished_count = 0, 0 domain = request.website.website_domain() BlogPost = request.env['blog.post'] Blog = request.env['blog.blog'] blogs = Blog.search(domain, order="create_date asc") # retrocompatibility to accept tag as slug active_tag_ids = tag and [int(unslug(t)[1]) for t in tag.split(',')] or [] if active_tag_ids: domain += [('tag_ids', 'in', active_tag_ids)] if blog: domain += [('blog_id', '=', blog.id)] if date_begin and date_end: domain += [("post_date", ">=", date_begin), ("post_date", "<=", date_end)] if request.env.user.has_group('website.group_website_designer'): count_domain = domain + [("website_published", "=", True), ("post_date", "<=", fields.Datetime.now()) ] published_count = BlogPost.search_count(count_domain) unpublished_count = BlogPost.search_count(domain) - published_count if state == "published": domain += [("website_published", "=", True), ("post_date", "<=", fields.Datetime.now())] elif state == "unpublished": domain += [ '|', ("website_published", "=", False), ("post_date", ">", fields.Datetime.now()) ] else: domain += [("post_date", "<=", fields.Datetime.now())] blog_url = QueryURL('', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end) blog_posts = BlogPost.search(domain, order="post_date desc") pager = request.website.pager( url=request.httprequest.path.partition('/page/')[0], total=len(blog_posts), page=page, step=self._blog_post_per_page, url_args=opt, ) pager_begin = (page - 1) * self._blog_post_per_page pager_end = page * self._blog_post_per_page blog_posts = blog_posts[pager_begin:pager_end] all_tags = blog.all_tags()[blog.id] # function to create the string list of tag ids, and toggle a given one. # used in the 'Tags Cloud' template. def tags_list(tag_ids, current_tag): tag_ids = list(tag_ids) # required to avoid using the same list if current_tag in tag_ids: tag_ids.remove(current_tag) else: tag_ids.append(current_tag) tag_ids = request.env['blog.tag'].browse(tag_ids).exists() return ','.join(slug(tag) for tag in tag_ids) tag_category = sorted(all_tags.mapped('category_id'), key=lambda category: category.name.upper()) other_tags = sorted(all_tags.filtered(lambda x: not x.category_id), key=lambda tag: tag.name.upper()) values = { 'blog': blog, 'blogs': blogs, 'main_object': blog, 'other_tags': other_tags, 'state_info': { "state": state, "published": published_count, "unpublished": unpublished_count }, 'active_tag_ids': active_tag_ids, 'tags_list': tags_list, 'blog_posts': blog_posts, 'blog_posts_cover_properties': [json.loads(b.cover_properties) for b in blog_posts], 'pager': pager, 'nav_list': self.nav_list(blog), 'blog_url': blog_url, 'date': date_begin, 'tag_category': tag_category, } response = request.render("website_blog.blog_post_short", values) return response
def blog_post(self, blog, blog_post, tag_id=None, page=1, enable_editor=None, **post): """ Prepare all values to display the blog. :return dict values: values for the templates, containing - 'blog_post': browse of the current post - 'blog': browse of the current blog - 'blogs': list of browse records of blogs - 'tag': current tag, if tag_id in parameters - 'tags': all tags, for tag-based navigation - 'pager': a pager on the comments - 'nav_list': a dict [year][month] for archives navigation - 'next_post': next blog post, to direct the user towards the next interesting post """ if not blog.can_access_from_current_website(): raise werkzeug.exceptions.NotFound() BlogPost = request.env['blog.post'] date_begin, date_end = post.get('date_begin'), post.get('date_end') pager_url = "/blogpost/%s" % blog_post.id pager = request.website.pager(url=pager_url, total=len(blog_post.website_message_ids), page=page, step=self._post_comment_per_page, scope=7) pager_begin = (page - 1) * self._post_comment_per_page pager_end = page * self._post_comment_per_page comments = blog_post.website_message_ids[pager_begin:pager_end] tag = None if tag_id: tag = request.env['blog.tag'].browse(int(tag_id)) blog_url = QueryURL('', ['blog', 'tag'], blog=blog_post.blog_id, tag=tag, date_begin=date_begin, date_end=date_end) if not blog_post.blog_id.id == blog.id: return request.redirect("/blog/%s/post/%s" % (slug(blog_post.blog_id), slug(blog_post))) tags = request.env['blog.tag'].search([]) # Find next Post all_post = BlogPost.search([('blog_id', '=', blog.id)]) if not request.env.user.has_group('website.group_website_designer'): all_post = all_post.filtered( lambda r: r.post_date <= fields.Datetime.now()) if blog_post not in all_post: return request.redirect("/blog/%s" % (slug(blog_post.blog_id))) # should always return at least the current post all_post_ids = all_post.ids current_blog_post_index = all_post_ids.index(blog_post.id) nb_posts = len(all_post_ids) next_post_id = all_post_ids[(current_blog_post_index + 1) % nb_posts] if nb_posts > 1 else None next_post = next_post_id and BlogPost.browse(next_post_id) or False values = { 'tags': tags, 'tag': tag, 'blog': blog, 'blog_post': blog_post, 'blog_post_cover_properties': json.loads(blog_post.cover_properties), 'main_object': blog_post, 'nav_list': self.nav_list(blog), 'enable_editor': enable_editor, 'next_post': next_post, 'next_post_cover_properties': json.loads(next_post.cover_properties) if next_post else {}, 'date': date_begin, 'blog_url': blog_url, 'pager': pager, 'comments': comments, } response = request.render("website_blog.blog_post_complete", values) request.session[request.session.sid] = request.session.get( request.session.sid, []) if not (blog_post.id in request.session[request.session.sid]): request.session[request.session.sid].append(blog_post.id) # Increase counter blog_post.sudo().write({ 'visits': blog_post.visits + 1, }) return response
def ks_getShopValues(self, page=0, category=None, search='', ppg=False, **post): add_qty = int(post.get('add_qty', 1)) Category = request.env['product.public.category'] if category: category = Category.search([('id', '=', int(category))], limit=1) if not category or not category.can_access_from_current_website(): raise NotFound() else: category = Category if ppg: try: ppg = int(ppg) post['ppg'] = ppg except ValueError: ppg = False if not ppg: ppg = 24 ppr = request.env['website'].get_current_website().shop_ppr or 4 if request.httprequest.args.getlist('attrib'): attrib_list = request.httprequest.args.getlist('attrib') try: if post.get('filter_variant_remove'): attrib_list.remove(post['filter_variant_remove']) except: pass else: attrib_list = post.get('attrib') try: if post.get('filter_variant_remove'): attrib_list.remove(post['filter_variant_remove']) except: pass if attrib_list == None: attrib_list = [] attrib_values = [[int(x) for x in v.split("-")] for v in attrib_list if v] attributes_ids = {v[0] for v in attrib_values} attrib_set = {v[1] for v in attrib_values} brnd_list = post.get('brnd', request.httprequest.args.getlist('brnd')) if request.httprequest.args.getlist('brnd'): brnd_list = request.httprequest.args.getlist('brnd') try: if post.get('filter_brand_remove'): brnd_list.remove(post['filter_brand_remove']) except: pass else: brnd_list = post.get('brnd') try: if post.get('filter_brand_remove'): brnd_list.remove(post['filter_brand_remove']) except: pass if brnd_list == None: brnd_list = [] if 'filter' in post: ks_filer_val = post['filter'] filter = ks_filer_val.split("_") if filter.__len__() == 2 and filter[0] == "brand": # search = filter[1] brnd_list = [ '0-' + str(request.env["ks_product_manager.ks_brand"].search( [("name", "=", filter[1])], limit=1).id) ] brnds_values = [[int(x) for x in v.split("-")] for v in brnd_list if v] brnds_set = {v[1] for v in brnds_values} product_ids = request.env['product.template'].search( ['&', ('sale_ok', '=', True), ('active', '=', True)]) ks_min_price_avail = ks_max_price_avail = 0 product_count = len(product_ids) if product_ids: request.cr.execute( 'select min(list_price),max(list_price) from product_template where id in %s', (tuple(product_ids.ids), )) min_max_vals = request.cr.fetchall() ks_min_price_avail = min_max_vals[0][0] or 0 ks_max_price_avail = min_max_vals[0][1] or 1 ks_min_selected_price = post.get('min', ks_min_price_avail) ks_max_selected_price = post.get('max', ks_max_price_avail) domain = self._get_search_domain( search, category, attrib_values, brnds_values, ks_max_selected_price=ks_max_selected_price, ks_min_selected_price=ks_min_selected_price) pricelist_context, pricelist = self._get_pricelist_context() request.context = dict(request.context, pricelist=pricelist.id, partner=request.env.user.partner_id) url = "/shop" if search: post["search"] = search if attrib_list: post['attrib'] = attrib_list Product = request.env['product.template'].with_context(bin_size=True) Category = request.env['product.public.category'] search_categories = False search_product = Product.search(domain) website_domain = request.website.website_domain() categs_domain = [('parent_id', '=', False)] + website_domain if search: categories = search_product.mapped('public_categ_ids') search_categories = Category.search( [('product_tmpl_ids', 'in', search_product.ids)] + website_domain).parents_and_self categs_domain.append(('id', 'in', search_categories.ids)) # categs = search_categories.filtered(lambda c: not c.parent_id) else: search_categories = Category categs = Category.search(categs_domain) if category: url = "/shop/category/%s" % slug(category) parent_category_ids = [category.id] current_category = category while current_category.parent_id: parent_category_ids.append(current_category.parent_id.id) current_category = current_category.parent_id keep = QueryURL('/shop', category=category and int(category), search=search, attrib=attrib_list, brnd=brnd_list, min=ks_min_selected_price, ppg=ppg, max=ks_max_selected_price, order=post.get('order')) if post.get('filter_remove'): category = None del (post['filter_remove']) keep = QueryURL('/shop', search=search, attrib=attrib_list, brnd=brnd_list, min=ks_min_selected_price, ppg=ppg, max=ks_max_selected_price, order=post.get('order')) pager = request.website.pager(url=url, total=len(search_product), page=page, step=ppg, scope=7, url_args=post) if post.get('offset', False): pager = request.website.pager(url=url, total=len(search_product) - post['offset'], page=page, step=ppg, scope=7, url_args=post) products = Product.search(domain, offset=post['offset'], limit=ppg, order=self._get_search_order(post)) else: products = Product.search(domain, offset=pager['offset'], limit=ppg, order=self._get_search_order(post)) product_count = len(search_product) ProductAttribute = request.env['product.attribute'] if products: # get all products without limit attributes = ProductAttribute.search([('product_tmpl_ids', 'in', search_product.ids)]) else: attributes = ProductAttribute.browse(attributes_ids) compute_currency = request.website.get_current_pricelist().currency_id brands = request.env["ks_product_manager.ks_brand"].search([ ("ks_is_published", "=", True) ]) layout_mode = '' if not layout_mode: if request.website.viewref( 'website_sale.products_list_view').active: layout_mode = 'list' else: layout_mode = 'grid' ks_img_url = "" if category is None: category = 0 cat_name = '' else: cat_name = category.name if category.ks_categ_background: ks_img_url = "/web/image/product.public.category/" + str( category.id) + "/ks_categ_background" values = { 'search': search, 'category': category, 'attrib_values': attrib_values, 'attrib_set': attrib_set, 'pager': pager, 'pricelist': pricelist, 'ks_img_url': ks_img_url, 'add_qty': add_qty, 'products': products, 'search_count': product_count, # common for all searchbox 'bins': TableCompute().process(products, ppg, ppr), 'ppr': ppr, 'rows': ppr, 'categories': categs, 'attributes': attributes, 'compute_currency': compute_currency, 'keep': keep, # 'parent_category_ids': parent_category_ids, 'search_categories_ids': search_categories.ids, 'layout_mode': layout_mode, 'min_price_selected': ks_min_selected_price, 'max_price_selected': ks_max_selected_price, 'min_price_set': math.floor(float(ks_min_price_avail)), 'max_price_set': math.ceil(float(ks_max_price_avail)), 'brands': brands, 'brnd_set': brnds_set, 'ppg': ppg, 'order': post.get('order'), 'category_name': cat_name, 'page_count': pager['page_count'], 'breadcumb_shop': request.env['eagle_theme_ecomm.ks_breadcumb'].search( []).ks_breadcumb_image_url, } if category: values['main_object'] = category return values
def Ks_MultitabProductData(self, **post): vals={} ks_tabs = [] total_tab=[] ks_slider_id = post.get('id', False) ks_multi_tab_data = request.env['ks_product.multitab_slider'].sudo().search([("id", "=", ks_slider_id)], limit=1) is_ks_wishlist = request.website.viewref('website_sale_wishlist.add_to_wishlist').active is_ks_cart = request.website.viewref('website_sale.products_add_to_cart').active is_ks_compare = request.website.viewref('website_sale_comparison.add_to_compare').active is_ks_product_det = request.website.viewref('website_sale.products_description').active ks_currency_id = request.env['website'].get_current_website().currency_id keep = QueryURL('/shop') ks_tabs=ks_multi_tab_data.tabs_line_ids_line vals = { "tabs": ks_multi_tab_data, "slider_id":ks_slider_id, 'rtl': request.env['res.lang'].search([('code', '=', request.env.lang)]).direction == 'rtl', "ks_Speed": ks_multi_tab_data.ks_Speed, "ks_loop": ks_multi_tab_data.ks_loop, "ks_auto_slide": ks_multi_tab_data.ks_auto_slide, "ks_nav_links": ks_multi_tab_data.ks_nav_links, "ks_items_per_slide": ks_multi_tab_data.ks_items_per_slide, 'website_currency_id': ks_currency_id.symbol, 'website_currency_position': ks_currency_id.position, "is_ks_wishlist": is_ks_wishlist, "is_ks_cart": is_ks_cart, "is_ks_compare": is_ks_compare, "is_ks_product_det": is_ks_product_det, } if ks_tabs: for ks_products_tab in ks_tabs: ks_prods=[] tab_name=ks_products_tab.tabs_line_ids.name tab_id=ks_products_tab.tabs_line_ids.id tab_item_len=len(ks_products_tab.ks_product_template_sliders) for prods in ks_products_tab.ks_product_template_sliders: if prods.is_published: ks_product_var_id = prods['product_variant_id'].id ks_img_url = "/web/image/product.template/" + str(prods['id']) + "/image_256" base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url') prod_price = prods._get_combination_info(prods._get_first_possible_combination(), add_qty=1, pricelist='')[ 'list_price'] if not prod_price: prod_price = prods['list_price'] values = { 'product_name': prods['name'], 'website_currency_id': ks_currency_id.symbol, 'website_currency_position': ks_currency_id.position, 'website_price': float("{0:.2f}".format(prod_price)), 'product_img': ks_img_url, 'prod_id': prods['id'], 'prod_price': prods['list_price'], 'prod_url': "/shop/product/%s" % (prods['id'],), 'brand_name': prods.ks_product_brand_id.name, 'ks_product_var_id': ks_product_var_id, 'description_sale': prods.description_sale, 'is_ks_wishlist': is_ks_wishlist, 'is_ks_cart': is_ks_cart, 'is_ks_compare': is_ks_compare, 'is_ks_product_det': is_ks_product_det, } ks_prods.append(values) total_tab.append([ks_prods,tab_name,'#tab-'+str(tab_id),'tab-'+str(tab_id)]) vals.update({ 'tab_names':total_tab, }) return vals