OpenERP 6.1 module with upload file field - python

I want to create OpenERP 6.1 module with a upload binary file field as one of the fields in view.
The file will be stored in database as binary data, but before storage in database I need to parse that file, and save data as part of the other created module.
So, I don't know how to specifiy filed for upload files in a view xml file, and also how to run the uploading process. Can somebody help me about this? Some code snippets or advice how to do that.

Take a look at the way the attachments module works, particularly the binary data column. You should also look at the screen definition.

Related

How do I upload and manipulate excel file with Django?

Ok,
I had a look at the UploadFile Class documentation of the Django framework. Didn't find exactly what I am looking for?
I am creating a membership management system with Django. I need the staff to have the ability to upload excel files containing list of members (and their details) which I will then manipulate to map to the Model fields.
It's easy to do this with pandas framework for example, but I want to do it with Django if I can.
Any suggestions.
Thanks in advance
you can use xlrd to read excel files
in client side you just submit a form with file input.
on server uploaded file stored on request.FILES
read file and pass it to xlrd then process sheets and cells of each sheet

How to store and download a zip file in database postgres

I'm trying to store and then download a zip file from Postgres database. I know that this is not the best approach (i should only save the path to file) but i need to do this way, just for learning and practice.
I did a python script to store the content of the file into a bytea field but this was not my final goal. I really want to know how to save the zip file.
Any ideas? I just know python so i'm trying to this in python
Thank you guys!
If you can store the file as a bytea field then storing a zipped file is just the same.
Postgres doesn't have a concept of "file" field - you simply store the content (as you did for the original content) in bytea field.
If you're asking about zipping a file on the fly,
Take a look at zlib it's one of the common modules for such tasks.
Regards
Jony

save binary fields to folder?

I would like to use binary fields in openerp, but instead of save them to the database as usual, I'd like to save to file system (folder). I could use a char field to store the path but, is there a way to implement the upload and download for it?
Thanks
A module which was developed in version 6 may help you to select path for saving files instead of storing in db as binary.
check out web gallery module

Insert users into Active Directory

I am trying to determine how to best insert users into active directory from a SQL server table.
I figured I could use the LDAP sever to do a insert, but the research iv done would suggest otherwise and that I could only pull data from active directory to SQL server.
Then I thought I could use a python program to query the table and spit out a CSV file to then do a bulk insert but I am not sure if this would modify existing users if data changes.
Any insight would be appreciated
Here's a general idea of the algorithm:
Load user data from SQL Server
Convert it into an LDIF (LDAP Data Interchange Format) file
Import the LDIF file into Active Directory using the LDIFDE command-line tool
Python, or any other programming language, can help you with step 2. Notice that the details of the conversion are very specific to how your data is represented. You'll have to carefully map each data base field into an LDAP attribute, and determine the classes to be used in the LDAP objects.
Will the above modify existing users? yes, of course. You could write the LDIF in such a way that it updates the existing data, or if that's a problem you could verify first if an user exists in the Active Directory and don't add those changes to the LDIF file.
Alternatively
You could use CSVDE for importing data in CSV format, but anyway you'll have to design a mapping strategy for each one of the fields that you want to import into Active Directory.

OpenErp - External Id Bulk Update

I need a way to add, some external ID's in the system without having to add them manually or by .csv
Is there any way to do this by a module, that maybe updates all the ir.model.data tables of the db?
If so, what module should i look for? Is there any in existence, so i can make a new one based on it?
Thanks in advance
You can do this with a module by loading the data through xml or csv. Have a look at any module with a security\ir.model.access.csv file.
So to load data, create new module and add a csv file with the name of the table you want to load into (eg ir.model.data.csv) and add it to the __openerp__.py file under 'update_xml'.

Categories