Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
3096 Vizualizări

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?

Imagine profil
Abandonează
Cel mai bun răspuns

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

Thanks a lot.

Imagine profil
Abandonează

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.")]

Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
feb. 22
3638
1
dec. 24
2575
0
dec. 21
2216
4
mar. 15
11889
2
aug. 24
9682