odoo 中的附件在form及tree表单中以超链接的形式显示
例子:
下边附件上传3个附件

在form 表单中显示这三个附件:

代码:
mail.thread 模型中添加计算字段
from odoo import models, fields, api
class MailThread(models.AbstractModel):
_inherit = 'mail.thread'
attachment_ids = fields.Many2many(comodel_name='ir.attachment', compute='_compute_attachment_ids')
def _compute_attachment_ids(self):
for rec in self:
rec.attachment_ids = self.env['ir.attachment'].search(
[('res_id', 'in', rec.ids), ('res_model', '=', self._name)])
在xml文件中添加计算字段:
<field name="attachment_ids" widget="many2many_binary"/>
本文来自博客园,作者:那时一个人,转载请注明原文链接:https://www.cnblogs.com/qianxunman/p/15266643.html

浙公网安备 33010602011771号