|
@ -1,25 +1,25 @@ |
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
# © 2016 Akretion (http://www.akretion.com) |
|
|
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|
|
|
|
|
|
|
|
# Copyright 2016 Akretion (http://www.akretion.com) |
|
|
|
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
|
|
# @author Alexis de Lattre <alexis.delattre@akretion.com> |
|
|
# @author Alexis de Lattre <alexis.delattre@akretion.com> |
|
|
|
|
|
|
|
|
from odoo import models, fields, api |
|
|
|
|
|
import re |
|
|
import re |
|
|
|
|
|
|
|
|
|
|
|
from odoo import api, fields, models |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ResPartner(models.Model): |
|
|
class ResPartner(models.Model): |
|
|
_inherit = 'res.partner' |
|
|
_inherit = 'res.partner' |
|
|
|
|
|
|
|
|
sanitized_vat = fields.Char( |
|
|
sanitized_vat = fields.Char( |
|
|
compute='compute_sanitized_vat', string='Sanitized TIN', |
|
|
|
|
|
|
|
|
compute='_compute_sanitized_vat', string='Sanitized TIN', |
|
|
store=True, readonly=True, |
|
|
store=True, readonly=True, |
|
|
help='TIN in uppercase without spaces nor special caracters.') |
|
|
help='TIN in uppercase without spaces nor special caracters.') |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
def _sanitize_vat(self, vat): |
|
|
def _sanitize_vat(self, vat): |
|
|
return vat and re.sub(r'\W+', '', vat).upper() or False |
|
|
return vat and re.sub(r'\W+', '', vat).upper() or False |
|
|
|
|
|
|
|
|
@api.multi |
|
|
|
|
|
@api.depends('vat') |
|
|
@api.depends('vat') |
|
|
def compute_sanitized_vat(self): |
|
|
|
|
|
|
|
|
def _compute_sanitized_vat(self): |
|
|
for partner in self: |
|
|
for partner in self: |
|
|
partner.sanitized_vat = self._sanitize_vat(partner.vat) |
|
|
partner.sanitized_vat = self._sanitize_vat(partner.vat) |