Odoo Help


1 Answer

Ludo - 21South Netherlands

--Ludo - 21South--
| 3 2 7
Zwijndrecht, Netherlands
--Ludo - 21South--


Ludo - 21South Netherlands
10/29/14, 6:47 AM

The user in which OpenERP is running most likely has no access rights to any other directory then the OpenERP directory itself. You will notice for example that files like attachments are usually stored in database OR in the filestore directory under the openerp directory.  Since you are pointing to a home directory, which might be something this user doesn't have. The /tmp directory is also available, but make since its temporary, it is not permanent and therefor not ideal in your situation.

However, there is an alternative to a fysical file. Look up documentation in python on StringIO. This allows you to create a virtual file, and use any normal file operation on it like you normally would. Difference is that this file is not stored on the disk and therefore does not require specific access rights.

Once you have such a file, you store its contents in a binary field in OpenERP and/or as attachment. I think this will work for you.

1 Comment
Anirudh Lou Singapore
11/4/14, 3:57 AM

Thank you sir for your answer, actually i did what you have told me, but i got an error, or perhaps my code is far way from reality. I made a class named 'file.holder' just like this one: class file_holder(osv.osv): _name = 'file.holder' _columns = { 'name' : fields.char('File name'), 'file_data' : fields.binary('File Name',filters='*.DAT',) } def get_file(self, cr, uid, context=None): file_path = addons.get_module_resource('mp_seven', 'files', 'studentlist.DAT') fo = {} fo = open(file_path,"wb") active_id = self.pool.get('student.student').search(cr,uid,[]) for list in self.browse(cr,uid,active_id,context=context): fo.write(list.id+","+list.name) self.create(cr,uid,{ 'name' : '', 'file_data' : file_path }) return fo.read().encode('base64') file_holder() where addons is a folder in openerpserver-7, mp_seven is my project name, files is subfolder in my project and where studentlist.DAT resides. Whenever this method is bieng called in other class the browser/terminal says : file_path = addons.get_module_resource('mp_seven', 'files', 'studentlist.DAT') NameError: global name 'addons' is not defined

Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now