Replace _constraints with validate in ModelStorage and improve user messages.
issue2616 review371002
This commit is contained in:
1 parent
9fa6fc19da
commit
19939c4d5f
2 files changed
+15
-7
No files matched your search
+5
-7
@@ -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):
|
||||
|
||||
+10
@@ -391,5 +391,15 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="model">party.party,-1</field>
|
||||
<field name="action" ref="report_letter"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.translation" id="company_recursion_error">
|
||||
<field name="name">company.company</field>
|
||||
<field name="lang">en_US</field>
|
||||
<field name="type">error</field>
|
||||
<field name="src">recursion_error</field>
|
||||
<field name="value">Recursion error: Company "%(rec_name)s" with parent "%(parent_rec_name)s" was configured as ancestor of itself.</field>
|
||||
<field name="module">company</field>
|
||||
<field name="fuzzy" eval="False"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
Reference in new issue
Block a user