This question has been flagged

Hello,

I am  making a custom module to store data on custom tools which require a pdf, image or design file to be saved in with the tools model and Im not sure on how to implement this?

I guesses I could possibly use ir.attachment but not sure on how to implement it.

Thanks for any help  

Avatar
Discard

By using binary fields: https://goo.gl/2JAxhD

Best Answer

Hi Levi: You also have the option of defining the field as a binary (odoo.fields.Binary) field. Attachments provide you the ability to attach multiple documents. The binary field will allow you to store one document in the binary field.

Avatar
Discard
Best Answer

Hi,

See the below samples of adding Many2one and Many2Many field for storing files.

attachment_id = fields.Many2one('ir.attachment', string='Attachment', ondelete='cascade')

doc_attachment_id = fields.Many2many('ir.attachment', 'doc_attach_rel', 'doc_id', 'attach_id3', string="Attachment",
help='You can attach the copy of your document', copy=False)


Thanks

Avatar
Discard