From f32669b0860a798a98615b5d56ccaa4b1876c392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 1 Oct 2025 10:17:22 +0200 Subject: [PATCH] Make each company's party unique --- modules/company/company.py | 9 +++++++++ modules/company/message.xml | 3 +++ 2 files changed, 12 insertions(+) diff --git a/modules/company/company.py b/modules/company/company.py index a59516ceeb..b623ceca86 100644 --- a/modules/company/company.py +++ b/modules/company/company.py @@ -72,6 +72,15 @@ class Company(ModelSQL, ModelView): help="Uses the first identifier that matches the criteria.\n" "If none match, uses the party's tax identifier.") + @classmethod + def __setup__(cls): + super().__setup__() + t = cls.__table__() + cls._sql_constraints += [ + ('party_unique', Unique(t, t.party), + 'company.msg_company_party_unique'), + ] + @property def header_used(self): return Template(self.header or '').safe_substitute(self._substitutions) diff --git a/modules/company/message.xml b/modules/company/message.xml index f69d76290c..0a2d5732fb 100644 --- a/modules/company/message.xml +++ b/modules/company/message.xml @@ -3,6 +3,9 @@ this repository contains the full copyright notices and license terms. --> + + A party can only be assigned to one company. + The size of cached company logo must be unique.