[IMP] base_vat: added a button on the partner form view to directly check the VAT...
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Wed, 8 Feb 2012 15:26:47 +0000 (16:26 +0100)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Wed, 8 Feb 2012 15:26:47 +0000 (16:26 +0100)
bzr revid: qdp-launchpad@openerp.com-20120208152647-b6xr5rq6kdpk4sxq

addons/base_vat/base_vat.py
addons/base_vat/base_vat_view.xml

index c773300..7b8363f 100644 (file)
@@ -104,6 +104,11 @@ 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)
+
     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 +117,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
index fa53906..18480b4 100644 (file)
@@ -9,7 +9,8 @@
             <field name="arch" type="xml">
                 <field name="property_account_payable" position="after">
                     <group colspan="2" col="6">
-                        <field name="vat" on_change="vat_change(vat)" colspan="4" />
+                        <field name="vat" on_change="vat_change(vat)"/>
+                        <button name="button_check_vat" string="Check VAT" type="object" icon="gtk-execute"/>
                         <field name="vat_subjected" colspan="1" groups="base.group_extended" />
                     </group>
                 </field>