~openerp-dev/openobject-server/saas-4-report-fixes-sle

« back to all changes in this revision

Viewing changes to openerp/addons/base/ir/ir_actions.py

  • Committer: Simon Lejeune
  • Date: 2014-05-15 20:23:23 UTC
  • Revision ID: sle@openerp.com-20140515202323-un166mor6udytjgx
[FIX] ir_actions: adapt render_report when called in a tests/qweb report context to generate the pdf only if a directory has been provided

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
_logger = logging.getLogger(__name__)
43
43
 
 
44
 
44
45
class actions(osv.osv):
45
46
    _name = 'ir.actions.actions'
46
47
    _table = 'ir_actions'
129
130
        Look up a report definition and render the report for the provided IDs.
130
131
        """
131
132
        new_report = self._lookup_report(cr, name)
132
 
        # in order to use current yml test files with qweb reports
133
 
        if isinstance(new_report, (str, unicode)):
134
 
            return self.pool['report'].get_pdf(cr, uid, res_ids, new_report, data=data, context=context), 'pdf'
 
133
 
 
134
        if isinstance(new_report, (str, unicode)):  # Qweb report
 
135
            # The only case where a QWeb report is rendered with this method occurs when running
 
136
            # yml tests originally written for RML reports.
 
137
            if openerp.tools.config['test_enable'] and not tools.config['test_report_directory']:
 
138
                # Only generate the pdf when a destination folder has been provided.
 
139
                return self.pool['report'].get_html(cr, uid, res_ids, new_report, data=data, context=context), 'html'
 
140
            else:
 
141
                return self.pool['report'].get_pdf(cr, uid, res_ids, new_report, data=data, context=context), 'pdf'
135
142
        else:
136
143
            return new_report.create(cr, uid, res_ids, data, context)
137
144
 
1170
1177
 
1171
1178
    }
1172
1179
 
1173
 
 
1174
 
 
1175
1180
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
1176