You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
785 B
25 lines
785 B
# -*- coding: utf-8 -*-
|
|
# © 2016 Akretion (http://www.akretion.com)
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
|
|
|
from openerp import models, fields, api
|
|
import re
|
|
|
|
|
|
class ResPartner(models.Model):
|
|
_inherit = 'res.partner'
|
|
|
|
sanitized_vat = fields.Char(
|
|
compute='_compute_sanitized_vat', string='Sanitized TIN',
|
|
store=True, readonly=True,
|
|
help='TIN in uppercase without spaces nor special caracters.')
|
|
|
|
def _sanitize_vat(self, vat):
|
|
return vat and re.sub(r'\W+', '', vat).upper() or False
|
|
|
|
@api.multi
|
|
@api.depends('vat')
|
|
def _compute_sanitized_vat(self):
|
|
for partner in self:
|
|
partner.sanitized_vat = self._sanitize_vat(partner.vat)
|