From 19939c4d5f95ff50de4ff31d5a1d54fa1461d04f Mon Sep 17 00:00:00 2001 From: Albert Cervera i Areny Date: Thu, 7 Mar 2013 16:54:45 +0100 Subject: [PATCH] Replace _constraints with validate in ModelStorage and improve user messages. issue2616 review371002 --- company.py | 12 +++++------- company.xml | 10 ++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/company.py b/company.py index 529b63088f..f43b59dd72 100644 --- a/company.py +++ b/company.py @@ -30,13 +30,11 @@ class Company(ModelSQL, ModelView): @classmethod def __setup__(cls): super(Company, cls).__setup__() - cls._constraints += [ - ('check_recursion', 'recursive_companies'), - ] - cls._error_messages.update({ - 'recursive_companies': ( - 'You can not create recursive companies!'), - }) + + @classmethod + def validate(cls, companies): + super(Company, cls).validate(companies) + cls.check_recursion(companies) @classmethod def copy(cls, companies, default=None): diff --git a/company.xml b/company.xml index 9891cdfba0..cf540e9ad2 100644 --- a/company.xml +++ b/company.xml @@ -391,5 +391,15 @@ this repository contains the full copyright notices and license terms. --> party.party,-1 + + + company.company + en_US + error + recursion_error + Recursion error: Company "%(rec_name)s" with parent "%(parent_rec_name)s" was configured as ancestor of itself. + company + +