Hi,
I'm trying to add a decoration to a badge in widget in a list view.
I have it working on a default view using this:
field name="status" widget="badge" decoration-success= "status == 'Done'"
But when I'm trying to use in on another view using xpath, I'm not able to get it right. I think that should be something like this:
xpath expr="//field[@name='status']" position="attributes"
attribute name="widget">badge attribute
attribute name="decoration-success"> [['status','=','Done']] attribute
xpath
Any suggestions?
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi,
I would recommand that you create a related and stored field:
status_name = field.Char(related='status.name', store=True, copy=False)
and then in your xml you put this:
widget="badge" decoration-success = " status_name == ' Done' "
Hope this helps.
Upvote if it does.
Hi Ibrahim,
Thanks for the answer. I was aware of using a char field to hold the value, but I was trying to figure out if there was any option to use the information from the Many2One field to use on the Badge Attribute. I dont know if it is even possible.
Hi Ibrahim,
I couldnt find any better alternative. Im going to close it and use your answer. I was trying to avoid creating more fields.
Thanks
Your XPath override should look like this
<xpath expr="//field[@name='status']" position="attributes">
<attribute name="widget">badge</attribute>
<attribute name="decoration-success">status == 'Done'</attribute>
<xpath>
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
2
thg 8 20
|
3367 | ||
|
0
thg 2 16
|
5627 | ||
|
0
thg 10 21
|
3955 | ||
|
1
thg 4 16
|
4406 | ||
|
1
thg 8 25
|
489 |
I had to remove the symbols < > / because it was modifing the description. Sorry for that
Status is a ManytoOne field. It works with a selection field, but it doesnt with a ManytoOne field. I tried some alternatives like:
status.name == 'Done'
status.id == 13
But i get an error with any of these
Decoration in Tree View: https://learnopenerp.blogspot.com/2022/05/decorate-text-bold-italic-colors-field-in-tree-view-column-odoo-15.html