Reputation: 123
I declared a variable below:
import os
......
class product(osv.osv):
......
file_import = fields.Binary(string="File")
@api.multi
def save_file(self):
# do something
If I declare variable above, can I get extension file_import?
Upvotes: 1
Views: 738
Reputation: 1315
create new field for storefile name and set into xml.
Example
----Python-----
import os
......
class product(osv.osv):
......
file_import = fields.Binary(string="File")
filename=fields.char('Filename')
------XML-----
<field name="filename" invisible="1"/>
<field name="file_import" filename="filename"/>
So, when you upload file file_import field it will automatically store file name into filename field. From filename you can get its extension.
Hope this helps.
Upvotes: 1