[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
This commit is contained in:
Vo Minh Thu 2012-02-10 12:34:27 +01:00
parent a04e39233c
commit 799752a74b
1 changed files with 7 additions and 1 deletions

View File

@ -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