diff --git a/website_supplier_list/README.rst b/website_supplier_list/README.rst new file mode 100644 index 0000000000..073119b9a7 --- /dev/null +++ b/website_supplier_list/README.rst @@ -0,0 +1,73 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +===================== +Website Supplier List +===================== + +This module was written to extend the functionality of the website +to allow users to publish his suppliers on a new page. + +Installation +============ + +To install this module, you need to: + +1. Clone the branch 9.0 of the repository https://github.com/OCA/website +2. Add the path to this repository in your configuration (addons-path) +3. Update the module list +4. Go to menu *Setting -> Modules -> Local Modules* +5. Search For *Website Supplier List* +6. Install the module + +Usage +===== + +To use this module, you need to: + +1. Go to menu *Invoicing -> Suppliers -> Suppliers* +2. Edit or create one. +3. Within the *Sales & Purchases* tab, there will be a new field named *Publish Supplier On The Website* + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/186/9.0 + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Michael Viriyananda + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://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 https://odoo-community.org. diff --git a/website_supplier_list/__init__.py b/website_supplier_list/__init__.py new file mode 100644 index 0000000000..1dbea48d4d --- /dev/null +++ b/website_supplier_list/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models +from . import controllers diff --git a/website_supplier_list/__openerp__.py b/website_supplier_list/__openerp__.py new file mode 100644 index 0000000000..439d655fdb --- /dev/null +++ b/website_supplier_list/__openerp__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# © 2016 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'Website Supplier List', + 'version': '9.0.1.0.0', + 'summary': 'Publish Your Suppliers References', + 'author': 'OpenSynergy Indonesia,Odoo Community Association (OCA)', + 'website': 'https://github.com/mikevhe18', + 'category': 'Website', + 'depends': [ + 'crm_partner_assign', + 'purchase', + 'website_partner' + ], + 'data': [ + 'security/website_supplier_list.xml', + 'views/assets.xml', + 'views/website_supplier.xml', + 'views/res_partner_view.xml' + ], + 'installable': True, +} diff --git a/website_supplier_list/controllers/__init__.py b/website_supplier_list/controllers/__init__.py new file mode 100644 index 0000000000..a709fb9f99 --- /dev/null +++ b/website_supplier_list/controllers/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import main diff --git a/website_supplier_list/controllers/main.py b/website_supplier_list/controllers/main.py new file mode 100644 index 0000000000..575ed5e65a --- /dev/null +++ b/website_supplier_list/controllers/main.py @@ -0,0 +1,109 @@ +# -*- coding: utf-8 -*- +# © 2016 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp.addons.web import http +from openerp.tools.translate import _ +from openerp.addons.web.http import request +import werkzeug.urls + + +class WebsiteSupplier(http.Controller): + _references_per_page = 20 + + def _get_country_ids(self, country_id, country_ids): + country_obj = request.env['res.country'] + + if not any( + x['country_id'][0] == country_id + for x in country_ids if x['country_id']): + country = country_obj.read( + country_id, ['name']) + if country: + country_ids.append({ + 'country_id_count': 0, + 'country_id': (country_id, country['name']) + }) + country_ids.sort( + key=lambda d: d['country_id'] and d['country_id'][1]) + + return country_ids + + @http.route([ + '/suppliers', + '/suppliers/page/', + '/suppliers/country/', + '/suppliers/country//page/', + ], type='http', auth="public", website=True) + def suppliers(self, countries=None, page=0, **post): + partner_obj = request.env['res.partner'] + partner_name = post.get('search', '') + url = '/suppliers' + country_ids = [] + country_id = False + + domain = [ + ('website_supplier_published', '=', True), + ('supplier', '=', True) + ] + if partner_name: + domain += [ + '|', + ('name', 'ilike', post.get("search")), + ('website_description', 'ilike', post.get("search")) + ] + + country_ids = partner_obj.read_group( + domain, ["id", "country_id"], + groupby="country_id", orderby="country_id") + country_count = partner_obj.search_count(domain) + + if countries: + country_id = countries.id + if country_id: + country_ids = self._get_country_ids(country_id, country_ids) + url += '/country/%s' % (country_id) + domain += [('country_id', '=', country_id)] + + country_ids.insert(0, { + 'country_id_count': country_count, + 'country_id': (0, _("All Countries")) + }) + + partner_count = partner_obj.search_count(domain) + + pager = request.website.pager( + url=url, total=partner_count, page=page, + step=self._references_per_page, + scope=7, url_args=post + ) + + partner_ids = partner_obj.search( + domain, offset=pager['offset'], + limit=self._references_per_page) + + values = { + 'countries': country_ids, + 'current_country_id': country_id or 0, + 'partners': partner_ids, + 'pager': pager, + 'post': post, + 'search_path': "?%s" % werkzeug.url_encode(post), + } + return request.website.render("website_supplier_list.index", values) + + @http.route( + ['/suppliers/'], + type='http', + auth="public", + website=True) + def partners_detail(self, partner_id, **post): + obj_partner = request.env['res.partner'] + if partner_id: + partner = obj_partner.browse(partner_id) + if partner.exists() and partner.website_published: + values = {} + values['main_object'] = values['partner'] = partner + return request.website.render( + "website_supplier_list.details", values) + return self.suppliers(**post) diff --git a/website_supplier_list/i18n/es.po b/website_supplier_list/i18n/es.po new file mode 100644 index 0000000000..b61b86b60f --- /dev/null +++ b/website_supplier_list/i18n/es.po @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_supplier_list +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-09-16 20:38+0000\n" +"PO-Revision-Date: 2016-09-16 20:38+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: website_supplier_list +#: code:addons/website_supplier_list/controllers/main.py:70 +#, python-format +msgid "All Countries" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.implemented_by_block +msgid "Implemented By" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "No result found" +msgstr "" + +#. module: website_supplier_list +#: view:website:website.layout view:website:website_supplier_list.details +#: view:website:website_supplier_list.index +msgid "Our Suppliers" +msgstr "" + +#. module: website_supplier_list +#: model:ir.model,name:website_supplier_list.model_res_partner +msgid "Partner" +msgstr "" + +#. module: website_supplier_list +#: field:res.partner,website_supplier_published:0 +msgid "Publish Supplier On The Website" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.references_block +msgid "References" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "References by Country" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "Search" +msgstr "Buscar" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "Trusted by millions worldwide" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.implemented_by_block +msgid "reference(s))" +msgstr "" diff --git a/website_supplier_list/i18n/fr.po b/website_supplier_list/i18n/fr.po new file mode 100644 index 0000000000..71a7a66f3d --- /dev/null +++ b/website_supplier_list/i18n/fr.po @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_supplier_list +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-09-16 20:38+0000\n" +"PO-Revision-Date: 2016-09-16 20:38+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: website_supplier_list +#: code:addons/website_supplier_list/controllers/main.py:70 +#, python-format +msgid "All Countries" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.implemented_by_block +msgid "Implemented By" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "No result found" +msgstr "" + +#. module: website_supplier_list +#: view:website:website.layout view:website:website_supplier_list.details +#: view:website:website_supplier_list.index +msgid "Our Suppliers" +msgstr "" + +#. module: website_supplier_list +#: model:ir.model,name:website_supplier_list.model_res_partner +msgid "Partner" +msgstr "Partenaire" + +#. module: website_supplier_list +#: field:res.partner,website_supplier_published:0 +msgid "Publish Supplier On The Website" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.references_block +msgid "References" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "References by Country" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "Search" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "Trusted by millions worldwide" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.implemented_by_block +msgid "reference(s))" +msgstr "" diff --git a/website_supplier_list/i18n/nl.po b/website_supplier_list/i18n/nl.po new file mode 100644 index 0000000000..2d8ad75503 --- /dev/null +++ b/website_supplier_list/i18n/nl.po @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_supplier_list +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-09-16 20:38+0000\n" +"PO-Revision-Date: 2016-09-16 20:38+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: nl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: website_supplier_list +#: code:addons/website_supplier_list/controllers/main.py:70 +#, python-format +msgid "All Countries" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.implemented_by_block +msgid "Implemented By" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "No result found" +msgstr "" + +#. module: website_supplier_list +#: view:website:website.layout view:website:website_supplier_list.details +#: view:website:website_supplier_list.index +msgid "Our Suppliers" +msgstr "" + +#. module: website_supplier_list +#: model:ir.model,name:website_supplier_list.model_res_partner +msgid "Partner" +msgstr "Relatie" + +#. module: website_supplier_list +#: field:res.partner,website_supplier_published:0 +msgid "Publish Supplier On The Website" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.references_block +msgid "References" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "References by Country" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "Search" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "Trusted by millions worldwide" +msgstr "" + +#. module: website_supplier_list +#: view:website:website_supplier_list.implemented_by_block +msgid "reference(s))" +msgstr "" diff --git a/website_supplier_list/i18n/sl.po b/website_supplier_list/i18n/sl.po new file mode 100644 index 0000000000..441202b915 --- /dev/null +++ b/website_supplier_list/i18n/sl.po @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_supplier_list +# +# Translators: +# Matjaž Mozetič , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-06-23 03:09+0000\n" +"PO-Revision-Date: 2016-06-23 03:09+0000\n" +"Last-Translator: Matjaž Mozetič , 2016\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#. module: website_supplier_list +#: code:addons/website_supplier_list/controllers/main.py:70 +#, python-format +msgid "All Countries" +msgstr "Vse države" + +#. module: website_supplier_list +#: view:website:website_supplier_list.implemented_by_block +msgid "Implemented By" +msgstr "Implementiral" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "No result found" +msgstr "Brez rezultatov" + +#. module: website_supplier_list +#: view:website:website.layout view:website:website_supplier_list.details +#: view:website:website_supplier_list.index +msgid "Our Suppliers" +msgstr "Naši dobavitelji" + +#. module: website_supplier_list +#: model:ir.model,name:website_supplier_list.model_res_partner +msgid "Partner" +msgstr "Partner" + +#. module: website_supplier_list +#: field:res.partner,website_supplier_published:0 +msgid "Publish Supplier On The Website" +msgstr "Objavi dobavitelja na spletni strani" + +#. module: website_supplier_list +#: view:website:website_supplier_list.references_block +msgid "References" +msgstr "Sklici" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "References by Country" +msgstr "Sklici po državi" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "Search" +msgstr "Iskanje" + +#. module: website_supplier_list +#: view:website:website_supplier_list.index +msgid "Trusted by millions worldwide" +msgstr "Zaupajo nam miljoni po vsem svetu." + +#. module: website_supplier_list +#: view:website:website_supplier_list.implemented_by_block +msgid "reference(s))" +msgstr "sklic(i))" diff --git a/website_supplier_list/models/__init__.py b/website_supplier_list/models/__init__.py new file mode 100644 index 0000000000..b18a461bc2 --- /dev/null +++ b/website_supplier_list/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import res_partner diff --git a/website_supplier_list/models/res_partner.py b/website_supplier_list/models/res_partner.py new file mode 100644 index 0000000000..4c34ed8cf5 --- /dev/null +++ b/website_supplier_list/models/res_partner.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# © 2016 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import fields, models + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + website_supplier_published = fields.Boolean( + string='Publish Supplier On The Website', + copy=False, + default=True) diff --git a/website_supplier_list/security/website_supplier_list.xml b/website_supplier_list/security/website_supplier_list.xml new file mode 100644 index 0000000000..2320ee2527 --- /dev/null +++ b/website_supplier_list/security/website_supplier_list.xml @@ -0,0 +1,13 @@ + + + + Website Supplier List: Public + + [('website_supplier_published', '=', True)] + + + + + + + diff --git a/website_supplier_list/static/description/icon.png b/website_supplier_list/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/website_supplier_list/static/description/icon.png differ diff --git a/website_supplier_list/static/src/css/website_supplier_list.css b/website_supplier_list/static/src/css/website_supplier_list.css new file mode 100644 index 0000000000..a66b016e31 --- /dev/null +++ b/website_supplier_list/static/src/css/website_supplier_list.css @@ -0,0 +1,15 @@ +.oe_supplier_google_maps { + width:260px; + height:240px; + border:0; + padding:0; + margin:0; +} + +.oe_google_maps { + width:898px; + height:485px; + border:0; + padding:0; + margin:0; +} \ No newline at end of file diff --git a/website_supplier_list/views/assets.xml b/website_supplier_list/views/assets.xml new file mode 100644 index 0000000000..e055ecb284 --- /dev/null +++ b/website_supplier_list/views/assets.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/website_supplier_list/views/res_partner_view.xml b/website_supplier_list/views/res_partner_view.xml new file mode 100644 index 0000000000..4d0932e963 --- /dev/null +++ b/website_supplier_list/views/res_partner_view.xml @@ -0,0 +1,14 @@ + + + + Website Supplier + res.partner + + + + + + + + \ No newline at end of file diff --git a/website_supplier_list/views/website_supplier.xml b/website_supplier_list/views/website_supplier.xml new file mode 100644 index 0000000000..a12b4f3023 --- /dev/null +++ b/website_supplier_list/views/website_supplier.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + +