From dd8278aefdf449ecb32066254e97eb18628cdf0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 5 Mar 2016 17:27:36 +0100 Subject: [PATCH] Pre-validate identifier code issue5357 review17091002 --- party.py | 14 ++++++++------ view/party_form.xml | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/party.py b/party.py index e8af125e35..69b5e766c4 100644 --- a/party.py +++ b/party.py @@ -295,18 +295,20 @@ class PartyIdentifier(ModelSQL, ModelView): pass return self.code - @classmethod - def validate(cls, identifiers): - super(PartyIdentifier, cls).validate(identifiers) - for identifier in identifiers: - identifier.check_code() + def pre_validate(self): + super(PartyIdentifier, self).pre_validate() + self.check_code() def check_code(self): if self.type == 'eu_vat': if not vat.is_valid(self.code): + if self.party.id > 0: + party = self.party.rec_name + else: + party = '' self.raise_user_error('invalid_vat', { 'code': self.code, - 'party': self.party.rec_name, + 'party': party, }) diff --git a/view/party_form.xml b/view/party_form.xml index 2410fa68d8..241228ba40 100644 --- a/view/party_form.xml +++ b/view/party_form.xml @@ -25,7 +25,7 @@ this repository contains the full copyright notices and license terms. --> view_ids="party.category_view_list"/> - +