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

オープン
#1,112 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@fdardenne がすでに取り組んでいます。

2026年1月5日 から。

評価

この issue はまだ評価されていません。

説明

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?

主要言語
Python
スター
182
フォーク
3.4k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

odoo/tutorials のほかの issue

odoo/tutorials の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。