Skip to content

Commit

Permalink
[FIX] partner_company_type: make unique constraint dependent on country
Browse files Browse the repository at this point in the history
  • Loading branch information
len-foss committed Dec 5, 2024
1 parent 0e0d847 commit 005918e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions partner_company_type/models/res_partner_company_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,15 @@ class ResPartnerCompanyType(models.Model):
"Leave it blank if you want it to appear on any partner.",
)

_sql_constraints = [('name_uniq', 'unique (name)',
"Partner Company Type already exists!")]
_sql_constraints = [
(
'name_country_uniq',
'unique (name, country_id)',
"Partner Company Type already exists for this country!"
),
(
"unique_name_null_country_id",
"EXCLUDE (name WITH =) WHERE (country_id IS NULL)",
"Shared Partner Company Type already exists!"
),
]

0 comments on commit 005918e

Please sign in to comment.