Browse Source

[ADD]Initial Commit

pull/81/head
SHEREEF PT 8 years ago
parent
commit
f91b552f3e
  1. 36
      website_sale_advanced_search/README.md
  2. 23
      website_sale_advanced_search/__init__.py
  3. 47
      website_sale_advanced_search/__openerp__.py
  4. 23
      website_sale_advanced_search/controllers/__init__.py
  5. 51
      website_sale_advanced_search/controllers/main.py
  6. BIN
      website_sale_advanced_search/static/description/banner.jpg
  7. BIN
      website_sale_advanced_search/static/description/cybro_logo.png
  8. BIN
      website_sale_advanced_search/static/description/icon.png
  9. 109
      website_sale_advanced_search/static/description/index.html
  10. BIN
      website_sale_advanced_search/static/images/categories.png
  11. BIN
      website_sale_advanced_search/static/images/cybro_logo.png
  12. BIN
      website_sale_advanced_search/static/images/screen2.png
  13. BIN
      website_sale_advanced_search/static/images/screen3.png
  14. BIN
      website_sale_advanced_search/static/images/search_occurance.png
  15. 45
      website_sale_advanced_search/static/js/product_search.js
  16. 9
      website_sale_advanced_search/views/assets.xml
  17. 32
      website_sale_advanced_search/views/template.xml

36
website_sale_advanced_search/README.md

