Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions website_supplier_list/README.rst
Original file line number Diff line number Diff line change
@@ -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
<https://github.com/OCA/website/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 <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Michael Viriyananda <viriyananda.michael@gmail.com>

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.
6 changes: 6 additions & 0 deletions website_supplier_list/__init__.py
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions website_supplier_list/__openerp__.py
Original file line number Diff line number Diff line change
@@ -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,
}
5 changes: 5 additions & 0 deletions website_supplier_list/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -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
109 changes: 109 additions & 0 deletions website_supplier_list/controllers/main.py
Original file line number Diff line number Diff line change
@@ -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/<int:page>',
'/suppliers/country/<model("res.country"):countries>',
'/suppliers/country/<model("res.country"):countries>/page/<int: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/<int:partner_id>'],
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)
76 changes: 76 additions & 0 deletions website_supplier_list/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_supplier_list
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <transbot@odoo-community.org>, 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 ""
76 changes: 76 additions & 0 deletions website_supplier_list/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_supplier_list
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <transbot@odoo-community.org>, 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 ""
Loading