Odooers论坛

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Limiting field size in V14 onwards

形象
odoo
形象
丢弃
2 答案
0
形象
odoo
最佳答案

Interesting update. I actually tried adding back size attribute to a field in V15 and it works without issue or any warning in the log! I was surprised as I took the advice from an OCA article https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-14.0.

However I can see that even in V16 there are still many uses of the size attribute used on char fields, for example:
https://github.com/odoo/odoo/blob/16.0/addons/l10n_de/models/datev.py

Anyone know if Odoo backtracked on this plan and it's no longer relevant?

形象
丢弃
0
形象
odoo
最佳答案

HI Chris Mann, 
Second option will be try to add constraints and check length of the char field in its method. You can raise exception for the size exceed. 

If you want to automatically crop it to 18 char , then you have to follow the string slicing. But on you case its related field , so might be automatically cropped will not work.
Hope it will help you. 

1 备注
形象
丢弃
形象
odoo
-

Thanks Malay.
Unfortunately I don't think those options will work.
The field is used as part of an export template to CSV file and needs to have the limit applied when exported so that the field length is limited.
It's to export to a bank formatted CSV for payments that has strict rules on length.