@ -0,0 +1,36 @@
# Ecommerce Advanced Search
Ecommerce Advanced Search is an odoo e-commerse based addon, which enhance the searching criterias including category selector.
- E-commerce product search
- Can Select Category
- New drop down with product website categories
- Find all products related to searching content according to category selected
- Display results as drop down
- Selection of results redirects to product description page
### Depends
Ecommerce Advanced Search addon depends on Odoo website and website_sale
### Tech
* [jQuery] - Search AutoComplete
* [Python] - Controllers
* [XML] - Odoo website templates
### Installation
- www.odoo.com/documentation/9.0/setup/install.html
- Install our custom addon, which also installs its depends [website, website_sale]
### Usage
>Select categories from the search drop down
>First Install our custom addon, then go to website and select Shop menu.
On the product search bar type any key, then it will make searching hints as dropdown box under the bar.
Selecting one of results will redirect to the current product description page.
License
----
GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (LGPLv3)
(http://www.gnu.org/licenses/agpl.html)

23
website_sale_advanced_search/__init__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Hilar AK(<hilar@cybrosys.in>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import controllers

47
website_sale_advanced_search/__openerp__.py

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Hilar AK(<hilar@cybrosys.in>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': "Advanced Search in ECommerce ",
'version': '9.0.1.0.0',
'summary': """Odoo e-commerce advanced search.""",
'description': """
Odoo e-commerce advanced search. Autocomplete search product with category and display name
""",
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'website': "http://www.cybrosys.com",
'category': 'Website',
'depends': ['base',
'website',
'website_sale',
],
'data': [
'views/assets.xml',
'views/template.xml'
],
'demo': [],
'images': ['static/description/banner.jpg'],
'license': 'LGPL-3',
'installable': True,
'auto_install': False,
}

23
website_sale_advanced_search/controllers/__init__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Hilar AK(<hilar@cybrosys.in>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import main

51
website_sale_advanced_search/controllers/main.py

@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Hilar AK(<hilar@cybrosys.in>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import json
from openerp import http
from openerp.http import request
class WebsiteSearch(http.Controller):
@http.route('/shop/search', csrf=False, type="http", methods=['POST', 'GET'], auth="public", website=True)
def search_contents(self, **kw):
"""
Searches products according to the category selected on front,
:param kw: dict contains the category and search key
:return: Dict with params as name, res_id, value
"""
strings = '%' + kw.get('name') + '%'
category = int(kw.get('category')) if not kw.get('category') == 'all' else ''
try:
domain = [('public_categ_ids', 'child_of', [category])] if category else []
product_as_category = request.env['product.template'].search(domain)
sql = """select id as res_id, name as name, name as value from product_template where name ILIKE %s"""
extra_query = ''
if product_as_category:
extra_query = " and id in %s"
limit = " limit 15"
request.cr.execute(sql+extra_query+limit,\
(tuple([strings]), tuple(product_as_category and product_as_category.ids)))
name = request.cr.dictfetchall()
except:
name = {'name': 'None', 'value': 'None'}
return json.dumps(name)

BIN
website_sale_advanced_search/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

BIN
website_sale_advanced_search/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
website_sale_advanced_search/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

109
website_sale_advanced_search/static/description/index.html

@ -0,0 +1,109 @@
<html>
<head>
<style>
.carousel-indicators .active {
background-color: #ff0f42 !important;
}
</style>
</head>
<section class="oe_container oe_dark">
<h2 class="oe_slogan" style="margin-top:20px;" >E-commerce Search Advanced</h2>
</section>
<div class="oe_container">
<div class="row">
<div class="col-md-12">
<div class="carousel slide" id="carousel-71641">
<ol class="carousel-indicators">
<li data-slide-to="0" data-target="#carousel-71641" style="border: 1px solid #ff1313 !important;">
</li>
<li data-slide-to="1" data-target="#carousel-71641" class="active" style="border: 1px solid #ff1313 !important;">
</li>
<li data-slide-to="2" data-target="#carousel-71641" style="border: 1px solid #ff1313 !important;">
</li>
<li data-slide-to="3" data-target="#carousel-71641" style="border: 1px solid #ff1313 !important;">
</li>
</ol>
<div class="carousel-inner">
<div class="item">
<img alt="Carousel Bootstrap First" src="/website_sale_advanced_search/static/images/categories.png">
<div class="carousel-caption">
<h4 style="color:red">
Product Categories On Search
</h4>
<p style="color:red">
Lists all categories as a dropdown
</p>
</div>
</div>
<div class="item active">
<img alt="Carousel Bootstrap Second" src="/website_sale_advanced_search/static/images/search_occurance.png">
<div class="carousel-caption">
<h4 style="color:red">
Listing of results while searching by category
</h4>
<p style="color:red">
Enabled auto complete on e-commerce search, fetches all related products according to the name and selected categories.
</p>
</div>
</div>
<div class="item">
<img alt="Carousel Bootstrap Third" src="/website_sale_advanced_search/static/images/screen2.png">
<div class="carousel-caption">
<h4 style="color:red">
Listing of results for category 'All'
</h4>
<p style="color:red">
Enabled auto complete on e-commerce search, fetches all related products according to the name and selected categories.
</p>
</div>
</div>
<div class="item">
<img alt="Carousel Bootstrap Fourth" src="/website_sale_advanced_search/static/images/screen3.png">
<div class="carousel-caption">
<h4 style="color:red">
Product page preview.
</h4>
<p style="color:red">
Preview after clicking on the occurences.
</p>
</div>
</div>
</div> <a style="padding-top: 250px;color: red;" class="left carousel-control" href="#carousel-71641" data-slide="prev"><span class="fa fa-chevron-left" aria-hidden="true"></span></a> <a style="padding-top: 250px;color: red;" class="right carousel-control" href="#carousel-71641" data-slide="next"><span class="fa fa-chevron-right" aria-hidden="true"></span></a>
</div>
</div>
</div>
</div>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">E-commerce Advanced Search</h2>
<h3 class="oe_slogan">Gives search results as dropdown while typing on search bar.</h3>
<div>
<h4><p>Features:</p></h4>
<ul>
<li>E-commerce product search</li>
<li>Can Select Category</li>
<li>New dropdown with product website categories</li>
<li>Find all products related to searching content according to category selected</li>
<li>Display results as dropdown</li>
<li>Selection of results redirects to product description page</li>
</ul>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2>
<div class="oe_slogan" style="margin-top:10px !important;">
<a class="btn btn-primary btn-lg mt8"
style="color: #FFFFFF !important;border-radius: 0;" href="http://www.cybrosys.com"><i
class="fa fa-envelope"></i> Email </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="http://www.cybrosys.com/contact/"><i
class="fa fa-phone"></i> Contact Us </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="http://www.cybrosys.com/odoo-customization-and-installation/"><i
class="fa fa-check-square"></i> Request Customization </a>
</div>
<img src="/website_college/static/description/images/cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block">
</section>
</html>

BIN
website_sale_advanced_search/static/images/categories.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 KiB

BIN
website_sale_advanced_search/static/images/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
website_sale_advanced_search/static/images/screen2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

BIN
website_sale_advanced_search/static/images/screen3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

BIN
website_sale_advanced_search/static/images/search_occurance.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

45
website_sale_advanced_search/static/js/product_search.js

@ -0,0 +1,45 @@
odoo.define('website_sale_advanced_search.product_search', function (require) {
"use strict";
var ajax = require('web.ajax');
var core = require('web.core');
var session = require('web.session');
var base = require('web_editor.base');
var _t = core._t;
base.url_translations = '/website/translations';
var _t = core._t;
$(function() {
$('.search-panel .dropdown-menu').find('a').click(function(e) {
e.preventDefault();
var param = $(this).attr("href").replace("#","");
var concept = $(this).text();
$('.search-panel span#search_concept').text(concept);
$('.input-group #search_param').val(param);
});
$(".oe_search_box").autocomplete({
source: function(request, response) {
$.ajax({
url: "/shop/search",
method: "POST",
dataType: "json",
data: { name: request.term, category: $('.input-group #search_param').val()},
success: function( data ) {
response( $.map( data, function( item ) {
return {
label: item.name,
value: item.name,
id: item.res_id,
}
}));
},
error: function (error) {
alert('error: ' + error);
}
});
},
select:function(suggestion,term,item){
window.location.href= "/shop/product/"+term.item.id
},
minLength: 1
});
});
});

9
website_sale_advanced_search/views/assets.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Layout and common templates -->
<template id="website_sale_advanced_search.assets_frontend" inherit_id="website.assets_frontend" name="Product Search">
<xpath expr="." position="inside">
<script type="text/javascript" src="/website_sale_advanced_search/static/js/product_search.js"></script>
</xpath>
</template>
</odoo>

32
website_sale_advanced_search/views/template.xml

@ -0,0 +1,32 @@
<odoo>
<template id="website_advanced_search" name="Ecommerce Advanced Search">
<div class="input-group">
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Filter by</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<t t-foreach="categories" t-as="c_ids">
<li><a t-att-href="'#'+str(c_ids.id)"><span t-esc="c_ids.name"/></a></li>
</t>
<li class="divider"></li>
<li><a href="#all">All</a></li>
</ul>
</div>
<input type="hidden" name="search_param" value="all" id="search_param"/>
<div class="oe_search">
<input type="text" name="search" class="search-query form-control oe_search_box" placeholder="Search..." t-att-value="search" />
<span class="fa fa-remove fa-lg oe_search_clear"></span>
</div>
<span class="input-group-btn">
<button type="submit" class="btn btn-default oe_search_button"><i class="fa fa-search"/></button>
</span>
</div>
</template>
<template id="website_sale_custom_search" inherit_id="website_sale.search">
<xpath position="replace" expr="//t[@t-call='website.website_search_box']">
<t t-call="website_sale_advanced_search.website_advanced_search"/>
</xpath>
</template>
</odoo>
Loading…
Cancel
Save