diff --git a/companyweb_payment_info/tests/test_cweb_upload.py b/companyweb_payment_info/tests/test_cweb_upload.py index 6b1222631..32fa65425 100644 --- a/companyweb_payment_info/tests/test_cweb_upload.py +++ b/companyweb_payment_info/tests/test_cweb_upload.py @@ -123,7 +123,7 @@ def test_upload_payment(self): self.demo_user )._cweb_payment_info_step1() - self.env.user.company_id.vat = "FR0835207216" + self.env.user.company_id.vat = "FR23334175221" # UserError bad on users's company with self.assertRaises(UserError): diff --git a/l10n_be_partner_kbo_bce/README.rst b/l10n_be_partner_kbo_bce/README.rst new file mode 100644 index 000000000..02dbf50a9 --- /dev/null +++ b/l10n_be_partner_kbo_bce/README.rst @@ -0,0 +1,82 @@ +========================= +Belgium - KBO/BCE numbers +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c44269b9a5e508ed0bd48298598c63eb405784d43a2a614a31f95e2156ed1a23 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--belgium-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-belgium/tree/17.0/l10n_be_partner_kbo_bce + :alt: OCA/l10n-belgium +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-belgium-17-0/l10n-belgium-17-0-l10n_be_partner_kbo_bce + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-belgium&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds support for KBO/BCE numbers on partner records +including a consistency check with the VAT numbers. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +There is no specific installation procedure for this module. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Noviat + +Contributors +------------ + +- Luc De Meyer + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/l10n-belgium `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_be_partner_kbo_bce/__init__.py b/l10n_be_partner_kbo_bce/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/l10n_be_partner_kbo_bce/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_be_partner_kbo_bce/__manifest__.py b/l10n_be_partner_kbo_bce/__manifest__.py new file mode 100644 index 000000000..193f56d19 --- /dev/null +++ b/l10n_be_partner_kbo_bce/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2009-2020 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Belgium - KBO/BCE numbers", + "category": "Localization", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "author": "Noviat,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/l10n-belgium", + "depends": ["partner_identification", "base_vat"], + "data": ["data/res_partner_id_category.xml", "views/res_partner.xml"], + "demo": ["demo/res_partner.xml"], + "installable": True, +} diff --git a/l10n_be_partner_kbo_bce/data/res_partner_id_category.xml b/l10n_be_partner_kbo_bce/data/res_partner_id_category.xml new file mode 100644 index 000000000..38c574b79 --- /dev/null +++ b/l10n_be_partner_kbo_bce/data/res_partner_id_category.xml @@ -0,0 +1,10 @@ + + + + l10n_be_kbo_bce + Belgium KBO/BCE Number + failed = self.validate_l10n_be_partner_kbo_bce(id_number) + + diff --git a/l10n_be_partner_kbo_bce/demo/res_partner.xml b/l10n_be_partner_kbo_bce/demo/res_partner.xml new file mode 100644 index 000000000..88095bc9c --- /dev/null +++ b/l10n_be_partner_kbo_bce/demo/res_partner.xml @@ -0,0 +1,17 @@ + + + + Noviat + + 1 + Brussel + 1083 + Rusatiralaan 1 + info@noviat.com + +32 2 808 86 38 + http://www.noviat.com + + diff --git a/l10n_be_partner_kbo_bce/i18n/es.po b/l10n_be_partner_kbo_bce/i18n/es.po new file mode 100644 index 000000000..6fff1500b --- /dev/null +++ b/l10n_be_partner_kbo_bce/i18n/es.po @@ -0,0 +1,69 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_be_partner_kbo_bce +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-08-06 13:11+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: l10n_be_partner_kbo_bce +#: model:res.partner.id_category,name:l10n_be_partner_kbo_bce.l10n_be_kbo_bce_number_category +msgid "Belgium KBO/BCE Number" +msgstr "Bélgica Número KBO/BCE" + +#. module: l10n_be_partner_kbo_bce +#. odoo-python +#: code:addons/l10n_be_partner_kbo_bce/models/res_partner.py:0 +#, python-format +msgid "Configuration Error, Country BE has not been defined !" +msgstr "Error de configuración, ¡no se ha definido el país BE!" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model,name:l10n_be_partner_kbo_bce.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_partner__country_code +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_users__country_code +msgid "Country Code" +msgstr "Código del país" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_partner__kbo_bce_number +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_users__kbo_bce_number +msgid "KBO/BCE Number" +msgstr "Número KBO/BCE" + +#. module: l10n_be_partner_kbo_bce +#. odoo-python +#: code:addons/l10n_be_partner_kbo_bce/models/res_partner.py:0 +#, python-format +msgid "KBO/BCE Number '%(kbn)s' is not consistent with VAT Number '%(vat)s'." +msgstr "" +"El número KBO/BCE \"%(kbn)s\" no coincide con el número de IVA \"%(vat)s\"." + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model,name:l10n_be_partner_kbo_bce.model_res_partner_id_category +msgid "Partner ID Category" +msgstr "Categoría ID de socio" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,help:l10n_be_partner_kbo_bce.field_res_partner__country_code +#: model:ir.model.fields,help:l10n_be_partner_kbo_bce.field_res_users__country_code +msgid "" +"The ISO country code in two chars. \n" +"You can use this field for quick search." +msgstr "" +"El código ISO del país en dos caracteres. \n" +"Puede utilizar este campo para una búsqueda rápida." diff --git a/l10n_be_partner_kbo_bce/i18n/fr.po b/l10n_be_partner_kbo_bce/i18n/fr.po new file mode 100644 index 000000000..9b5bc1ede --- /dev/null +++ b/l10n_be_partner_kbo_bce/i18n/fr.po @@ -0,0 +1,67 @@ +# French translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_be_partner_kbo_bce +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-06 11:30:51.934000\n" +"PO-Revision-Date: 2018-04-06 11:30:51.934000\n" +"Last-Translator: Luc De Meyer (Noviat nv/sa)\n" +"Language-Team: \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: l10n_be_partner_kbo_bce +#: model:res.partner.id_category,name:l10n_be_partner_kbo_bce.l10n_be_kbo_bce_number_category +#, fuzzy +msgid "Belgium KBO/BCE Number" +msgstr "Numéro BCE" + +#. module: l10n_be_partner_kbo_bce +#. odoo-python +#: code:addons/l10n_be_partner_kbo_bce/models/res_partner.py:0 +#, python-format +msgid "Configuration Error, Country BE has not been defined !" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model,name:l10n_be_partner_kbo_bce.model_res_partner +msgid "Contact" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_partner__country_code +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_users__country_code +msgid "Country Code" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_partner__kbo_bce_number +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_users__kbo_bce_number +msgid "KBO/BCE Number" +msgstr "Numéro BCE" + +#. module: l10n_be_partner_kbo_bce +#. odoo-python +#: code:addons/l10n_be_partner_kbo_bce/models/res_partner.py:0 +#, python-format +msgid "KBO/BCE Number '%(kbn)s' is not consistent with VAT Number '%(vat)s'." +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model,name:l10n_be_partner_kbo_bce.model_res_partner_id_category +msgid "Partner ID Category" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,help:l10n_be_partner_kbo_bce.field_res_partner__country_code +#: model:ir.model.fields,help:l10n_be_partner_kbo_bce.field_res_users__country_code +msgid "" +"The ISO country code in two chars. \n" +"You can use this field for quick search." +msgstr "" diff --git a/l10n_be_partner_kbo_bce/i18n/l10n_be_partner_kbo_bce.pot b/l10n_be_partner_kbo_bce/i18n/l10n_be_partner_kbo_bce.pot new file mode 100644 index 000000000..cd8dbd294 --- /dev/null +++ b/l10n_be_partner_kbo_bce/i18n/l10n_be_partner_kbo_bce.pot @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_be_partner_kbo_bce +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_be_partner_kbo_bce +#: model:res.partner.id_category,name:l10n_be_partner_kbo_bce.l10n_be_kbo_bce_number_category +msgid "Belgium KBO/BCE Number" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#. odoo-python +#: code:addons/l10n_be_partner_kbo_bce/models/res_partner.py:0 +#, python-format +msgid "Configuration Error, Country BE has not been defined !" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model,name:l10n_be_partner_kbo_bce.model_res_partner +msgid "Contact" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_partner__country_code +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_users__country_code +msgid "Country Code" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_partner__kbo_bce_number +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_users__kbo_bce_number +msgid "KBO/BCE Number" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#. odoo-python +#: code:addons/l10n_be_partner_kbo_bce/models/res_partner.py:0 +#, python-format +msgid "KBO/BCE Number '%(kbn)s' is not consistent with VAT Number '%(vat)s'." +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model,name:l10n_be_partner_kbo_bce.model_res_partner_id_category +msgid "Partner ID Category" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,help:l10n_be_partner_kbo_bce.field_res_partner__country_code +#: model:ir.model.fields,help:l10n_be_partner_kbo_bce.field_res_users__country_code +msgid "" +"The ISO country code in two chars. \n" +"You can use this field for quick search." +msgstr "" diff --git a/l10n_be_partner_kbo_bce/i18n/nl.po b/l10n_be_partner_kbo_bce/i18n/nl.po new file mode 100644 index 000000000..87e300c93 --- /dev/null +++ b/l10n_be_partner_kbo_bce/i18n/nl.po @@ -0,0 +1,67 @@ +# Dutch translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_be_partner_kbo_bce +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-06 11:30:51.934000\n" +"PO-Revision-Date: 2018-04-06 11:30:51.934000\n" +"Last-Translator: Luc De Meyer (Noviat nv/sa)\n" +"Language-Team: \n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: l10n_be_partner_kbo_bce +#: model:res.partner.id_category,name:l10n_be_partner_kbo_bce.l10n_be_kbo_bce_number_category +#, fuzzy +msgid "Belgium KBO/BCE Number" +msgstr "KBO Nummer" + +#. module: l10n_be_partner_kbo_bce +#. odoo-python +#: code:addons/l10n_be_partner_kbo_bce/models/res_partner.py:0 +#, python-format +msgid "Configuration Error, Country BE has not been defined !" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model,name:l10n_be_partner_kbo_bce.model_res_partner +msgid "Contact" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_partner__country_code +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_users__country_code +msgid "Country Code" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_partner__kbo_bce_number +#: model:ir.model.fields,field_description:l10n_be_partner_kbo_bce.field_res_users__kbo_bce_number +msgid "KBO/BCE Number" +msgstr "KBO Nummer" + +#. module: l10n_be_partner_kbo_bce +#. odoo-python +#: code:addons/l10n_be_partner_kbo_bce/models/res_partner.py:0 +#, python-format +msgid "KBO/BCE Number '%(kbn)s' is not consistent with VAT Number '%(vat)s'." +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model,name:l10n_be_partner_kbo_bce.model_res_partner_id_category +msgid "Partner ID Category" +msgstr "" + +#. module: l10n_be_partner_kbo_bce +#: model:ir.model.fields,help:l10n_be_partner_kbo_bce.field_res_partner__country_code +#: model:ir.model.fields,help:l10n_be_partner_kbo_bce.field_res_users__country_code +msgid "" +"The ISO country code in two chars. \n" +"You can use this field for quick search." +msgstr "" diff --git a/l10n_be_partner_kbo_bce/models/__init__.py b/l10n_be_partner_kbo_bce/models/__init__.py new file mode 100644 index 000000000..21153e6be --- /dev/null +++ b/l10n_be_partner_kbo_bce/models/__init__.py @@ -0,0 +1,2 @@ +from . import res_partner +from . import res_partner_id_category diff --git a/l10n_be_partner_kbo_bce/models/res_partner.py b/l10n_be_partner_kbo_bce/models/res_partner.py new file mode 100644 index 000000000..4b563b4a1 --- /dev/null +++ b/l10n_be_partner_kbo_bce/models/res_partner.py @@ -0,0 +1,150 @@ +# Copyright 2009-2020 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class ResPartner(models.Model): + _inherit = "res.partner" + + kbo_bce_number = fields.Char( + string="KBO/BCE Number", + compute=lambda s: s._compute_identification( + "kbo_bce_number", "l10n_be_kbo_bce" + ), + inverse=lambda s: s._inverse_identification( + "kbo_bce_number", "l10n_be_kbo_bce" + ), + search=lambda s, *a: s._search_identification("l10n_be_kbo_bce", *a), + ) + country_code = fields.Char(related="country_id.code") + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if vals.get("is_company"): + if "vat" in vals or "kbo_bce_number" in vals: + self._sync_kbo_bce_number(vals) + return super().create(vals_list) + + def write(self, vals): + # base module, res_partner.py drops 'is_company' from vals + # hence we save vals before super() + vals_in = vals.copy() + if "is_company" in vals_in: + if vals_in["is_company"]: + company_partners = self + else: + company_partners = self.env["res.partner"] + else: + company_partners = self.filtered(lambda r: r.is_company) + contact_partners = self - company_partners + + super(ResPartner, contact_partners).write(vals) + for partner in company_partners: + values = vals_in.copy() + if any( + [ + x in vals_in + for x in ["vat", "kbo_bce_number", "is_company", "country_id"] + ] + ): + if "vat" in vals_in: + vat = vals_in["vat"] + else: + vat = partner.vat + if "kbo_bce_number" in vals_in: + kbo_bce_number = vals_in["kbo_bce_number"] + else: + kbo_bce_number = partner.kbo_bce_number + if "country_id" in vals_in: + country_id = vals_in["country_id"] + else: + country_id = partner.country_id.id + sync_vals = { + "vat": vat, + "kbo_bce_number": kbo_bce_number, + "country_id": country_id, + } + partner._sync_kbo_bce_number(sync_vals) + for k in sync_vals: + values[k] = sync_vals[k] + super(ResPartner, partner).write(values) + return True + + def _vals_format_kbo_bce_number(self, vals): + rn = vals.get("kbo_bce_number") + if rn: + vals["kbo_bce_number"] = self._format_kbo_bce_number(rn) + + def _format_kbo_bce_number(self, number): + res = number.replace(" ", "").replace(".", "") + res = res[:4] + "." + res[4:7] + "." + res[7:] + return res + + def _get_belgium(self): + be = self.env.ref("base.be") or self.env["res.country"].search( + [("code", "=", "BE")] + ) + if not be: + raise ValidationError( + _("Configuration Error, Country BE has not been defined !") + ) + return be + + def _sync_kbo_bce_number(self, sync_vals): + be = self._get_belgium() + country_id = sync_vals.get("country_id") and sync_vals["country_id"] + vat = sync_vals.get("vat") and self._fix_vat_number( + sync_vals["vat"], country_id + ) + kbn = sync_vals.get("kbo_bce_number") and sync_vals["kbo_bce_number"] + has_kbo_bce_number = False + + if vat and vat[0:2] == "BE" and not kbn: + kbn = vat[2:] + sync_vals["kbo_bce_number"] = kbn + has_kbo_bce_number = True + + if kbn and not vat: + has_kbo_bce_number = True + vat_number = kbn.replace(".", "") + sync_vals["vat"] = "BE " + vat_number + sync_vals["vies_vat_to_check"] = "BE " + vat_number + + if has_kbo_bce_number and not country_id: + sync_vals["country_id"] = be.id + + self._vals_format_kbo_bce_number(sync_vals) + self._update_kbo_bce_sync_vals(sync_vals) + + # consistency check + kbn = sync_vals.get("kbo_bce_number") + vat = sync_vals.get("vat") + if kbn and vat: + if kbn.replace(".", "") != self._fix_vat_number(vat, country_id)[2:]: + raise ValidationError( + _( + "KBO/BCE Number '%(kbn)s' is not consistent with " + "VAT Number '%(vat)s'.", + kbn=kbn, + vat=vat, + ) + ) + + # minimise overhead caused by sync of _commercial_fields + # and address fields to child records + if self.vat == sync_vals.get("vat"): + del sync_vals["vat"] + if self.country_id.id == sync_vals.get("country_id"): + del sync_vals["country_id"] + + def _update_kbo_bce_sync_vals(self, sync_vals): + """ + Use this method for extra customisations, e.g. + lookup in external databases. + + in case of 'create': empty self, sync_vals contains all vals + in case of 'write': self contains partner record + """ diff --git a/l10n_be_partner_kbo_bce/models/res_partner_id_category.py b/l10n_be_partner_kbo_bce/models/res_partner_id_category.py new file mode 100644 index 000000000..cb44792f9 --- /dev/null +++ b/l10n_be_partner_kbo_bce/models/res_partner_id_category.py @@ -0,0 +1,25 @@ +# Copyright 2009-2020 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import re + +from odoo import api, models + + +class ResPartnerIdCategory(models.Model): + _inherit = "res.partner.id_category" + + @api.model + def validate_l10n_be_partner_kbo_bce(self, id_number): + failed = True + kbo_bce_number = id_number.name + supported_chars = "0-9." + pattern = re.compile("[^" + supported_chars + "]") + if not pattern.findall(kbo_bce_number): + kbo_bce_number = kbo_bce_number.replace(".", "") + if len(kbo_bce_number) == 10: + base = int(kbo_bce_number[:8]) + mod = base % 97 + if 97 - mod == int(kbo_bce_number[-2:]): + failed = False + return failed diff --git a/l10n_be_partner_kbo_bce/pyproject.toml b/l10n_be_partner_kbo_bce/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/l10n_be_partner_kbo_bce/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_be_partner_kbo_bce/readme/CONTRIBUTORS.md b/l10n_be_partner_kbo_bce/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..4d017214a --- /dev/null +++ b/l10n_be_partner_kbo_bce/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Luc De Meyer \<\> diff --git a/l10n_be_partner_kbo_bce/readme/DESCRIPTION.md b/l10n_be_partner_kbo_bce/readme/DESCRIPTION.md new file mode 100644 index 000000000..d2af689e6 --- /dev/null +++ b/l10n_be_partner_kbo_bce/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module adds support for KBO/BCE numbers on partner records +including a consistency check with the VAT numbers. diff --git a/l10n_be_partner_kbo_bce/readme/INSTALL.md b/l10n_be_partner_kbo_bce/readme/INSTALL.md new file mode 100644 index 000000000..9d94322d9 --- /dev/null +++ b/l10n_be_partner_kbo_bce/readme/INSTALL.md @@ -0,0 +1 @@ +There is no specific installation procedure for this module. diff --git a/l10n_be_partner_kbo_bce/static/description/icon.png b/l10n_be_partner_kbo_bce/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/l10n_be_partner_kbo_bce/static/description/icon.png differ diff --git a/l10n_be_partner_kbo_bce/static/description/index.html b/l10n_be_partner_kbo_bce/static/description/index.html new file mode 100644 index 000000000..be3d9aff8 --- /dev/null +++ b/l10n_be_partner_kbo_bce/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Belgium - KBO/BCE numbers + + + +
+

