Hello, I'm trying to add the attribute maxlength="100" to the description field in the products form.
I've done an inheritance and also modified 'placeholder' value and added a new class 'border' to the element.
But I'n not able to define maxlength=10.
Here is the code:
![]()
What am I missing?
Thanks for your help.
P.S.: Sorry for the screenshot, I've tried to copy the code but it always appeared incomplete.
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ờ
Hello Victor,
I don't know this is right way or not but you can recreate name field with size in .py file by inheriting model.
name = fields.Char('Name', index=True, required=True, translate=True, size=10)
Thanks.
Hi Siddharth,
If I understand correctly your solution, it will overwrite the field size definition but what I'm trying to do it's to avoid the user to enter strings longer than the maxlenght defined, in the frontend.
Also I want to understand why I cannot define a valid html attribute from a view.
P.S. thanks for your answer.
Hi Siddhartd,
at the end I've programmed a Python constrain to solve the problem:
@api.constrains('name')
def _check_description(self):
for description in self:
if len(description.name) > 100:
raise ValidationError("El campo descripción debe tener 100 caracteres como máximo.")
Thanks for your help.
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 5 22
|
2906 | ||
|
2
thg 8 19
|
20170 | ||
|
1
thg 11 24
|
1781 | ||
|
5
thg 7 24
|
93275 | ||
|
1
thg 12 23
|
3157 |