HI
I'm with some troubles when I'm downloading some files. The name I set to the file is for example "123456.xml" and when I download it the file name is the name of my model....
I store the name and the filedata on a database to set as default on the new wizard after I click on a button (I have some images to help you understand :) )
My .py
I create the columns
class Saft_Export_Transporte(osv.osv_memory):
_name = 'saft.export.transporte'
_description = 'Saft Export'
def get_filedata_transporte(self, cr, uid, context=None):
cr.execute("SELECT filedata from Saft_Export_Transporte where id=1")
output=cr.fetchone()
output=str(output[0])
return outputdef get_name_transporte(self, cr, uid,context=None):
cr.execute("SELECT name from Saft_Export_Transporte")
output=cr.fetchone()
output=str(output[0])
return output
_columns = {
'name': fields.char('Nome',size=25, readonly=True),
'filedata': fields.binary('Texto',filters='*.xml'),
}
_defaults = {
'filedata': get_filedata_transporte,
'name': get_name_transporte
}
My .xml
<record id="saft_export_transporte" model="ir.ui.view">
<field name="name">Saft Export Transporte</field>
<field name="model">saft.export.transporte</field>
<field name="arch" type="xml">
<form string="Saft Export Transporte" version="7.0">
<group col="1">
<separator string="Concluido"/>
<field name="name" invisible="1"/>
<label string="Guarde o ficheiro resumido saft"/>
<newline/>
<field name="filedata" nolabel="1" readonly="1" filename="name"/>
</group>
<footer>
<button string="Fechar" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record><record id="saft_export_action" model="ir.actions.act_window">
<field name="name">saft.export</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">saft.export.transporte</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
Can you help me?