Error in solution for "2.3. Add a dashboard item"

Abierto
#1,112 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@fdardenne ya está trabajando en esto.

Desde el 5/1/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

Hi,

The assignment has us create a dashboard item, with optional size prop, that should default to 1. That should be reflected in the size of the displayed element.

This is the solution provided: dashboard_item.js
And it's used like this in the Dashboard: dashboard.xml

However, if the prop isn't provided, this is what appears:
<div class="card m-2 border-dark" style="width: NaNrem;"><div class="card-body">some content </div></div>

It looks like I'm not imagining this since it appears to be included in the relevant screenshot as well:

https://www.odoo.com/documentation/18.0/_images/dashboard_item.png

If the elements containing "some content" truly were 18rem wide, they'd be about half of what the element containing "I love milk" is.

I solved it myself by adding setup() in DashboardItem:
setup() { this.size = 1; if(this.props.size && this.props.size > 0) { this.size = this.props.size; } }

And adjusting line 5 in dashboard_item.xml:
<div class="card d-inline-block m-2" t-attf-style="width: {{18*size}}rem;">

Is there a way to make it work with the default value for the size prop though?

Lenguaje dominante
Python
Estrellas
182
Forks
3.4k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de odoo/tutorials

Todos los issues de odoo/tutorials

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.