跳至内容
菜单
此问题已终结
2 回复
3069 查看

I need a new field in res.partner for account number. The number should only belong to one contact and must be created manually (no sequencing). How do we get a uniqueness check on that field to prevent duplicate entries and warn the user that the value already exists?

形象
丢弃
最佳答案

Hello, would you by any chance know the python code to use ?

Thanks a lot.

形象
丢弃

Hi,

You can use sql constraints.
_sql_constraints = [('name_uniq', "unique(name, applicability, country_id)", "A tag with the same name and applicability already exists in this country.")]

最佳答案

Hi,

You can create an automated action in the database, that is getting triggered on writing or creating record in this model and you can raise warning if duplicates are found.


Check whether base_automation module is installed in the database, if not install it, then keeping the developer mode activated, navigate to Automated Actions menu under the settings and create a new record here, select triggered on Create & Update and execute a python code, that check and raises the warning.

Thanks

形象
丢弃
相关帖文 回复 查看 活动
1
2月 22
3623
1
12月 24
2564
0
12月 21
2202
4
3月 15
11881
2
8月 24
9633