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

Đang mở
#1,112 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@fdardenne đang làm issue này rồi.

Từ ngày 5/1/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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?

Ngôn ngữ chính
Python
Star
182
Fork
3.4k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của odoo/tutorials

Tất cả issue của odoo/tutorials

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.