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

未关闭
#1,112 0 条评论 0 个 reaction 已指派 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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

odoo/tutorials 的其他 Issue

查看 odoo/tutorials 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。