forked from OCA/website
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OCA#41 from JayVora-SerpentCS/8.0
ShopByBrand Feature in Odoo!
- Loading branch information
Showing
11 changed files
with
368 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:alt: License: AGPL-3 | ||
|
||
========================== | ||
Website Sale Product Brand | ||
========================== | ||
|
||
Description | ||
=========== | ||
|
||
This module was written to extend the functionality of product filtering on website. | ||
It will allow you to filter product based on its brand. | ||
|
||
This Module depends on product_brand module : | ||
->https://github.com/OCA/product-attribute/tree/8.0/product_brand | ||
|
||
While shopping online, we have seen various eShops having a feature to shop by brands | ||
which ODOO does not yet provide officially.Website Sale Product Brand fills the gap at certain | ||
extent and by providing basic search by brands, thus reducing end-user’s efforts in | ||
searching the products he/she wants to purchase. | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
- Create Product brand, to create product brand | ||
go to: | ||
sales>products>product brands | ||
- Select Product brand in product. | ||
|
||
Based on this configuration, you will see the menuitem shop by brand under shop menu. | ||
It will show all the brands and once you select that brand it will show product's which | ||
is related to this brand. | ||
|
||
For further information, please visit: | ||
|
||
https://www.odoo.com/forum/help-1 | ||
The blog here explains the HOWTO : | ||
http://www.serpentcs.com/serpentcs-odoo-ecommerce-shop-brands-contribution | ||
The Youtube Video is here : | ||
https://www.youtube.com/watch?feature=player_embedded&v=LkV5umivylw | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Jay Vora <jay.vora@serpentcs.com> | ||
* Meet Dholakia <m.dholakia.serpentcs@gmail.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: http://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: http://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Copyright (C) 2012-Today Serpent Consulting Services Pvt. Ltd. | ||
# (<http://www.serpentcs.com>) | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/> | ||
# | ||
############################################################################## | ||
|
||
from . import controllers | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Copyright (C) 2012-Today Serpent Consulting Services Pvt. Ltd. | ||
# (<http://www.serpentcs.com>) | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/> | ||
# | ||
############################################################################## | ||
|
||
{ | ||
'name': 'Product Brand Filtering in Website', | ||
'category': 'e-commerce', | ||
'author': "Serpent Consulting Services Pvt. Ltd," | ||
"Odoo Community Association (OCA)", | ||
'website': 'http://www.serpentcs.com', | ||
'version': '8.0.1.0.0', | ||
'depends': [ | ||
'product_brand', | ||
'website_sale' | ||
], | ||
'data': [ | ||
"security/ir.model.access.csv", | ||
"views/product_brand.xml", | ||
], | ||
'installable': True, | ||
'auto_install': False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Copyright (C) 2012-Today Serpent Consulting Services Pvt. Ltd. | ||
# (<http://www.serpentcs.com>) | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/> | ||
# | ||
############################################################################## | ||
|
||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Copyright (C) 2012-Today Serpent Consulting Services Pvt. Ltd. | ||
# (<http://www.serpentcs.com>) | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/> | ||
# | ||
############################################################################## | ||
|
||
import openerp | ||
from openerp import http | ||
from openerp.http import request | ||
from openerp import SUPERUSER_ID | ||
from openerp.addons.website_sale.controllers.main import QueryURL | ||
from openerp.addons.website_sale.controllers.main import website_sale | ||
|
||
|
||
class WebsiteSale(website_sale): | ||
|
||
@http.route(['/shop', | ||
'/shop/page/<int:page>', | ||
'/shop/category/<model("product.public.category"):category>', | ||
"""/shop/category/<model("product.public.category"):category> | ||
/page/<int:page>""", | ||
'/shop/brands'], | ||
type='http', | ||
auth='public', | ||
website=True) | ||
def shop(self, page=0, category=None, brand=None, search='', **post): | ||
if brand: | ||
request.context.setdefault('brand_id', int(brand)) | ||
result = super(WebsiteSale, self).shop(page=page, category=category, | ||
brand=brand, search=search, | ||
**post) | ||
result.qcontext['brand'] = brand | ||
return result | ||
|
||
# Method to get the brands. | ||
@http.route( | ||
['/page/product_brands'], | ||
type='http', | ||
auth='public', | ||
website=True) | ||
def product_brands(self, **post): | ||
cr, context, pool = (request.cr, | ||
request.context, | ||
request.registry) | ||
b_obj = pool['product.brand'] | ||
domain = [] | ||
if post.get('search'): | ||
domain += [('name', 'ilike', post.get('search'))] | ||
brand_ids = b_obj.search(cr, SUPERUSER_ID, domain) | ||
brand_rec = b_obj.browse(cr, SUPERUSER_ID, brand_ids, context=context) | ||
|
||
keep = QueryURL('/page/product_brands', brand_id=[]) | ||
values = {'brand_rec': brand_rec, | ||
'keep': keep} | ||
if post.get('search'): | ||
values.update({'search': post.get('search')}) | ||
return request.website.render( | ||
'website_sale_product_brand.product_brands', | ||
values) | ||
|
||
openerp.addons.website_sale.controllers.main.website_sale = WebsiteSale |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Copyright (C) 2012-Today Serpent Consulting Services Pvt. Ltd. | ||
# (<http://www.serpentcs.com>) | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/> | ||
# | ||
############################################################################## | ||
|
||
from . import website |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Copyright (C) 2012-Today Serpent Consulting Services Pvt. Ltd. | ||
# (<http://www.serpentcs.com>) | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/> | ||
# | ||
############################################################################## | ||
|
||
from openerp.osv import orm | ||
from openerp.http import request | ||
|
||
|
||
class WebSite(orm.Model): | ||
_inherit = 'website' | ||
|
||
def sale_product_domain(self, cr, uid, ids, context=None): | ||
domain = super(WebSite, self).sale_product_domain(cr, uid, ids=ids, | ||
context=context) | ||
if 'brand_id' in request.env.context: | ||
domain.append( | ||
('product_brand_id', '=', request.env.context['brand_id'])) | ||
return domain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_product_brand_public,public.product.brand,product_brand.model_product_brand,base.group_public,1,0,0,0 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<!-- Page template for displaying Brands --> | ||
<template id="product_brands" name="Brands"> | ||
<t t-call="website.layout"> | ||
<t t-set="additional_title">Product Brands</t> | ||
<div id="wrap" t-attf-class="wrapper"> | ||
<div class="container"> | ||
<div class="row"> | ||
<form action="/shop/brands" class="form-horizontal mt32 col-md-8" method="post" > | ||
<div class="input-group" style="margin-left:60%;"> | ||
<div class='col-md-6'> | ||
<input type="text" name="search" class="form-control" placeholder="Search..." t-att-value='search'/> | ||
</div> | ||
<div class='col-md-2'> | ||
<button class="btn btn-primary">Search</button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
<br/> | ||
<section> | ||
<t t-if='brand_rec'> | ||
<t t-foreach="brand_rec" t-as="o"> | ||
<div class="col-md-3" style="display: inline-block;"> | ||
<a t-att-href="keep('/shop/brands',brand = o.id)"> | ||
<div class='row' style='margin-left:15%;'> | ||
<img itemprop="image" width="200px" height="200px" class="img" t-attf-src="/website/image/product.brand/#{o.id}/logo#{'?max_width=300&max_height=300'}"/> | ||
</div> | ||
<div class='row' style='text-align:center;'> | ||
<t t-esc='o.name' /> | ||
</div> | ||
</a> | ||
</div> | ||
</t> | ||
</t> | ||
<t t-if='not brand_rec'> | ||
<div class="text-center text-muted"> | ||
<h3 class="css_editable_display">No Brands Found.</h3> | ||
</div> | ||
</t> | ||
</section> | ||
</div> | ||
</div> | ||
</t> | ||
</template> | ||
|
||
<template id="website_sale.categories_recursive" name="Category list"> | ||
<li t-att-class="'active' if c.id == int(category or 0) else ''"> | ||
<a t-att-href="keep('/shop/category/' + slug(c), category=0, brand=brand)" t-field="c.name"/> | ||
<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> | ||
|
||
<!-- Menu in website for Brand --> | ||
<record id="menu_website_sale_shop" model="website.menu"> | ||
<field name="name">Shop All</field> | ||
<field name="url">/shop</field> | ||
<field name="parent_id" ref="website_sale.menu_shop" /> | ||
</record> | ||
|
||
<record id="menu_website_sale_brand" model="website.menu"> | ||
<field name="name">Shop by Brand</field> | ||
<field name="url">/page/product_brands</field> | ||
<field name="parent_id" ref="website_sale.menu_shop" /> | ||
</record> | ||
|
||
</data> | ||
</openerp> |