Hi.
I had the same problem. The only solution for me was to modify the OPENERP Kernel with a patch. Then you can control the name from you xml report configuration. Example:
<report
id="sale_order_cyls_label_report"
model="sale.order"
name="sale_order_cyls_label_report"
file="OpenJobs/report/sale_order_cyls_label_report.rml"
string="Cylinders Labels 2x2"
auto="True"
report_type="pdf"
attachment="('CYL'+(object.job_id.job or ''))"
usage="default"
keyword="client_print_multi"
menu="True"
header="False"
/>
Then the file name was made from the attribute 'attachment' ex. 'CYL10024.pdf'. To patch, change the file 'openerp7/openerp-web/addons/web/controllers/main.py'. Search and find at the end of file the statement:
file_name = '%s.%s' % (file_name, report_struct['format'])
Then insert next code just before:
#Start code added
''' Code added by Raul Paz to set the default file_name like the attach_name
The attach_name mach with the attachment expresion from your report_xml
<report
id="report_webkit.YourModule_report_id"
model="YourModule.model"
name="Your_report_name"
file="YOUR_MODULE/report/YOUR_MAKO_FILE.mako"
string="Your Text in the print button"
auto="False"
report_type="webkit"
attachment="'Valid_filename_expresion"
usage="default"
/>
'''
try:
if action['attachment']:
model = context['active_model']
cr = openerp.pooler.get_db(req.session._db).cursor()
uid = context['uid']
ids = context['active_ids']
objects=openerp.pooler.get_pool(req.session._db).get(model).browse(cr,uid,ids,context=context)
file_name=[eval(action['attachment'],{'object':x, 'time':time}) for x in objects][0]
''' Next code force to remake the report file on each request.
Remove if your want to send always the first report file.
If attachment_use is set to false the report files are always generated and stored
'''
if action['attachment_use']:
aids = openerp.pooler.get_pool(req.session._db).get('ir.attachment').search(cr, uid, [('datas_fname','=',file_name+'.pdf'),('res_model','=',model),('res_id','in',ids)])
atts = openerp.pooler.get_pool(req.session._db).get('ir.attachment')
res = atts.unlink(cr, uid, aids, context)
cr.commit()
openerp.osv.orm.except_orm('Attach doc deleted',file_name)
except:
openerp.osv.orm.except_orm('Attach doc not deleted',file_name)
finally:
cr.close()
#end code added
This work for all report styles...