On OpenERP 7, when you have the document module installed and you download the attachement via the drop down list on the form view, the name of the file will be the name of the attachement and not datas_fname ; so we need to have name = datas_fname.

This commit is contained in:
Alexis de Lattre
2013-12-09 14:34:10 +01:00
committed by Alexis de Lattre
parent 3f6cddd3ed
commit 2335aecfda

View File

@@ -95,12 +95,11 @@ class report_intrastat_common(orm.TransientModel):
import base64
assert len(ids) == 1, "Only one ID accepted"
filename = datetime.strftime(start_date_datetime, '%Y-%m') + '_' + declaration_name + '.xml'
attach_name = declaration_name.upper() + ' ' + datetime.strftime(start_date_datetime, '%Y-%m')
attach_obj = self.pool.get('ir.attachment')
if not context:
context = {}
context.update({'default_res_id': ids[0], 'default_res_model': object._name})
attach_id = attach_obj.create(cr, uid, {'name': attach_name, 'datas': base64.encodestring(xml_string), 'datas_fname': filename}, context=context)
attach_id = attach_obj.create(cr, uid, {'name': filename, 'datas': base64.encodestring(xml_string), 'datas_fname': filename}, context=context)
return attach_id
def _open_attach_view(self, cr, uid, attach_id, title='XML file', context=None):