openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #05743
[Merge] lp:~openerp-dev/openobject-addons/trunk-bug-749958-xrg into lp:openobject-addons
xrg has proposed merging lp:~openerp-dev/openobject-addons/trunk-bug-749958-xrg into lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
Related bugs:
Bug #749958 in OpenERP Addons: "[trunk] [base_vat] [base_vat_mx]: Wrong validation"
https://bugs.launchpad.net/openobject-addons/+bug/749958
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-749958-xrg/+merge/58487
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-749958-xrg/+merge/58487
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-bug-749958-xrg.
=== modified file 'base_vat/base_vat.py'
--- base_vat/base_vat.py 2011-02-11 11:29:07 +0000
+++ base_vat/base_vat.py 2011-04-20 12:25:53 +0000
@@ -23,6 +23,8 @@
from osv import osv, fields
from tools.translate import _
+import re
+import datetime
_ref_vat = {
'be': 'BE0477472701', 'at': 'ATU12345675',
@@ -39,7 +41,7 @@
'pt': 'PT123456789', 'ro': 'RO1234567897',
'se': 'SE123456789701', 'si': 'SI12345679',
'sk': 'SK0012345675', 'el': 'EL12345670',
- 'mx': 'MXABC123456T1B'
+ 'mx': 'MXABCD831230T1B',
}
@@ -1066,17 +1068,29 @@
return False
return True
- def check_vat_mx(self, vat):
- '''
- Verificar RFC méxico
- '''
- if not 12 <= len(vat) <= 13:
- return False
- elif len(vat)==12 and not vat[:3].isalpha() | vat[3:9].isdigit() | vat[-3:].isalnum():
- return False
- elif len(vat)==13 and not vat[:4].isalpha() | vat[4:10].isdigit() | vat[-3:].isalnum():
- return False
+ __check_vat_mx_re = re.compile(r"(?P<primeras>[A-Z&ñÃ]{3,4})" \
+ r"[ \-_]?" \
+ r"(?P<ano>[0-9]{2})(?P<mes>[01][1-9])(?P<dia>[0-3][0-9])" \
+ r"[ \-_]?" \
+ r"(?P<code>[A-Z0-9&ñÃ\xd1\xf1]{3})$")
+
+ def check_vat_mx(vat):
+ ''' Mexican VAT verification
+
+ Verificar RFC México
+ '''
+ m = self.__check_vat_mx_re.match(vat)
+ if not m:
+ #No valid format
+ return False
+ try:
+ datetime.date(int(m.group('ano')), int(m.group('mes')), int(m.group('dia')))
+ except ValueError:
+ return False
+
+ #Valid format and valid date
return True
+
res_partner()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Follow ups