【问题标题】:Get document attachment list in qweb report Odoo在 qweb 报表 Odoo 中获取文档附件列表
【发布时间】:2017-05-08 20:12:23
【问题描述】:

我正在使用 qweb 报告生成一个文档,该文档应该使用 Odoo 的 document 模块具有关联的附件。但我不知道如何在 qweb/pdf 报告中显示与文档关联的附件列表。

请注意,我不是要求将文档存储为附件。只是为了在报告中显示当前附件的列表。

你知道怎么做吗?

【问题讨论】:

    标签: python odoo odoo-10 qweb odoo-view


    【解决方案1】:

    我在 one2many 关系中使用 computed fields 解决了这个问题。

    这就是魔法:

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

    【讨论】:

      猜你喜欢
      • 2022-11-11
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多