Odoo Help

Welcome!

This community 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.

1

How to work with ir.attachment in Odoo 8?

By
Pascal Tremblay
on 6/30/15, 2:55 PM 3,800 views

Hey guy,

Other questions here. 

Document module is well installed. We are on Odoo 8 nightly build.

When we go in Setting->Database Structure->Attachments, we many icons of our reports an attachments.


1) If we prefer to store our attachments in a external filestore, should they appear there too?

2) In this place, can we only see attachment stored in database?


3) And you guys, do you use this ir_attachment.location parameter in the setting of Odoo 8???



4) It is impossible to write any PDF report in the filestore (on disk). We can not see them in settings -> Database Structure -> Attachment, anymore... It worked before!!!??!!!  See image above.... We can see any PDF there... But now, it doesn't work.


5) I have made a search in all the directory of our odoo installations. No trace of any PDF there... It is magic.... Where are my report????? When it is written on the web that we can store our attachment on a disk filestore, does it include also the PDF REPORTS?????


Thanks to help or discuss any of my questions.

3

Temur

--Temur--
2896
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 6/30/15, 5:04 PM

We had some discussion about the topic here. It covers at least 4 and 5.

UPDATE:

1) Currently it's other way around: if we prefer to store files in database, then we have to configure it to be this way. by default files are stored in filestore, we do not have to configure anything. Files are stored in filestore and naturally they appear there. Thus, database records ("ir.attachment") are necessary as they are pointing to actual files in the filestore. 

2) In this place we see ir.attachment records, any of them may have actual file saved in filestore or in database. It does not matter where file is stored, in database or in filestore, here we can see all ir.attachment records.

3) this setting determine where files are actually stored. value 'file' is default and it means that files will be stored in the filestore. value 'db' means that files will be stored in the database, you can set it to 'db'. also possible use some path, I tried to use path in v7 but it become relative path under filestore... for path you can check how it works for v8. also you can implement support for other storage engines, refer to ir_attachment code. Note: if we change this setting, it'll affect only new records. i.e. if it was set to 'file' and we changed to 'db', then old files will stay where they are in filestore, but new files will be stored in database, and so on.

4) if you interested to do it yourself, then this is completely cowered in the thread that I've referred in the beginning. i.e. create file (csv) and save it using ir.attachment. only difference is that in your case file type is pdf, this difference does not make big deal. But if you just worry that now, it doesn't work... then I can assure you that it works like a charm.

5) Also cowered in the referred thread. files on the disk are NOT saved with it's original names, but using hash code of it's content (used sha1 of content, part of hash used for parent directory of actual file). that's why you can't find the file you search with it's name, but files are there. file names are stored in the database, in ir.attachment. if it's absolutely necessary you can find file on the disk if you know or can compute it's sha1 hash code. you'll find the file under filestore, under directory with a name matching the start (left part) of hashcode. as you find the correct one and you know it's original name, you can rename it (or just add .pdf extension) and open with some pdfreader.


Thanks. Someone else?

Pascal Tremblay
on 6/30/15, 5:09 PM

Updated. Added answers to 1, 2 and 3. Also added notes for 4 and 5.

Temur
on 7/1/15, 3:05 AM

Big big big thanks! We analyze each one of your words and we come back with our comments.

Pascal Tremblay
on 7/1/15, 5:23 AM

You're welcome.

Temur
on 7/1/15, 7:06 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/30/15, 2:55 PM
Seen: 3800 times
Last updated: 1/12/16, 8:41 PM