Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
3081 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.พ. 22
3631
Restrict Studio ,to users แก้ไขแล้ว
1
ธ.ค. 24
2566
0
ธ.ค. 21
2205
4
มี.ค. 15
11886
2
ส.ค. 24
9652