2017-05-08 66 views
0

我正在使用qweb報告生成一個文檔,該文檔應該使用Odoo的document模塊進行關聯附件。但我不知道如何顯示與qweb/pdf報告中的文檔相關的附件列表。在qweb報告中獲取文檔附件列表Odoo

請注意,我不是要求將文檔作爲附件存儲。只需在報告中顯示當前附件列表。

你知道該怎麼做嗎?

回答

0

我使用computed fields來解決這個問題,其關係爲one2many。

這使魔:

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)])