Belgium - KBO/BCE numbers

+ + +

Beta License: AGPL-3 OCA/l10n-belgium Translate me on Weblate Try me on Runboat

+

This module adds support for KBO/BCE numbers on partner records +including a consistency check with the VAT numbers.

+

Table of contents

+ +
+

Installation

+

There is no specific installation procedure for this module.

+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Noviat
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/l10n-belgium project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/l10n_be_partner_kbo_bce/tests/__init__.py b/l10n_be_partner_kbo_bce/tests/__init__.py new file mode 100644 index 000000000..6cbc48b6b --- /dev/null +++ b/l10n_be_partner_kbo_bce/tests/__init__.py @@ -0,0 +1 @@ +from . import test_l10n_be_partner_kbo_bce diff --git a/l10n_be_partner_kbo_bce/tests/test_l10n_be_partner_kbo_bce.py b/l10n_be_partner_kbo_bce/tests/test_l10n_be_partner_kbo_bce.py new file mode 100644 index 000000000..00bb7f82a --- /dev/null +++ b/l10n_be_partner_kbo_bce/tests/test_l10n_be_partner_kbo_bce.py @@ -0,0 +1,42 @@ +# Copyright 2009-2020 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.exceptions import ValidationError +from odoo.tests.common import TransactionCase + + +class TestKboBceNumber(TransactionCase): + def setUp(self): + super().setUp() + self.rp_1 = self.env.ref("l10n_be_partner_kbo_bce.res_partner_1") + self.be = self.env.ref("base.be") + + def test_validate_kbo_bce_number(self): + rp = self.rp_1 + with self.assertRaises(ValidationError): + rp.kbo_bce_number = "0820 512 014" + + def test_assign_kbo_bce_number(self): + rp = self.rp_1 + rp.vat = "BE 0820 512 013" + self.assertEqual(rp.country_id, self.be) + self.assertEqual(rp.kbo_bce_number, "0820.512.013") + + def test_check_vat_consistency(self): + rp = self.rp_1 + rp.vat = "BE 0820 512 013" + with self.assertRaises(ValidationError): + rp.kbo_bce_number = "0477.472.701" + + def test_format_kbo_bce_number(self): + rp = self.rp_1 + rp.vat = "BE 0820 512 013" + rp.kbo_bce_number = "0820512013" + rp.invalidate_recordset(["kbo_bce_number"]) + self.assertEqual(rp.kbo_bce_number, "0820.512.013") + + def test_create_be_partner(self): + rp_vals = {"name": "BeCo", "vat": "BE 0820 512 013", "is_company": True} + rp = self.env["res.partner"].create(rp_vals) + self.assertEqual(rp.country_id, self.be) + self.assertEqual(rp.kbo_bce_number, "0820.512.013") diff --git a/l10n_be_partner_kbo_bce/views/res_partner.xml b/l10n_be_partner_kbo_bce/views/res_partner.xml new file mode 100644 index 000000000..7eab9aaa1 --- /dev/null +++ b/l10n_be_partner_kbo_bce/views/res_partner.xml @@ -0,0 +1,13 @@ + + + res.partner.form.kbo_bce_number + res.partner + + +
+ + +
+
+
+
diff --git a/pandoc-3.1.12.2-1-amd64.deb b/pandoc-3.1.12.2-1-amd64.deb new file mode 100644 index 000000000..8766f9f6f Binary files /dev/null and b/pandoc-3.1.12.2-1-amd64.deb differ