From 799752a74b2bc20071068ec8361ba136a79e5259 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 10 Feb 2012 12:34:27 +0100 Subject: [PATCH] [FIX] report: do not use the default_type entry from the context: the type column exists on both the account_invoice and on the attachment. It is set for the account_invoice, so we must not use it for the attachment creation. lp bug: https://launchpad.net/bugs/918203 fixed bzr revid: vmt@openerp.com-20120210113427-vnty3pcmcw3g3b97 --- openerp/report/report_sxw.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openerp/report/report_sxw.py b/openerp/report/report_sxw.py index b521a16a700..a1ceae9ae2b 100644 --- a/openerp/report/report_sxw.py +++ b/openerp/report/report_sxw.py @@ -474,13 +474,19 @@ class report_sxw(report_rml, preprocess.report): if aname: try: name = aname+'.'+result[1] + # Remove the default_type entry from the context: this + # is for instance used on the account.account_invoices + # and is thus not intended for the ir.attachment type + # field. + ctx = dict(context) + ctx.pop('default_type', None) pool.get('ir.attachment').create(cr, uid, { 'name': aname, 'datas': base64.encodestring(result[0]), 'datas_fname': name, 'res_model': self.table, 'res_id': obj.id, - }, context=context + }, context=ctx ) except Exception: #TODO: should probably raise a proper osv_except instead, shouldn't we? see LP bug #325632