# -*- coding: utf-8 -*- # # Odoo Extension Module # Copyright (C) 2014-2016 Camadeus GmbH () # # 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 . # import re import openerp from openerp import models import logging _logger = logging.getLogger(__name__) class Report(models.Model): _inherit = "report" def render(self, cr, uid, ids, template, values=None, context=None): testmode = {'testmode': False} r = openerp.tools.config.get('dbfilter_test', 'test.*') try: pattern_list = eval(r) if not hasattr(pattern_list, '__iter__'): pattern_list = [pattern_list] except: pattern_list = [r] for pattern in pattern_list: if isinstance(pattern, str) and re.match(pattern, cr.dbname): testmode = {'testmode': True} _logger.info('testmode enabled for reports') if not values: values = {} values.update(testmode) return super(Report, self).render(cr, uid, ids, template, values, context)