Skip to Content
Menu
This question has been flagged

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?

Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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?

Related Posts Replies Views Activity
2
Mar 25
414
1
Feb 25
480
0
Dec 24
434
1
Dec 24
1073
0
Dec 24
862