Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2597 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
oct 25
2874
1
sept 25
2870
3
jul 25
4208
1
may 25
2302
4
may 25
3663