details: https://code.tryton.org/tryton/commit/8a062bb4f22e
branch: default
user: Cédric Krier <[email protected]>
date: Wed Oct 01 10:17:22 2025 +0200
description:
Make each company's party unique
diffstat:
modules/company/company.py | 9 +++++++++
modules/company/message.xml | 3 +++
2 files changed, 12 insertions(+), 0 deletions(-)
diffs (32 lines):
diff -r 5eb9ccb5f3f6 -r 8a062bb4f22e modules/company/company.py
--- a/modules/company/company.py Wed Oct 01 10:16:47 2025 +0200
+++ b/modules/company/company.py Wed Oct 01 10:17:22 2025 +0200
@@ -72,6 +72,15 @@
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 -r 5eb9ccb5f3f6 -r 8a062bb4f22e modules/company/message.xml
--- a/modules/company/message.xml Wed Oct 01 10:16:47 2025 +0200
+++ b/modules/company/message.xml Wed Oct 01 10:17:22 2025 +0200
@@ -3,6 +3,9 @@
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
+ <record model="ir.message" id="msg_company_party_unique">
+ <field name="text">A party can only be assigned to one
company.</field>
+ </record>
<record model="ir.message" id="msg_company_logo_cache_size_unique">
<field name="text">The size of cached company logo must be
unique.</field>
</record>