How to Show the Attachments in ERP According to Users Need?

How to Show the Attachments in ERP According to Users Need?

If User Want To show attachments in form view,

attachment

Above Screen will make you more clear.
Suppose, you have Two attachments & want to show in another One2many field.
Then you should have One notebook page as Attached Document and attachment_ids as one2many. In that one2many, attachments will be shown by that attachment button.

Field in project.task class should be as follow:

‘attachment_ids’: fields.one2many(‘ir.attachment’, ‘res_id’, domain=lambda self: [(‘res_model’, ‘=’, self._name)], auto_join=True, string=’Attachments’),

and inverse field should be as follow:

‘res_id’:fields.integer() in r.attachment class

To Show Attachment in One2many, write the following view:

<page string=”Attached Documents”>
<p>
Add attachments using above Attachment(s) button.
</p>
<group string=”Attached Documents”>
<field name=”attachment_ids” mode=”kanban” nolabel =”1″>
<kanban create=”0″>
<field name=”id”/>
<field name=”mimetype”/>
<field name=”type”/>
<field name=”datas_fname”/>
<field name=”name”/>
<templates>
<t t-name=”kanban-box”>
<div class=”oe_kanban_global_click” style=”flex:None; height:160px; width:190px; box-shadow:0px 0px 1px 1px #6F6F6F;”>
<div class=”oe_kanban_vignette”>
<div class=”oe_attachment”>
<div class=”oe_name”>
<field name=”name”/>
</div>
<div t-if=”record.type.raw_value == ‘binary'”>
<a t-attf-href=”/web/content/#{record.id.value}?download=1″>
<t t-set=”webimage” t-value=”new RegExp(‘image.*(gif|jpeg|jpg|png)’).test(record.mimetype.value)”/>
<div t-if=”!webimage” class=”o_image” t-att-data-mimetype=”record.mimetype.value”/>
<div t-if=”webimage” class=”o_kanban_attachment_image”>
<img t-attf-src=”/web/image/#{record.id.value}?download=1″/>
</div>
</a>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</group>
</page>

In above kanban view, you can show another fields that you want to display. Here we have taken limited value in kanban view according to our need. For further information contact us