From f61b41e4ec2f10c261a5f0c1ab774c4eb2f38350 Mon Sep 17 00:00:00 2001 From: Jordi Riera Date: Tue, 17 Mar 2015 16:31:01 -0400 Subject: [PATCH] [ADD] Add res_company_logo_secondary module. --- res_company_logo_secondary/README.rst | 29 +++++++ res_company_logo_secondary/__init__.py | 21 +++++ res_company_logo_secondary/__openerp__.py | 33 ++++++++ res_company_logo_secondary/res_company.py | 78 +++++++++++++++++++ .../res_company_view.xml | 29 +++++++ 5 files changed, 190 insertions(+) create mode 100644 res_company_logo_secondary/README.rst create mode 100644 res_company_logo_secondary/__init__.py create mode 100644 res_company_logo_secondary/__openerp__.py create mode 100644 res_company_logo_secondary/res_company.py create mode 100644 res_company_logo_secondary/res_company_view.xml diff --git a/res_company_logo_secondary/README.rst b/res_company_logo_secondary/README.rst new file mode 100644 index 000000000..2962f246e --- /dev/null +++ b/res_company_logo_secondary/README.rst @@ -0,0 +1,29 @@ +Company Logo Secondary +====================== + +The module associates a secondary logo and name to the company. + +The case the module required the module was because the company had some +alternate logo and name. + +Credits +======= + +Contributors +------------ + +* Jordi Riera +* Pierre Gault + +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. diff --git a/res_company_logo_secondary/__init__.py b/res_company_logo_secondary/__init__.py new file mode 100644 index 000000000..95297445f --- /dev/null +++ b/res_company_logo_secondary/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Nicolas Bessi. Copyright Camptocamp SA +# +# 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 . +# +############################################################################## + +from . import res_company diff --git a/res_company_logo_secondary/__openerp__.py b/res_company_logo_secondary/__openerp__.py new file mode 100644 index 000000000..f2a309fac --- /dev/null +++ b/res_company_logo_secondary/__openerp__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Nicolas Bessi. Copyright Camptocamp SA +# +# 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 . +# +############################################################################## + +{ + 'name': 'Company Logo Secondary', + 'version': '1.0', + 'author': 'Savoir-faire Linux', + 'maintainer': 'Savoir-faire Linux, OCA', + 'category': 'Sales', + 'website': 'http://www.savoirfairelinux.com', + 'depends': ['base'], + 'data': [ + 'res_company_view.xml', + ], + 'installable': True, +} diff --git a/res_company_logo_secondary/res_company.py b/res_company_logo_secondary/res_company.py new file mode 100644 index 000000000..a77fdddb6 --- /dev/null +++ b/res_company_logo_secondary/res_company.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Nicolas Bessi. Copyright Camptocamp SA +# +# 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 . +# +############################################################################## +from openerp.osv import orm, fields +from openerp import tools + + +class ResCompany(orm.Model): + _inherit = 'res.company' + + def _get_logo_secondary(self, cr, uid, ids, name, args, context=None): + result = dict.fromkeys(ids, False) + for obj in self.browse(cr, uid, ids, context=context): + result[obj.id] = tools.image_get_resized_images(obj.logo_secondary) + return result + + def _set_logo_secondary(self, cr, uid, id, name, value, args, context=None): + return self.write( + cr, uid, [id], + {'image': tools.image_resize_image_big(value)}, + context=context + ) + + def _has_logo_secondary(self, cr, uid, ids, name, args, context=None): + result = {} + for obj in self.browse(cr, uid, ids, context=context): + result[obj.id] = obj.logo_secondary != False + return result + + _columns = { + 'name_secondary': fields.char('Secondary name', size=128), + 'logo_secondary': fields.binary("Logo Secondary"), + 'image_medium': fields.function( + _get_logo_secondary, + fnct_inv=_set_logo_secondary, + string="Medium-sized logo secondary", + type="binary", + multi="_get_logo_secondary", + store={ + _inherit: ( + lambda self, cr, uid, ids, c={}: + ids, ['logo_secondary'], 10 + ), + } + ), + 'image_small': fields.function( + _get_logo_secondary, + fnct_inv=_set_logo_secondary, + string="Small-sized logo secondary", + type="binary", + multi="_get_logo_secondary", + store={ + _inherit: ( + lambda self, cr, uid, ids, c={}: + ids, ['image'], 10), + }, + ), + 'has_logo_secondary': fields.function( + _has_logo_secondary, type="boolean" + ), + + } diff --git a/res_company_logo_secondary/res_company_view.xml b/res_company_logo_secondary/res_company_view.xml new file mode 100644 index 000000000..ce8cfa5c6 --- /dev/null +++ b/res_company_logo_secondary/res_company_view.xml @@ -0,0 +1,29 @@ + + + + + Company: Logo Secondary + res.company + + 100 + + + +
+ +
+
+
+
+
+ +
+
+ + +
+