Browse Source

[IMP] Integrate secondary logo with the report action

pull/98/head
Joao Alfredo Gama Batista 10 years ago
parent
commit
785d27656c
  1. 1
      res_company_logo_secondary/__init__.py
  2. 16
      res_company_logo_secondary/__openerp__.py
  3. 34
      res_company_logo_secondary/ir_actions_report_xml.py
  4. 15
      res_company_logo_secondary/ir_actions_report_xml_view.xml
  5. 18
      res_company_logo_secondary/res_company.py

1
res_company_logo_secondary/__init__.py

@ -19,3 +19,4 @@
##############################################################################
from . import res_company
from . import ir_actions_report_xml

16
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,
}

34
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
# (<http://www.savoirfairelinux.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.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
}

15
res_company_logo_secondary/ir_actions_report_xml_view.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="act_report_xml_view_secondary_logo" model="ir.ui.view">
<field name="name">ir.actions.report.xml</field>
<field name="model">ir.actions.report.xml</field>
<field name="inherit_id" ref="base.act_report_xml_view"/>
<field name="arch" type="xml">
<field name="header" position="after">
<field name="use_secondary_logo" attrs="{'invisible': [('header', '=', False)]}" />
</field>
</field>
</record>
</data>
</openerp>

18
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"
)
}
Loading…
Cancel
Save