Pre-validate identifier code

issue5357
review17091002
This commit is contained in:
Cédric Krier
2016-03-05 17:27:36 +01:00
parent f9cb8c8999
commit dd8278aefd
2 changed files with 9 additions and 7 deletions
+8 -6
View File
@@ -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,
})
+1 -1
View File
@@ -25,7 +25,7 @@ this repository contains the full copyright notices and license terms. -->
view_ids="party.category_view_list"/>
</page>
<page name="identifiers">
<field name="identifiers" colspan="4"/>
<field name="identifiers" colspan="4" pre_validate="1"/>
</page>
</notebook>
</form>