Comment 6 for bug 567216

Revision history for this message
Borja López Soilán (NeoPolus) (borjals) wrote :

Carlos, we usually go with the "autocomplete" way for our clients. If they type a VAT without starting characters we just add them using an on_change method:

    def onchange_vat(self, cr, uid, ids, vat):
        """
        Método que comprueba el NIF/CIF y añade el prefijo ES en caso necesario
        """
        if vat:
            if not re.match(r'[a-zA-Z]{2}.+', vat):
                vat = "ES%s" % vat.upper()
            return { 'value': { 'vat': vat, 'vat_subjected': True } }
        return { 'value': { 'vat_subjected': False } }