跳至內容
選單
此問題已被標幟
1 回覆
2474 瀏覽次數

In Odoo 17.0 (on-premise), I'm wondering if there's some way to limit the characters that can be entered into the text and multi-line text fields?

I'm finding that some customers are entering too much text in some fields, enough so that the text begins to overlap the next field, and the final document is difficult to read.  I've noticed that for multi-line text fields, this is accentuated if the person signing the field has the zoom setting in their browser much lower than 100%, because the size of the text does not scale in line with the zoom setting.

Limiting the characters that can be entered in a field is one way I've thought that might help reduce the chances of this happening.

Is there some way to customize the fields, either directly or with development of a customization module?

頭像
捨棄
最佳答案

Hello Bill Ennals,

To limit the characters in a Text field (fields.Text) in Odoo 17.0, you'll need to create a constraint in a custom module, as Text fields don't inherently have a character limit option.


code : 

@api.constrains('x_custom_text_field')

 def _check_text_field_length(self):

  ​for record in self: if record.x_custom_text_field and len(record.x_custom_text_field) > 500: # Set your desired limit 

​​raise ValidationError("The text is too long. Please limit it to 500 characters.")


Hope this helps!

Thanks & Regards,

Name : Yahoo Baba

Email:  yahoobaba077@gmail.com

頭像
捨棄
作者

Thanks for the prompt reply Yahoo Baba. Do you think the 'Text' fields in Odoo Sign are actually standard text fields though? It seems to me that each field that can receive input in Odoo Sign is a model record (sign.item) in itself, but I can't figure out where/how the entered text is stored. I would guess in the database, but perhaps not...perhaps in an attachment on the sign.item record?

Can anyone else enlighten me?

相關帖文 回覆 瀏覽次數 活動
1
8月 25
2352
2
8月 25
951
2
3月 25
1827
1
11月 25
2389
0
8月 25
1559