Hello. I need to know how to make a file upload to the server OpenERP. I'm creating a module which has to allow me to do an upload of a file to the server, then do a treatment for their content. I have done the treatment but n ose content as I can make a system call OpenERP to Upload File.
12 Answers
Hi,
you can use fields.binary
. you can save your file in database.
in your file.py
'data': fields.binary('File'),
in your file.xml:
<field name="data" />
and
<button name="import_file" string="Import" type="object" class="oe_highlight" />
if you clik in button Import it call function import_file
in your function :
create a temp file for treatment content data.
def import_file(self, cr, uid, ids, context=None):
fileobj = TemporaryFile('w+')
fileobj.write(base64.decodestring(data))
# your treatment
return
Thanks.
I need a button on my form that allows me to look at the client workstation, the file you want to upload to the server, and already once uploaded to launch the program evaluate the content of the file. After parsing the file's contents, if correct, shall be recorded in the custom tables, but never before.
@Joaquin i want to import sale order line from import button like i want add sale order line three(3) way 1-> add sale order line as current working oi's ok 2-> add sale oder line from my CSV/Excel file when i click on import button in sale order form view 3-> add sale order line both like 1, 2 how it is possible ?
Please elaborate. Do you mean uploading some sort of python script or csv? Not sure where you're trying to go with this, there's already importing, file attachments, etc.
Hi Brett.What I want is to upload a file, it can be a txt, csv or xls from a custom module, and that module should read the contents of that file and processing it, analyzing those contents and insert those contained in the custom tables.