You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.2 KiB
58 lines
2.2 KiB
# -*- 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
|
|
}
|
|
|
|
def write(self, cr, uid, ids, vals, context=None):
|
|
context = context or {}
|
|
|
|
company = self.pool['res.users'].browse(
|
|
cr, uid, uid, context=context).company_id
|
|
logo_name = company.has_logo_secondary and company.name_secondary or False
|
|
|
|
if 'use_secondary_logo' in vals:
|
|
if logo_name:
|
|
assert len(ids) == 1, "you can only modify the report logo " \
|
|
"one at a time"
|
|
name = vals.get('name', False) or self.browse(
|
|
cr, uid, ids[0], context=context).name
|
|
if vals['use_secondary_logo']:
|
|
vals['name'] = ' '.join([name.strip(logo_name), logo_name])
|
|
else:
|
|
vals['name'] = name.strip(logo_name)
|
|
|
|
else:
|
|
vals.pop('use_secondary_logo')
|
|
|
|
return super(IrActionsReportXml, self).write(
|
|
cr, uid, ids, vals, context=context)
|