Link multiple records to one attachment


#1

In Tryton you can add attachments to different records (sale, invoice, purchase, party etc). On each records you can add multiple attachments. We are however searching for the other way around, adding multiple records to each attachment.

There are several use cases for this, like catalog pages from a supplier on which multiple of your products are described. You don’t want to cut that page into parts or add that page multiple times as attachment because in the future it will be updated. Also adding multiple times the same file is data duplication what should be prevented.
Another use case is like our one. We have calibration certificates which contains multiple assets. So we want to link all those assets to that specific calibration certificate. But that’s not possible now.

Is this something which can be implemented?


(Cédric Krier) #2

The file-system storage for the attachments avoid duplication of the data by using hash.

I think it is better to not use attachment but a custom model that you can link with all your assets.
The Binary field can use the same file-system storage as the attachment.


#3

So this means that when I add the same file to two different records, Tryton automatically detects that and links to the same binary?

That seems the way to go, the only thing I see is that the attachment-icon in the client isn’t working anymore. But that’s something we can overcome.


(Cédric Krier) #4

Yes check: http://hg.tryton.org/trytond/file/default/trytond/filestore.py#l30