Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2901 Lượt xem

Hi,

priority

The product name is too long. I want to print the first 10 characters in the output. What is HTML Qweb code?



Thanks.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello this is Gulshan Negi

Well, you can do this by using the code below.


< span t-field = "product.name" t-options = '{"widget": "text", "options": {"widget": "text", "truncate": 10}}' / >

I hope it will work.

Thank you

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

You can limit the length of characters of field from python using size attribute.

For that, inherit product.template model and override the name field and give attribute size=10

class ProductTemplate(models.Model):
_inherit = "product.template"
name = fields.Char('Name', index='trigram', required=True, translate=True, size=10)

Regards

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 4 18
5088
0
thg 6 25
790
1
thg 8 17
6337
0
thg 8 15
7563
1
thg 3 15
5723