Browse Source
Merge pull request #364 from hbrunn/9.0-base_sanitize_vat
Merge pull request #364 from hbrunn/9.0-base_sanitize_vat
[ADD] migration of base_vat_sanitizedpull/412/head
Pedro M. Baeza
8 years ago
committed by
GitHub
9 changed files with 197 additions and 0 deletions
-
59base_vat_sanitized/README.rst
-
3base_vat_sanitized/__init__.py
-
16base_vat_sanitized/__openerp__.py
-
34base_vat_sanitized/i18n/es.po
-
34base_vat_sanitized/i18n/sl.po
-
3base_vat_sanitized/models/__init__.py
-
25base_vat_sanitized/models/res_partner.py
-
3base_vat_sanitized/tests/__init__.py
-
20base_vat_sanitized/tests/test_vat.py
@ -0,0 +1,59 @@ |
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
|||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
================== |
|||
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 *account_invoice_import* module for example. |
|||
|
|||
Configuration |
|||
============= |
|||
|
|||
No configuration is needed. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
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/9.0 |
|||
|
|||
|
|||
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 |
|||
<https://github.com/OCA/ |
|||
partner-contact/issues/new?body=module:%20 |
|||
base_vat_sanitized%0Aversion:%20 |
|||
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Alexis de Lattre <alexis.delattre@akretion.com> |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: https://odoo-community.org/logo.png |
|||
:alt: Odoo Community Association |
|||
:target: https://odoo-community.org |
|||
|
|||
This module is maintained by the OCA. |
|||
|
|||
OCA, or the Odoo Community Association, is a nonprofit organization whose |
|||
mission is to support the collaborative development of Odoo features and |
|||
promote its widespread use. |
|||
|
|||
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import models |
@ -0,0 +1,16 @@ |
|||
# -*- 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> |
|||
|
|||
{ |
|||
'name': 'Base VAT Sanitized', |
|||
'version': '9.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', |
|||
'depends': ['base_vat'], |
|||
'installable': True, |
|||
} |
@ -0,0 +1,34 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * base_vat_sanitized |
|||
# |
|||
# Translators: |
|||
# Oihane Crucelaegui <oihanecruce@gmail.com>, 2016 |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: partner-contact (8.0)\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2016-07-03 07:56+0000\n" |
|||
"PO-Revision-Date: 2016-07-04 07:42+0000\n" |
|||
"Last-Translator: Oihane Crucelaegui <oihanecruce@gmail.com>\n" |
|||
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-partner-contact-8-0/language/es/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: es\n" |
|||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
|||
|
|||
#. module: base_vat_sanitized |
|||
#: model:ir.model,name:base_vat_sanitized.model_res_partner |
|||
msgid "Partner" |
|||
msgstr "Empresa" |
|||
|
|||
#. module: base_vat_sanitized |
|||
#: field:res.partner,sanitized_vat:0 |
|||
msgid "Sanitized TIN" |
|||
msgstr "" |
|||
|
|||
#. module: base_vat_sanitized |
|||
#: help:res.partner,sanitized_vat:0 |
|||
msgid "TIN in uppercase without spaces nor special caracters." |
|||
msgstr "" |
@ -0,0 +1,34 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * base_vat_sanitized |
|||
# |
|||
# Translators: |
|||
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2016 |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: partner-contact (8.0)\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2016-06-01 02:41+0000\n" |
|||
"PO-Revision-Date: 2016-06-01 09:42+0000\n" |
|||
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n" |
|||
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-partner-contact-8-0/language/sl/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: sl\n" |
|||
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" |
|||
|
|||
#. module: base_vat_sanitized |
|||
#: model:ir.model,name:base_vat_sanitized.model_res_partner |
|||
msgid "Partner" |
|||
msgstr "Partner" |
|||
|
|||
#. module: base_vat_sanitized |
|||
#: field:res.partner,sanitized_vat:0 |
|||
msgid "Sanitized TIN" |
|||
msgstr "Prečiščena ID za DDV" |
|||
|
|||
#. module: base_vat_sanitized |
|||
#: help:res.partner,sanitized_vat:0 |
|||
msgid "TIN in uppercase without spaces nor special caracters." |
|||
msgstr "ID za DDV z velikimi črkami brez presledkov ali posebnih znakov." |
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import res_partner |
@ -0,0 +1,25 @@ |
|||
# -*- 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) |
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import test_vat |
@ -0,0 +1,20 @@ |
|||
# -*- 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.tests.common import TransactionCase |
|||
|
|||
|
|||
class TestVatSanitized(TransactionCase): |
|||
|
|||
def test_vat_sanitized(self): |
|||
ldlc = self.env['res.partner'].create({ |
|||
'name': 'LDLC', |
|||
'is_company': True, |
|||
'vat': 'fr 26 403 554 181' |
|||
}) |
|||
self.assertEqual(ldlc.sanitized_vat, 'FR26403554181') |
|||
# Also test invalidation |
|||
ldlc.vat = False |
|||
self.assertEqual(ldlc.sanitized_vat, False) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue