Skip to content

Instantly share code, notes, and snippets.

@eLBati
Created April 23, 2016 09:37
Show Gist options
  • Save eLBati/827d7a11502024e9c34957ed17d07f09 to your computer and use it in GitHub Desktop.
Save eLBati/827d7a11502024e9c34957ed17d07f09 to your computer and use it in GitHub Desktop.
diff --git a/website_logo/README.rst b/website_logo/README.rst
index 10b3637..5168aca 100644
--- a/website_logo/README.rst
+++ b/website_logo/README.rst
@@ -1,11 +1,13 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
- :alt: License: AGPL-3
+ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
+ :alt: License: AGPL-3
-Website logo
+============
+Website Logo
============
-Load a logo image to be used on website only. This allows to use an internal
-company logo (for reports) and a different website logo.
+Load a logo image to be used on website only. This allows to use an
+internal company logo (for reports) and a different website logo.
Configuration
@@ -13,26 +15,38 @@ Configuration
To configure this module, you need to:
-* Go to 'Settings' > 'Configuration' > 'Website Settings'
-* Load a logo image in the logo field
+* Go to your company and load a logo image in the website logo field
+
+Note that, in case of anonymous visitors, the company associated to
+admin user will be used
+
+Known issues / Roadmap
+======================
-Use
-===
-This addon supports multi-website. If no logo defined, then a transparent image
-is shown, allowing to not show logo in one website, even "Show logo" option
-is actived
+Bug Tracker
+===========
+Bugs are tracked on `GitHub Issues
+<https://github.com/OCA/{project_repo}/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
------------
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
-* Antonio Espinosa <antonioea@antiun.com>
+* Dave Lasley <dave@laslabs.com>
Maintainer
----------
diff --git a/website_logo/__init__.py b/website_logo/__init__.py
index 57bdf91..899a9bb 100644
--- a/website_logo/__init__.py
+++ b/website_logo/__init__.py
@@ -1,22 +1,7 @@
# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (C) 2015 Agile Business Group sagl (<http://www.agilebg.com>)
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero 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 Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
+# © 2015 Agile Business Group sagl
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from . import controllers
+from . import tests
diff --git a/website_logo/__openerp__.py b/website_logo/__openerp__.py
index c44bfb0..bb03767 100644
--- a/website_logo/__openerp__.py
+++ b/website_logo/__openerp__.py
@@ -1,43 +1,22 @@
# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (C) 2015 Agile Business Group sagl (<http://www.agilebg.com>)
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero 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 Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
+# © 2015 Agile Business Group sagl
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Website logo',
- 'summary': 'Website company logo',
- 'version': '8.0.2.0.0',
+ 'summary': 'Website Company Logo',
+ 'version': '9.0.1.0.0',
'category': 'Website',
- 'author': "Agile Business Group, "
- "Antiun Ingeniería S.L., "
- "Odoo Community Association (OCA)",
+ 'author': "Agile Business Group, Odoo Community Association (OCA)",
'website': 'http://www.agilebg.com',
'license': 'AGPL-3',
'depends': [
'website',
],
'data': [
- 'views/res_config_view.xml',
- 'views/website_view.xml',
+ 'views/company_view.xml',
'views/website_templates.xml',
],
- 'qweb': [
- ],
'installable': True,
'auto_install': False,
}
diff --git a/website_logo/controllers/__init__.py b/website_logo/controllers/__init__.py
index 45e4b89..d97a038 100644
--- a/website_logo/controllers/__init__.py
+++ b/website_logo/controllers/__init__.py
@@ -1,21 +1,5 @@
# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (C) 2015 Agile Business Group sagl (<http://www.agilebg.com>)
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero 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 Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
+# © 2015 Agile Business Group sagl
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import main
diff --git a/website_logo/controllers/main.py b/website_logo/controllers/main.py
index 40f8ab3..0ef5176 100644
--- a/website_logo/controllers/main.py
+++ b/website_logo/controllers/main.py
@@ -1,62 +1,25 @@
# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (C) 2015 Agile Business Group sagl (<http://www.agilebg.com>)
-# Copyright (C) 2015 Antiun Ingenieria S.L. - Antonio Espinosa
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero 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 Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
+# © 2015 Agile Business Group sagl
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-import functools
-from cStringIO import StringIO
-
-import openerp
+from openerp.addons.web.controllers.main import Binary
from openerp.addons.web import http
from openerp.addons.web.http import request
+import openerp
from openerp.modules import get_module_resource
+import functools
+from cStringIO import StringIO
db_monodb = http.db_monodb
-class Website(http.Controller):
-
- def _image_logo_get(self, cr, domain=None):
- if domain:
- cr.execute("""SELECT logo, write_date
- FROM website
- WHERE name = %s
- """, (domain,))
- else:
- cr.execute("""SELECT logo, write_date
- FROM website
- """)
- row = cr.fetchone()
- if row and row[0]:
- return StringIO(str(row[0]).decode('base64')), row[1]
- return False, False
+class WebsiteLogo(Binary):
@http.route([
- '/web/binary/website_logo',
- '/website_logo',
'/website_logo.png',
], type='http', auth="none", cors="*")
def website_logo(self, dbname=None, **kw):
- imgname = 'website_nologo.png'
- placeholder = functools.partial(
- get_module_resource,
- 'website_logo', 'static', 'src', 'img')
+ imgname = 'logo.png'
uid = None
if request.session.db:
dbname = request.session.db
@@ -66,19 +29,24 @@ class Website(http.Controller):
if not uid:
uid = openerp.SUPERUSER_ID
if uid and dbname:
+ placeholder = functools.partial(
+ get_module_resource, 'web', 'static', 'src', 'img')
try:
# create an empty registry
registry = openerp.modules.registry.Registry(dbname)
- env = request.httprequest.environ
- domain = env.get('HTTP_HOST', '').split(':')[0]
with registry.cursor() as cr:
- image, mtime = self._image_logo_get(cr, domain)
- if not image:
- image, mtime = self._image_logo_get(cr, 'localhost')
- if image:
+ cr.execute("""SELECT c.website_logo, c.write_date
+ FROM res_users u
+ LEFT JOIN res_company c
+ ON c.id = u.company_id
+ WHERE u.id = %s
+ """, (uid,))
+ row = cr.fetchone()
+ if row and row[0]:
+ image_data = StringIO(str(row[0]).decode('base64'))
response = http.send_file(
- image, filename=imgname, mtime=mtime)
+ image_data, filename=imgname, mtime=row[1])
return response
except Exception:
return http.send_file(placeholder(imgname))
- return http.send_file(placeholder(imgname))
+ return self.company_logo(dbname=dbname, **kw)
diff --git a/website_logo/i18n/ca.po b/website_logo/i18n/ca.po
deleted file mode 100644
index b9f36e2..0000000
--- a/website_logo/i18n/ca.po
+++ /dev/null
@@ -1,52 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * website_logo
-#
-# Translators:
-# Carles Antolí <carlesantoli@hotmail.com>, 2015
-msgid ""
-msgstr ""
-"Project-Id-Version: website (8.0)\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-12-08 09:02+0000\n"
-"PO-Revision-Date: 2015-12-06 09:55+0000\n"
-"Last-Translator: Carles Antolí <carlesantoli@hotmail.com>\n"
-"Language-Team: Catalan (http://www.transifex.com/oca/OCA-website-8-0/language/ca/)\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Language: ca\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
-#. module: website_logo
-#: view:website:website.layout
-msgid "/website_logo.png"
-msgstr "/website_logo.png"
-
-#. module: website_logo
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Domain"
-msgstr "Domini"
-
-#. module: website_logo
-#: view:website:website_logo.view_website_form
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Logo"
-msgstr "Logo"
-
-#. module: website_logo
-#: help:website,logo:0
-msgid ""
-"This field holds the logo for this website, showed in header. Recommended "
-"size is 180x50"
-msgstr "Aquest camp té el logotip d'aquest lloc web, es mostra a la capçalera. La mida recomanada és de 180x50"
-
-#. module: website_logo
-#: model:ir.model,name:website_logo.model_website
-msgid "Website"
-msgstr "Lloc web"
-
-#. module: website_logo
-#: field:website,logo:0
-msgid "Website logo"
-msgstr "Logo lloc web"
diff --git a/website_logo/i18n/de.po b/website_logo/i18n/de.po
deleted file mode 100644
index ecf65af..0000000
--- a/website_logo/i18n/de.po
+++ /dev/null
@@ -1,52 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * website_logo
-#
-# Translators:
-# Rudolf Schnapka <rs@techno-flex.de>, 2016
-msgid ""
-msgstr ""
-"Project-Id-Version: website (8.0)\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-02-25 14:25+0000\n"
-"PO-Revision-Date: 2016-02-23 14:04+0000\n"
-"Last-Translator: Rudolf Schnapka <rs@techno-flex.de>\n"
-"Language-Team: German (http://www.transifex.com/oca/OCA-website-8-0/language/de/)\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Language: de\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
-#. module: website_logo
-#: view:website:website.layout
-msgid "/website_logo.png"
-msgstr "/website_logo.png"
-
-#. module: website_logo
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Domain"
-msgstr "Domäne"
-
-#. module: website_logo
-#: view:website:website_logo.view_website_form
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Logo"
-msgstr "Logo"
-
-#. module: website_logo
-#: help:website,logo:0
-msgid ""
-"This field holds the logo for this website, showed in header. Recommended "
-"size is 180x50"
-msgstr "Dieses Feld enthält das Logo dieser Webseite, welches im Kopf gezeigt wird. Empfohlene Größe ist 180x50"
-
-#. module: website_logo
-#: model:ir.model,name:website_logo.model_website
-msgid "Website"
-msgstr "Webseite"
-
-#. module: website_logo
-#: field:website,logo:0
-msgid "Website logo"
-msgstr "Webseiten-Logo"
diff --git a/website_logo/i18n/el_GR.po b/website_logo/i18n/el_GR.po
deleted file mode 100644
index eb0dc29..0000000
--- a/website_logo/i18n/el_GR.po
+++ /dev/null
@@ -1,51 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * website_logo
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: website (8.0)\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-12-05 01:59+0000\n"
-"PO-Revision-Date: 2015-12-04 23:32+0000\n"
-"Last-Translator: Goutoudis Kostas <goutoudis@gmail.com>\n"
-"Language-Team: Greek (Greece) (http://www.transifex.com/oca/OCA-website-8-0/language/el_GR/)\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Language: el_GR\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
-#. module: website_logo
-#: view:website:website.layout
-msgid "/website_logo.png"
-msgstr "/website_logo.png"
-
-#. module: website_logo
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Domain"
-msgstr ""
-
-#. module: website_logo
-#: view:website:website_logo.view_website_form
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Logo"
-msgstr ""
-
-#. module: website_logo
-#: help:website,logo:0
-msgid ""
-"This field holds the logo for this website, showed in header. Recommended "
-"size is 180x50"
-msgstr ""
-
-#. module: website_logo
-#: model:ir.model,name:website_logo.model_website
-msgid "Website"
-msgstr "Ιστότοπος"
-
-#. module: website_logo
-#: field:website,logo:0
-msgid "Website logo"
-msgstr "Λογότυπο Ιστότοπου"
diff --git a/website_logo/i18n/en.po b/website_logo/i18n/en.po
deleted file mode 100644
index d9644d1..0000000
--- a/website_logo/i18n/en.po
+++ /dev/null
@@ -1,51 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * website_logo
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: website (8.0)\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-12-05 01:59+0000\n"
-"PO-Revision-Date: 2015-12-02 23:15+0000\n"
-"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
-"Language-Team: English (http://www.transifex.com/oca/OCA-website-8-0/language/en/)\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Language: en\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
-#. module: website_logo
-#: view:website:website.layout
-msgid "/website_logo.png"
-msgstr "/website_logo.png"
-
-#. module: website_logo
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Domain"
-msgstr "Domain"
-
-#. module: website_logo
-#: view:website:website_logo.view_website_form
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Logo"
-msgstr "Logo"
-
-#. module: website_logo
-#: help:website,logo:0
-msgid ""
-"This field holds the logo for this website, showed in header. Recommended "
-"size is 180x50"
-msgstr "This field holds the logo for this website, showed in header. Recommended size is 180x50"
-
-#. module: website_logo
-#: model:ir.model,name:website_logo.model_website
-msgid "Website"
-msgstr "Website"
-
-#. module: website_logo
-#: field:website,logo:0
-msgid "Website logo"
-msgstr "Website logo"
diff --git a/website_logo/i18n/es.po b/website_logo/i18n/es.po
index 42f6470..e6f1230 100644
--- a/website_logo/i18n/es.po
+++ b/website_logo/i18n/es.po
@@ -3,16 +3,13 @@
# * website_logo
#
# Translators:
-# Antonio Espinosa <antonioea@antiun.com>, 2015
-# Antonio Trueba, 2016
-# Carles Antolí <carlesantoli@hotmail.com>, 2015
msgid ""
msgstr ""
"Project-Id-Version: website (8.0)\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-01-19 11:34+0000\n"
-"PO-Revision-Date: 2016-02-05 12:21+0000\n"
-"Last-Translator: Antonio Trueba\n"
+"POT-Creation-Date: 2015-10-03 23:14+0000\n"
+"PO-Revision-Date: 2015-09-25 08:28+0000\n"
+"Last-Translator: <>\n"
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-website-8-0/language/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -23,32 +20,20 @@ msgstr ""
#. module: website_logo
#: view:website:website.layout
msgid "/website_logo.png"
-msgstr "/website_logo.png"
-
-#. module: website_logo
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Domain"
-msgstr "Dominio"
-
-#. module: website_logo
-#: view:website:website_logo.view_website_form
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Logo"
-msgstr "Logo"
+msgstr ""
#. module: website_logo
-#: help:website,logo:0
-msgid ""
-"This field holds the logo for this website, showed in header. Recommended "
-"size is 180x50"
-msgstr "Este campo define el logo para este sitio web, mostrado en la cabecera. Tamaño recomendado 180x50"
+#: model:ir.model,name:website_logo.model_res_company
+msgid "Companies"
+msgstr "Compañías"
#. module: website_logo
-#: model:ir.model,name:website_logo.model_website
-msgid "Website"
-msgstr "Sitio web"
+#: view:res.company:website_logo.view_company_form
+msgid "Configuration"
+msgstr ""
#. module: website_logo
-#: field:website,logo:0
+#: view:res.company:website_logo.view_company_form
+#: field:res.company,website_logo:0
msgid "Website logo"
-msgstr "Logo Sitio Web"
+msgstr ""
diff --git a/website_logo/i18n/fi.po b/website_logo/i18n/fi.po
deleted file mode 100644
index f60aa4e..0000000
--- a/website_logo/i18n/fi.po
+++ /dev/null
@@ -1,51 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * website_logo
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: website (8.0)\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-03-15 18:42+0000\n"
-"PO-Revision-Date: 2015-09-25 08:28+0000\n"
-"Last-Translator: <>\n"
-"Language-Team: Finnish (http://www.transifex.com/oca/OCA-website-8-0/language/fi/)\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Language: fi\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
-#. module: website_logo
-#: view:website:website.layout
-msgid "/website_logo.png"
-msgstr ""
-
-#. module: website_logo
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Domain"
-msgstr ""
-
-#. module: website_logo
-#: view:website:website_logo.view_website_form
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Logo"
-msgstr ""
-
-#. module: website_logo
-#: help:website,logo:0
-msgid ""
-"This field holds the logo for this website, showed in header. Recommended "
-"size is 180x50"
-msgstr ""
-
-#. module: website_logo
-#: model:ir.model,name:website_logo.model_website
-msgid "Website"
-msgstr "Verkkosivut"
-
-#. module: website_logo
-#: field:website,logo:0
-msgid "Website logo"
-msgstr ""
diff --git a/website_logo/i18n/fr.po b/website_logo/i18n/fr.po
deleted file mode 100644
index 3850ed6..0000000
--- a/website_logo/i18n/fr.po
+++ /dev/null
@@ -1,51 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * website_logo
-#
-# Translators:
-msgid ""
-msgstr ""
-"Project-Id-Version: website (8.0)\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-12-05 01:59+0000\n"
-"PO-Revision-Date: 2015-09-25 08:28+0000\n"
-"Last-Translator: <>\n"
-"Language-Team: French (http://www.transifex.com/oca/OCA-website-8-0/language/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_logo
-#: view:website:website.layout
-msgid "/website_logo.png"
-msgstr ""
-
-#. module: website_logo
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Domain"
-msgstr ""
-
-#. module: website_logo
-#: view:website:website_logo.view_website_form
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Logo"
-msgstr ""
-
-#. module: website_logo
-#: help:website,logo:0
-msgid ""
-"This field holds the logo for this website, showed in header. Recommended "
-"size is 180x50"
-msgstr ""
-
-#. module: website_logo
-#: model:ir.model,name:website_logo.model_website
-msgid "Website"
-msgstr "Site Internet"
-
-#. module: website_logo
-#: field:website,logo:0
-msgid "Website logo"
-msgstr ""
diff --git a/website_logo/i18n/it.po b/website_logo/i18n/it.po
deleted file mode 100644
index 7564daa..0000000
--- a/website_logo/i18n/it.po
+++ /dev/null
@@ -1,53 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * website_logo
-#
-# Translators:
-# Paolo Valier, 2016
-# Paolo Valier, 2016
-msgid ""
-msgstr ""
-"Project-Id-Version: website (8.0)\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-03-15 18:42+0000\n"
-"PO-Revision-Date: 2016-03-13 17:06+0000\n"
-"Last-Translator: Paolo Valier\n"
-"Language-Team: Italian (http://www.transifex.com/oca/OCA-website-8-0/language/it/)\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Language: it\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
-#. module: website_logo
-#: view:website:website.layout
-msgid "/website_logo.png"
-msgstr "/website_logo.png"
-
-#. module: website_logo
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Domain"
-msgstr "Dominio"
-
-#. module: website_logo
-#: view:website:website_logo.view_website_form
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Logo"
-msgstr "Logo"
-
-#. module: website_logo
-#: help:website,logo:0
-msgid ""
-"This field holds the logo for this website, showed in header. Recommended "
-"size is 180x50"
-msgstr "Questo campo contiene il logo del sito mostrato nell'intestazione. Dimensioni raccomandate: 180x50."
-
-#. module: website_logo
-#: model:ir.model,name:website_logo.model_website
-msgid "Website"
-msgstr "Sito"
-
-#. module: website_logo
-#: field:website,logo:0
-msgid "Website logo"
-msgstr "Logo del sito"
diff --git a/website_logo/i18n/pt_BR.po b/website_logo/i18n/pt_BR.po
deleted file mode 100644
index 05af775..0000000
--- a/website_logo/i18n/pt_BR.po
+++ /dev/null
@@ -1,52 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * website_logo
-#
-# Translators:
-# danimaribeiro <danimaribeiro@gmail.com>, 2016
-msgid ""
-msgstr ""
-"Project-Id-Version: website (8.0)\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-03-12 02:17+0000\n"
-"PO-Revision-Date: 2016-03-05 18:09+0000\n"
-"Last-Translator: danimaribeiro <danimaribeiro@gmail.com>\n"
-"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-website-8-0/language/pt_BR/)\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Language: pt_BR\n"
-"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-
-#. module: website_logo
-#: view:website:website.layout
-msgid "/website_logo.png"
-msgstr ""
-
-#. module: website_logo
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Domain"
-msgstr "Domínio"
-
-#. module: website_logo
-#: view:website:website_logo.view_website_form
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Logo"
-msgstr "Logo"
-
-#. module: website_logo
-#: help:website,logo:0
-msgid ""
-"This field holds the logo for this website, showed in header. Recommended "
-"size is 180x50"
-msgstr "Este campo serve para o logo do site mostrado no cabeçalho. Tamanho recomendado é 180x50"
-
-#. module: website_logo
-#: model:ir.model,name:website_logo.model_website
-msgid "Website"
-msgstr "Website"
-
-#. module: website_logo
-#: field:website,logo:0
-msgid "Website logo"
-msgstr "Logo Website"
diff --git a/website_logo/i18n/ru.po b/website_logo/i18n/ru.po
deleted file mode 100644
index a437eb2..0000000
--- a/website_logo/i18n/ru.po
+++ /dev/null
@@ -1,52 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * website_logo
-#
-# Translators:
-# Mikhail - <expromt.core@gmail.com>, 2016
-msgid ""
-msgstr ""
-"Project-Id-Version: website (8.0)\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-01-19 11:34+0000\n"
-"PO-Revision-Date: 2016-01-15 21:11+0000\n"
-"Last-Translator: Mikhail - <expromt.core@gmail.com>\n"
-"Language-Team: Russian (http://www.transifex.com/oca/OCA-website-8-0/language/ru/)\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Language: ru\n"
-"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"
-
-#. module: website_logo
-#: view:website:website.layout
-msgid "/website_logo.png"
-msgstr ""
-
-#. module: website_logo
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Domain"
-msgstr "Домен"
-
-#. module: website_logo
-#: view:website:website_logo.view_website_form
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Logo"
-msgstr "Логотип"
-
-#. module: website_logo
-#: help:website,logo:0
-msgid ""
-"This field holds the logo for this website, showed in header. Recommended "
-"size is 180x50"
-msgstr "Это поле содержит логотип сайта, показываемый в заголовке. Рекомендуемый размер 180x50"
-
-#. module: website_logo
-#: model:ir.model,name:website_logo.model_website
-msgid "Website"
-msgstr "Сайт"
-
-#. module: website_logo
-#: field:website,logo:0
-msgid "Website logo"
-msgstr "Логотип сайта "
diff --git a/website_logo/i18n/sl.po b/website_logo/i18n/sl.po
deleted file mode 100644
index c0f4782..0000000
--- a/website_logo/i18n/sl.po
+++ /dev/null
@@ -1,52 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * website_logo
-#
-# Translators:
-# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015
-msgid ""
-msgstr ""
-"Project-Id-Version: website (8.0)\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-12-05 01:59+0000\n"
-"PO-Revision-Date: 2015-12-03 05:26+0000\n"
-"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
-"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-website-8-0/language/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_logo
-#: view:website:website.layout
-msgid "/website_logo.png"
-msgstr "/website_logo.png"
-
-#. module: website_logo
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Domain"
-msgstr "Domena"
-
-#. module: website_logo
-#: view:website:website_logo.view_website_form
-#: view:website.config.settings:website_logo.view_website_config_settings
-msgid "Logo"
-msgstr "Logotip"
-
-#. module: website_logo
-#: help:website,logo:0
-msgid ""
-"This field holds the logo for this website, showed in header. Recommended "
-"size is 180x50"
-msgstr "Polje, ki vsebuje logotip prikazan v glavi spletne strani. Priporočena velikost je 180x50"
-
-#. module: website_logo
-#: model:ir.model,name:website_logo.model_website
-msgid "Website"
-msgstr "Spletna stran"
-
-#. module: website_logo
-#: field:website,logo:0
-msgid "Website logo"
-msgstr "Spletni logotip"
diff --git a/website_logo/migrations/8.0.2.0.0/post-migration.py b/website_logo/migrations/8.0.2.0.0/post-migration.py
deleted file mode 100644
index f473291..0000000
--- a/website_logo/migrations/8.0.2.0.0/post-migration.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# -*- coding: utf-8 -*-
-# License AGPL-3: Antiun Ingenieria S.L. - Antonio Espinosa
-# See README.rst file on addon root folder for more details
-
-
-def migrate(cr, version):
- # Copy res.company.website_logo_to_be_delete to
- # first website.logo to that company
- cr.execute("""
- SELECT c.id, c.website_logo_to_be_delete
- FROM res_company c
- """)
- companies = cr.fetchall()
- for company in companies:
- if not company[1]:
- continue
- cr.execute("""
- SELECT w.id, w.company_id
- FROM website w
- WHERE w.company_id = %d
- """ % company[0])
- web = cr.fetchone()
- if web:
- cr.execute("""
- UPDATE website
- SET logo = '%s'
- WHERE id = %d
- """ % (company[1], web[0]))
-
- # Delete column res.company.website_logo_to_be_delete
- cr.execute("""
- ALTER TABLE res_company
- DROP COLUMN website_logo_to_be_delete
- """)
diff --git a/website_logo/migrations/8.0.2.0.0/pre-migration.py b/website_logo/migrations/8.0.2.0.0/pre-migration.py
deleted file mode 100644
index 484b91b..0000000
--- a/website_logo/migrations/8.0.2.0.0/pre-migration.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# -*- coding: utf-8 -*-
-# License AGPL-3: Antiun Ingenieria S.L. - Antonio Espinosa
-# See README.rst file on addon root folder for more details
-
-
-def migrate(cr, version):
- # Rename res.company.website_logo to res.company.website_logo_to_be_delete
- cr.execute("""
- ALTER TABLE res_company
- RENAME COLUMN website_logo TO website_logo_to_be_delete
- """)
diff --git a/website_logo/models/__init__.py b/website_logo/models/__init__.py
index dd4b399..5a71f74 100644
--- a/website_logo/models/__init__.py
+++ b/website_logo/models/__init__.py
@@ -1,22 +1,5 @@
# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (C) 2015 Agile Business Group sagl (<http://www.agilebg.com>)
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero 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 Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
+# © 2015 Agile Business Group sagl
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from . import website
-from . import res_config
+from . import res_company
diff --git a/website_logo/models/res_company.py b/website_logo/models/res_company.py
new file mode 100644
index 0000000..03ea484
--- /dev/null
+++ b/website_logo/models/res_company.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# © 2015 Agile Business Group sagl
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from openerp import models, fields
+
+
+class ResCompany(models.Model):
+ _inherit = 'res.company'
+ website_logo = fields.Binary()
diff --git a/website_logo/models/res_config.py b/website_logo/models/res_config.py
deleted file mode 100644
index cdc49ef..0000000
--- a/website_logo/models/res_config.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- coding: utf-8 -*-
-# License AGPL-3: Antiun Ingenieria S.L. - Antonio Espinosa
-# See README.rst file on addon root folder for more details
-
-from openerp import models, fields
-
-
-class WebsiteConfigSettings(models.TransientModel):
- _inherit = 'website.config.settings'
-
- logo = fields.Binary(
- string="Website logo", related="website_id.logo",
- help="This field holds the logo for this website, showed in header."
- "Recommended size is 180x50")
diff --git a/website_logo/models/website.py b/website_logo/models/website.py
deleted file mode 100644
index 3ea3c35..0000000
--- a/website_logo/models/website.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (C) 2015 Agile Business Group sagl (<http://www.agilebg.com>)
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero 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 Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-from openerp import models, fields
-
-
-class Website(models.Model):
- _inherit = 'website'
-
- logo = fields.Binary(
- string="Website logo",
- help="This field holds the logo for this website, showed in header. "
- "Recommended size is 180x50")
diff --git a/website_logo/static/src/img/website_nologo.png b/website_logo/static/src/img/website_nologo.png
deleted file mode 100644
index b4a1044..0000000
Binary files a/website_logo/static/src/img/website_nologo.png and /dev/null differ
diff --git a/website_logo/tests/__init__.py b/website_logo/tests/__init__.py
new file mode 100644
index 0000000..c33093a
--- /dev/null
+++ b/website_logo/tests/__init__.py
@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+from . import test_logo
diff --git a/website_logo/tests/test_logo.py b/website_logo/tests/test_logo.py
new file mode 100644
index 0000000..66d2dd6
--- /dev/null
+++ b/website_logo/tests/test_logo.py
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+# © 2016 LasLabs Inc.
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from openerp.tests import HttpCase
+from openerp.addons.website_logo.controllers.main import WebsiteLogo
+import mock
+
+
+imp_cont = 'openerp.addons.website_logo.controllers.main'
+imp_req = '%s.request' % imp_cont
+mod_imp = '%s.Binary' % imp_cont
+
+
+class TestLogo(HttpCase):
+
+ @mock.patch(mod_imp)
+ def setUp(self, mk):
+ super(TestLogo, self).setUp()
+ self.model_obj = self.env['res.company']
+ self.cont_obj = WebsiteLogo()
+ self.rec_id = self.env.ref('base.main_company')
+ self.image_val = 'Test'.encode('base64')
+ self.mock = mk
+
+ @mock.patch('%s.http' % imp_cont)
+ @mock.patch('%s.StringIO' % imp_cont)
+ @mock.patch(imp_req)
+ def test_sql_query_and_fetch(self, imp_mk, str_mk, http_mk):
+ """ SQL query is executed and fetched """
+ with mock.patch('%s.openerp' % imp_cont) as mk:
+ cr_mk = mk.modules.registry.Registry().cursor().__enter__()
+ self.cont_obj.website_logo()
+ args = cr_mk.execute.call_args
+ self.assertIn(
+ 'SELECT c.website_logo', args[0][0],
+ 'Website logo select not in query call',
+ )
+
+ @mock.patch('%s.http' % imp_cont)
+ @mock.patch('%s.StringIO' % imp_cont)
+ @mock.patch(imp_req)
+ def test_packs_and_returns_file(self, imp_mk, str_mk, http_mk):
+ """ Result of query is packed into StringIO then returned as file """
+ with mock.patch('%s.openerp' % imp_cont) as mk:
+ cr_mk = mk.modules.registry.Registry().cursor().__enter__()
+ cr_mk.fetchone.return_value = [self.image_val, 123]
+ res = self.cont_obj.website_logo()
+ str_mk.assert_called_once_with(
+ str(self.image_val).decode('base64')
+ )
+ http_mk.send_file.assert_called_once_with(
+ str_mk(), filename='logo.png', mtime=123,
+ )
+ self.assertEqual(
+ http_mk.send_file(), res,
+ 'Did not return image',
+ )
+
+ @mock.patch('%s.functools' % imp_cont)
+ @mock.patch('%s.http' % imp_cont)
+ @mock.patch('%s.StringIO' % imp_cont)
+ @mock.patch(imp_req)
+ def test_default_on_exception(self, imp_mk, str_mk, http_mk, func_mk):
+ with mock.patch('%s.openerp' % imp_cont) as mk:
+ cr_mk = mk.modules.registry.Registry().cursor().__enter__()
+ cr_mk.execute.side_effect = StopIteration
+ res = self.cont_obj.website_logo()
+ http_mk.send_file.assert_called_once(func_mk())
+ self.assertEqual(res, http_mk.send_file())
diff --git a/website_logo/views/company_view.xml b/website_logo/views/company_view.xml
new file mode 100644
index 0000000..5c081be
--- /dev/null
+++ b/website_logo/views/company_view.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<odoo>
+ <record id="view_company_form" model="ir.ui.view">
+ <field name="name">res.company.form</field>
+ <field name="model">res.company</field>
+ <field name="inherit_id" ref="base.view_company_form"></field>
+ <field name="arch" type="xml">
+ <xpath expr="//page[@name='configuration']/group" position="after">
+ <group string="Website logo">
+ <field name="website_logo" widget="image" nolabel="1"/>
+ </group>
+ </xpath>
+ </field>
+ </record>
+</odoo>
diff --git a/website_logo/views/res_config_view.xml b/website_logo/views/res_config_view.xml
deleted file mode 100644
index 7c0a63a..0000000
--- a/website_logo/views/res_config_view.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-<data>
-
-<record id="view_website_config_settings" model="ir.ui.view">
- <field name="name">Adding website logo</field>
- <field name="model">website.config.settings</field>
- <field name="inherit_id" ref="website.view_website_config_settings"/>
- <field name="arch" type="xml">
- <group string="Domain" position="after">
- <div name="logo">
- <separator string="Logo"/>
- <group name="logo">
- <field name="logo" widget="image" nolabel="1"/>
- </group>
- </div>
- </group>
- </field>
-</record>
-
-</data>
-</openerp>
diff --git a/website_logo/views/website_templates.xml b/website_logo/views/website_templates.xml
index a7b0823..f0547a7 100644
--- a/website_logo/views/website_templates.xml
+++ b/website_logo/views/website_templates.xml
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
-<openerp>
- <data>
+<odoo>
<template id="layout_logo_show" inherit_id="website.layout_logo_show">
<xpath expr="//a//img" position="attributes">
<attribute name="src">/website_logo.png</attribute>
</xpath>
</template>
- </data>
-</openerp>
+</odoo>
diff --git a/website_logo/views/website_view.xml b/website_logo/views/website_view.xml
deleted file mode 100644
index ab809ae..0000000
--- a/website_logo/views/website_view.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-<data>
-
-<record id="view_website_form" model="ir.ui.view">
- <field name="name">Add theme selection</field>
- <field name="model">website</field>
- <field name="inherit_id" ref="website.view_website_form"/>
- <field name="arch" type="xml">
- <div name="domain" position="after">
- <div name="logo">
- <separator string="Logo"/>
- <group name="logo">
- <field name="logo" widget="image" nolabel="1"/>
- </group>
- </div>
- </div>
- </field>
-</record>
-
-</data>
-</openerp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment