X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=addons%2Fbase_vat%2Fbase_vat.py;h=51c1663d3662ea70b4070ca520de8977996fb01f;hb=117bf937b9b9489718a46ad5d6a967110ee5c3f7;hp=c77330079893943e485f334e37239c2fde9499e3;hpb=6dc7b56a6d38d858335ca21e25042865c5fd342d;p=odoo%2Fodoo.git diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index c773300..51c1663 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -23,11 +23,12 @@ import logging import string import datetime import re +_logger = logging.getLogger(__name__) try: import vatnumber except ImportError: - logging.getLogger('base_vat').warning("VAT validation partially unavailable because the `vatnumber` Python library cannot be found. " + _logger.warning("VAT validation partially unavailable because the `vatnumber` Python library cannot be found. " "Install it to support more countries, for example with `easy_install vatnumber`.") vatnumber = None @@ -104,6 +105,12 @@ class res_partner(osv.osv): # country code or empty VAT number), so we fall back to the simple check. return self.simple_vat_check(cr, uid, country_code, vat_number, context=context) + def button_check_vat(self, cr, uid, ids, context=None): + if not self.check_vat(cr, uid, ids, context=context): + msg = self._construct_constraint_msg(cr, uid, ids, context=context) + raise osv.except_osv(_('Error!'), msg) + return True + def check_vat(self, cr, uid, ids, context=None): user_company = self.pool.get('res.users').browse(cr, uid, uid).company_id if user_company.vat_check_vies: @@ -112,7 +119,6 @@ class res_partner(osv.osv): else: # quick and partial off-line checksum validation check_func = self.simple_vat_check - for partner in self.browse(cr, uid, ids, context=context): if not partner.vat: continue