From 626a99fe7c9a7b668d1d19ec41581c7f2f9f08a5 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 13 May 2016 23:19:39 +0200 Subject: [PATCH 1/3] Add module base_vat_sanitized --- base_vat_sanitized/README.rst | 59 ++++++++++++++++++++++++ base_vat_sanitized/__init__.py | 3 ++ base_vat_sanitized/__openerp__.py | 16 +++++++ base_vat_sanitized/models/__init__.py | 3 ++ base_vat_sanitized/models/res_partner.py | 25 ++++++++++ base_vat_sanitized/tests/__init__.py | 3 ++ base_vat_sanitized/tests/test_vat.py | 20 ++++++++ 7 files changed, 129 insertions(+) create mode 100644 base_vat_sanitized/README.rst create mode 100644 base_vat_sanitized/__init__.py create mode 100644 base_vat_sanitized/__openerp__.py create mode 100644 base_vat_sanitized/models/__init__.py create mode 100644 base_vat_sanitized/models/res_partner.py create mode 100644 base_vat_sanitized/tests/__init__.py create mode 100644 base_vat_sanitized/tests/test_vat.py diff --git a/base_vat_sanitized/README.rst b/base_vat_sanitized/README.rst new file mode 100644 index 000000000..765ba8de6 --- /dev/null +++ b/base_vat_sanitized/README.rst @@ -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/8.0 + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 +`_. + +Credits +======= + +Contributors +------------ + +* Alexis de Lattre + +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. diff --git a/base_vat_sanitized/__init__.py b/base_vat_sanitized/__init__.py new file mode 100644 index 000000000..cde864bae --- /dev/null +++ b/base_vat_sanitized/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/base_vat_sanitized/__openerp__.py b/base_vat_sanitized/__openerp__.py new file mode 100644 index 000000000..61963525c --- /dev/null +++ b/base_vat_sanitized/__openerp__.py @@ -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 + +{ + 'name': 'Base VAT Sanitized', + 'version': '8.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, +} diff --git a/base_vat_sanitized/models/__init__.py b/base_vat_sanitized/models/__init__.py new file mode 100644 index 000000000..f261da797 --- /dev/null +++ b/base_vat_sanitized/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import res_partner diff --git a/base_vat_sanitized/models/res_partner.py b/base_vat_sanitized/models/res_partner.py new file mode 100644 index 000000000..d32d7a4bb --- /dev/null +++ b/base_vat_sanitized/models/res_partner.py @@ -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 + +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) diff --git a/base_vat_sanitized/tests/__init__.py b/base_vat_sanitized/tests/__init__.py new file mode 100644 index 000000000..ee615d406 --- /dev/null +++ b/base_vat_sanitized/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import test_vat diff --git a/base_vat_sanitized/tests/test_vat.py b/base_vat_sanitized/tests/test_vat.py new file mode 100644 index 000000000..0fa239a1b --- /dev/null +++ b/base_vat_sanitized/tests/test_vat.py @@ -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 + +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) From f640969f6af27a36ca27fd2e4a544983efb29a51 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sun, 5 Jun 2016 02:10:17 -0400 Subject: [PATCH 2/3] OCA Transbot updated translations from Transifex --- base_vat_sanitized/i18n/es.po | 34 ++++++++++++++++++++++++++++++++++ base_vat_sanitized/i18n/sl.po | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 base_vat_sanitized/i18n/es.po create mode 100644 base_vat_sanitized/i18n/sl.po diff --git a/base_vat_sanitized/i18n/es.po b/base_vat_sanitized/i18n/es.po new file mode 100644 index 000000000..9100a5f4b --- /dev/null +++ b/base_vat_sanitized/i18n/es.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_vat_sanitized +# +# Translators: +# Oihane Crucelaegui , 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 \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 "" diff --git a/base_vat_sanitized/i18n/sl.po b/base_vat_sanitized/i18n/sl.po new file mode 100644 index 000000000..1572f4658 --- /dev/null +++ b/base_vat_sanitized/i18n/sl.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_vat_sanitized +# +# Translators: +# Matjaž Mozetič , 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č \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." From 553b95f218acff95a5ea693e44fa9608110a0c36 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 19 Nov 2016 00:51:16 +0100 Subject: [PATCH 3/3] Port base_vat_sanitized to v10 --- base_vat_sanitized/README.rst | 10 +++------- base_vat_sanitized/{__openerp__.py => __manifest__.py} | 2 +- base_vat_sanitized/models/res_partner.py | 2 +- base_vat_sanitized/tests/test_vat.py | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) rename base_vat_sanitized/{__openerp__.py => __manifest__.py} (94%) diff --git a/base_vat_sanitized/README.rst b/base_vat_sanitized/README.rst index 765ba8de6..ec5552115 100644 --- a/base_vat_sanitized/README.rst +++ b/base_vat_sanitized/README.rst @@ -6,7 +6,7 @@ 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. +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 ============= @@ -20,7 +20,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/8.0 + :target: https://runbot.odoo-community.org/runbot/134/10.0 Bug Tracker @@ -29,11 +29,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 smashing it by providing a detailed and welcomed feedback. Credits ======= diff --git a/base_vat_sanitized/__openerp__.py b/base_vat_sanitized/__manifest__.py similarity index 94% rename from base_vat_sanitized/__openerp__.py rename to base_vat_sanitized/__manifest__.py index 61963525c..05e4d161c 100644 --- a/base_vat_sanitized/__openerp__.py +++ b/base_vat_sanitized/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Base VAT Sanitized', - 'version': '8.0.1.0.0', + 'version': '10.0.1.0.0', 'category': 'Hidden/Dependency', 'license': 'AGPL-3', 'summary': 'Adds field sanitized_vat on partners', diff --git a/base_vat_sanitized/models/res_partner.py b/base_vat_sanitized/models/res_partner.py index d32d7a4bb..d1fe5dfa2 100644 --- a/base_vat_sanitized/models/res_partner.py +++ b/base_vat_sanitized/models/res_partner.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # @author Alexis de Lattre -from openerp import models, fields, api +from odoo import models, fields, api import re diff --git a/base_vat_sanitized/tests/test_vat.py b/base_vat_sanitized/tests/test_vat.py index 0fa239a1b..faad406d3 100644 --- a/base_vat_sanitized/tests/test_vat.py +++ b/base_vat_sanitized/tests/test_vat.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # @author Alexis de Lattre -from openerp.tests.common import TransactionCase +from odoo.tests.common import TransactionCase class TestVatSanitized(TransactionCase):