Skip to Content
Menu
This question has been flagged
1 Reply
2158 Views

i have 3 binary fields where the users upload documents, how can i do for view all documents in my smart button?

camp1= fields.Binary()

camp2= fields.Binary() 

camp3= fields.Binary()

Avatar
Discard
Best Answer

Hi

You can try this code

<odoo>
    <data>
        <record id="button_id" model="ir.ui.view">
 
          <field name="name">model.view.form</field>
 
          <field name="model">http://model.name" target="_blank">model.name</field>
            <field name="arch" type="xml">
                <div name="button_box" position="inside">
                    <button class="oe_stat_button" type="object" name="button_name"
                        icon="">
                        <field string="Attachment" name="attathment_count" widget="statinfo"/>
                    </button>
                </div>
            </field>
        </record>
    </data>
</odoo>

you need to add a many2one field for relates the attahcment module like
attachment_ids = fields.Many2many(
        comodel_name='ir.attachment'
    )
class search(models.Model):
    _inherit = 'model_name'
    def button_name(self):
        self.ensure_one()
        return {
            'type': 'ir.actions.act_window',
            'name': 'Attachment',
            'view_mode': 'tree',
            'res_model': 'ir.attachment',
            'domain': [('id', 'in' http://attachment_ids.id" target="_blank">attachment_ids.id)],
            'context': "{'create': False}"
        }     

Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
1
Jun 25
857
3
May 25
2589
1
May 25
826
1
May 25
1007
4
May 25
2289