Skip to Content
Menu
This question has been flagged
3 Replies
11133 Views

Hi Team,

I am trying to workout how to add an attachment(s) field within the view (as opposed or in addition to the default attachments menu at the top of the screen).

I have looked at using the binary field type, but this seems to require the creation of a subform and view, etc.. Seems very complicated for something that I would have thought would be simple.  I don't want to go and over complicate things if not necessary.  


Any thoughts would be highly appreciated?

Thanks,

Damien

Avatar
Discard

Hi, define field in the form like this, attachment_ids = fields.Many2many('ir.attachment', string='Attachments')

Best Answer

Hi,

Try this example.

Python:

attachment_ids = fields.Many2many('ir.attachment', 'car_rent_checklist_ir_attachments_rel',
'rental_id', 'attachment_id', string="Attachments",
help="Images of the vehicle before contract/any attachments")

XML:

<field name="attachment_ids" widget="many2many_binary" class="oe_inline"/>

Thank you.

Avatar
Discard
Author

Thankyou for this advise. I have followed this and it works well, however there is a major security issue with this method... The attachments are referred by a URL with an incremented number. This obviously means that any logged in user can go through the number range to get to all of the attachments. Is there anyway to lock down the attachments to the record for which they are attached? So only a person with the permission to that record could view those attachments?

THanks,

Damien

Best Answer

Hi 

Try this module

https://www.odoo.com/apps/modules/10.0/muk_dms/

Avatar
Discard