简体   繁体   中英

Get document attachment list in qweb report Odoo

i am using qweb reports to generate a document wich should have asociated attachments using the document module of Odoo. But i dont know how to display the list of attachments asociated to a document in the qweb/pdf report.

Please note that i am not asking to store a document as attachment. Just to display the list of current attachments in a report.

Do you know how to do that?

I solve that problem using computed fields in a relationship one2many.

this make the magic:

attachment_ids = fields.One2many(comodel_name="ir.attachment", inverse_name="res_id", compute="_add_attachment")
@api.multi
def _add_attachment(self):
    self.attachment_ids = self.env['ir.attachment'].search([('res_model','=','document'),('res_id','=',self.id)])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM