From 785d27656c837e681f5f8b116b3bedda055fa412 Mon Sep 17 00:00:00 2001 From: Joao Alfredo Gama Batista Date: Mon, 4 May 2015 17:34:48 -0400 Subject: [PATCH] [IMP] Integrate secondary logo with the report action --- res_company_logo_secondary/__init__.py | 1 + res_company_logo_secondary/__openerp__.py | 16 +++++++++ .../ir_actions_report_xml.py | 34 +++++++++++++++++++ .../ir_actions_report_xml_view.xml | 15 ++++++++ res_company_logo_secondary/res_company.py | 18 +++++++++- 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 res_company_logo_secondary/ir_actions_report_xml.py create mode 100644 res_company_logo_secondary/ir_actions_report_xml_view.xml diff --git a/res_company_logo_secondary/__init__.py b/res_company_logo_secondary/__init__.py index 95297445f..ad544d604 100644 --- a/res_company_logo_secondary/__init__.py +++ b/res_company_logo_secondary/__init__.py @@ -19,3 +19,4 @@ ############################################################################## from . import res_company +from . import ir_actions_report_xml diff --git a/res_company_logo_secondary/__openerp__.py b/res_company_logo_secondary/__openerp__.py index f2a309fac..c2e229100 100644 --- a/res_company_logo_secondary/__openerp__.py +++ b/res_company_logo_secondary/__openerp__.py @@ -25,9 +25,25 @@ 'maintainer': 'Savoir-faire Linux, OCA', 'category': 'Sales', 'website': 'http://www.savoirfairelinux.com', + 'license': 'AGPL-3', + 'description': """ +Company Secondary Logo +====================== + +This module adds a a secondary logo to the company to be used by reports. +It requires the commit 491eb7ee35535666de6923ee63309c316b2b847d from the +https://github.com/savoirfairelinux/odoo/tree/7.0_res_company_secondary_logo +branch. + +Contributors +------------ +* Jordi Riera (jordi.riera@savoirfairelinux.com) +* Joao Alfredo Gama Batista (joao.gama@savoirfairelinux.com) +""" 'depends': ['base'], 'data': [ 'res_company_view.xml', + 'ir_actions_report_xml_view.xml' ], 'installable': True, } diff --git a/res_company_logo_secondary/ir_actions_report_xml.py b/res_company_logo_secondary/ir_actions_report_xml.py new file mode 100644 index 000000000..1c5e72064 --- /dev/null +++ b/res_company_logo_secondary/ir_actions_report_xml.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Odoo, Open Source Management Solution +# This module copyright (C) 2015 Savoir-faire Linux +# (). +# +# 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 + + +class IrActionsReportXml(orm.Model): + _inherit = 'ir.actions.report.xml' + + _columns = { + 'use_secondary_logo': fields.boolean('Use Secondary Logo') + } + + _defaults = { + 'use_secondary_logo': False + } diff --git a/res_company_logo_secondary/ir_actions_report_xml_view.xml b/res_company_logo_secondary/ir_actions_report_xml_view.xml new file mode 100644 index 000000000..972d192f6 --- /dev/null +++ b/res_company_logo_secondary/ir_actions_report_xml_view.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/res_company_logo_secondary/res_company.py b/res_company_logo_secondary/res_company.py index a77fdddb6..65b08bef4 100644 --- a/res_company_logo_secondary/res_company.py +++ b/res_company_logo_secondary/res_company.py @@ -43,6 +43,18 @@ class ResCompany(orm.Model): result[obj.id] = obj.logo_secondary != False return result + def _get_smart_logo(self, cr, uid, ids, name, args, context=None): + context = context or None + + res = {} + for obj in self.browse(cr, uid, ids, context=context): + if 'use_secondary_logo' in context and context['use_secondary_logo']: + res[obj.id] = obj.logo_secondary + else: + res[obj.id] = obj.logo + + return res + _columns = { 'name_secondary': fields.char('Secondary name', size=128), 'logo_secondary': fields.binary("Logo Secondary"), @@ -74,5 +86,9 @@ class ResCompany(orm.Model): 'has_logo_secondary': fields.function( _has_logo_secondary, type="boolean" ), - + 'smart_logo': fields.function( + _get_smart_logo, + string="Logo", + type="binary" + ) }