Browse Source

[11.0][MIG] Port base_vat_sanitized to V11

pull/639/head
Andrea 6 years ago
parent
commit
1cabb40cd0
  1. 13
      base_vat_sanitized/README.rst
  2. 2
      base_vat_sanitized/__init__.py
  3. 9
      base_vat_sanitized/__manifest__.py
  4. 2
      base_vat_sanitized/models/__init__.py
  5. 14
      base_vat_sanitized/models/res_partner.py
  6. 2
      base_vat_sanitized/tests/__init__.py
  7. 5
      base_vat_sanitized/tests/test_vat.py

13
base_vat_sanitized/README.rst

@ -1,5 +1,5 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
==================
@ -8,11 +8,6 @@ Base VAT Sanitized
This module adds a technical field *sanitized_vat* on partners that stores the VAT number without spaces and with letters in uppercase. It is useful for other modules that need to match partners on VAT number, such as the *base_business_document_import* module for example.
Configuration
=============
No configuration is needed.
Usage
=====
@ -20,7 +15,7 @@ This module doesn't bring any visible feature for the users.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/134/10.0
:target: https://runbot.odoo-community.org/runbot/134/11.0
Bug Tracker
@ -29,7 +24,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/partner-contact/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.
help us smash it by providing detailed and welcomed feedback.
Credits
=======

2
base_vat_sanitized/__init__.py

@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models

9
base_vat_sanitized/__manifest__.py

@ -1,16 +1,15 @@
# -*- 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>
{
'name': 'Base VAT Sanitized',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'category': 'Hidden/Dependency',
'license': 'AGPL-3',
'summary': 'Adds field sanitized_vat on partners',
'author': 'Akretion,Odoo Community Association (OCA)',
'website': 'http://www.akretion.com',
'website': 'https://github.com/OCA/partner-contact',
'depends': ['base_vat'],
'installable': True,
}

2
base_vat_sanitized/models/__init__.py

@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import res_partner

14
base_vat_sanitized/models/res_partner.py

@ -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>
from odoo import models, fields, api
import re
from odoo import api, fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
sanitized_vat = fields.Char(
compute='compute_sanitized_vat', string='Sanitized TIN',
compute='_compute_sanitized_vat', string='Sanitized TIN',
store=True, readonly=True,
help='TIN in uppercase without spaces nor special caracters.')
@classmethod
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):
def _compute_sanitized_vat(self):
for partner in self:
partner.sanitized_vat = self._sanitize_vat(partner.vat)

2
base_vat_sanitized/tests/__init__.py

@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import test_vat

5
base_vat_sanitized/tests/test_vat.py

@ -1,6 +1,5 @@
# -*- 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>
from odoo.tests.common import TransactionCase

Loading…
Cancel
Save