Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
6837 Vues

Hello, I am having some issues trying to show images in my kanban view. I attach my code below, both, my model and my XML for the kanban view.

Model:

# -*- coding: utf-8 -*-

from odoo import models, fields, api

class Libro(models.Model):
_name = 'libro'

image = fields.Binary(attachment=True)
name = fields.Char(string="Título")
autor = fields.Many2one("autores", string="Autor")
paginas = fields.Integer (string="Número de páginas")
isbn = fields.Char(string="ISBN")
catego = fields.Many2one ("categorias", string="Género")
fecharetirada = fields.Date(string="Fecha de Retirada")

XML:

<record model="ir.ui.view" id="libro_kanban_view">
<field name="name">libro.kanban.view</field>
<field name="model">libro</field>
<field name="type">kanban</field>
<field name="arch" type="xml">
<kanban>
<field name="image"/>
<field name="name"/>
<field name="autor"/>
<field name="isbn"/>
<field name="paginas"/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_vignette oe_semantic_html_override" style="background-color:#ff8800; border-radius:18px; border: 2px solid #7600d1">
<img t-att-src="kanban_image('libro','image',record.image.value)" class="oe_resource_picture"/>
<div class="oe_kanban_details">
<h4>
<a type="open">
<t><font color="#7600d1"><field name="name"/></font></t> <font color="#a700d1">[<field name="isbn"/>]</font>
</a>
</h4>
<div name="tags"/>
<ul>
<li><font color="#7600d1"><b>Autor:</b></font> <font color="white"><field name="autor"/></font></li>
<li><font color="#7600d1"><b>Número de páginas:</b></font> <font color="white"><field name="paginas"/></font></li>
</ul>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>

The thing is that I have seen many people using "record.id.value", but I don't know what it is, and I get an error if use it.

Thanks.

Avatar
Ignorer
Meilleure réponse

Hi,

Please see the sample of how the image is shown in the kanban view of the Employees,

In the python,

image_medium = fields.Binary("Medium-sized photo", attachment=True)


Then in the Kanban View,

<div class="o_kanban_image">
<img t-att-src="kanban_image('hr.employee', 'image_medium', record.id.raw_value)"/>
<div class="o_employee_summary_icons">
<t t-if="record.message_needaction_counter.raw_value">
<span class='oe_kanban_mail_new' title='Unread Messages'><i class='fa fa-comments'/><t t-raw="record.message_needaction_counter.raw_value"/></span>
</t>
<span title='Messages'><i class='fa fa-comments'/><t t-esc="record.message_ids.raw_value.length"/></span>
<span title='Followers'><i class='fa fa-users'/><t t-esc="record.message_follower_ids.raw_value.length"/></span>
</div>
</div>


Thanks

Avatar
Ignorer
Publications associées Réponses Vues Activité
2
mai 20
5877
0
janv. 19
5884
1
mars 15
6258
0
mars 15
5139
1
mars 15
17612