Contributors mailing list archives

contributors@odoo-community.org

Avatar

Re: Any module that verify numbers, i.e., employee's citizen ID

by
Ecosoft Co. Ltd., Kitti Upariphutthiphong
- 16/02/2021 16:04:09
Thank you everyone for the advice / suggestions.

On Thu, Feb 11, 2021 at 7:17 PM Daniel Reis <dreis@opensourceintegrators.com> wrote:
Hello Ruben,

AFAIK VAT number validation is out of the box in Odoo.

For specific country ID numbers, that be be a different case.
For these, I invite controibutions to the appropriate l10n_* OCA repository: https://github.com/OCA?q=l10n

Thanks
Daniel

On 11/02/2021 11:46, Rubén Seijas wrote:
Hi,

Maybe can this help.

https://pypi.org/project/python-stdnum/
 
And then use something like this 
 
import stdnum.eu.vat
 
def check_vat(self, vat):
        """
        Check VAT on create partner
        vat : VAT string
        """
        _LOG.info("Checking VAT number: %s", vat)
        if stdnum.eu.vat.is_valid(vat):
            _LOG.info("VAT %s is valid", vat)
            return vat
        else:
            _LOG.info("VAT not valid, detecting VAT Country...")
            vat_country = stdnum.eu.vat.guess_country(vat)
            if vat_country:
                vat = vat_country[0].upper() + vat
                _LOG.info("Country + VAT = %s, checking is valid", vat)
                stdnum.eu.vat.validate(vat)
                _LOG.info('VAT is valid: %s', vat)
                return vat
            else:
                raise stdnum.eu.vat.ValidationError(
                    'All checks have failed on VAT {}'.format(vat))
                return vat

Regards!

Rubén Seijas
Analista Programador
Tfno: 982 81 48 05 Ext: 104



El jue, 11 feb 2021 a las 11:57, Torvald Baade Bringsvor (<bringsvor@bringsvor.com>) escribió:
Hi

I made a module a couple of years ago for this requirement:


This validates the number entered to the rules for the Norwegian number (modulo 10) checksum) AFAIK.

But you are right, this is a common requirement for many countries.

-Torvald



tor. 11. feb. 2021 kl. 06:27 skrev Kitti Upariphutthiphong <kittiu@ecosoft.co.th>:
Dear community,

I have a requirement to validate hr.employee's citizen ID format in my country, but I think it would be nicer if we can just extend some base modules to be more generic.

So far, I found this, https://github.com/OCA/partner-contact/tree/13.0/partner_identification, which can verify numbers but onlty to res.partner.

Are the more generic base module to be used with other models yet, (or at least for hr.employee)

Thank you,
Kitti


_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe


--
Daniel Reis
Managing Director
M: +351 919991307
E: DReis@OpenSourceIntegrators.com
Av Doutor Desidério Cambournac 12 • 2710-553 Sintra, Portugal


_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

Reference