diff --git a/l10n_ro_partner_unique/README.rst b/l10n_ro_partner_unique/README.rst new file mode 100644 index 000000000..053bbade9 --- /dev/null +++ b/l10n_ro_partner_unique/README.rst @@ -0,0 +1,62 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +========================= +Romania - Partners Unique +========================= + +This module add condition for unique partners based on VAT and NRC numbers +for every company. + + +Installation +============ + +To install this module, you need to: + +#. Clone the branch 8.0 of the repository https://github.com/OCA/l10n-romania +#. Add the path to this repository in your configuration (addons-path) +#. Update the module list +#. Search for "Romania - Partners Unique" in your addons +#. Install the module + + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/177/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 +`here `_. + +Credits +======= + +Contributors +------------ + +* Fekete Mihai +* Dorin Hongu +* Adrian Vasile + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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 http://odoo-community.org. diff --git a/l10n_ro_partner_unique/__init__.py b/l10n_ro_partner_unique/__init__.py new file mode 100644 index 000000000..2be73fc5f --- /dev/null +++ b/l10n_ro_partner_unique/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2015 Forest and Biomass Services Romania +# See README.rst file on addons root folder for license details + +from . import models diff --git a/l10n_ro_partner_unique/__openerp__.py b/l10n_ro_partner_unique/__openerp__.py new file mode 100644 index 000000000..19ab5474c --- /dev/null +++ b/l10n_ro_partner_unique/__openerp__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# © 2015 Forest and Biomass Services Romania +# See README.rst file on addons root folder for license details + +{ + 'name': 'Romania - Partners Unique', + 'summary': 'Creates a rule for vat and nrc unique for partners.', + 'version': '8.0.1.0.0', + 'category': 'Localization', + 'author': 'Forest and Biomass Services Romania, ' + 'Odoo Community Association (OCA)', + 'website': 'https://www.forbiom.eu', + 'license': 'AGPL-3', + 'application': False, + 'installable': True, + 'depends': ['base', 'l10n_ro'], + 'images': [], + 'auto_install': False, +} diff --git a/l10n_ro_partner_unique/models/__init__.py b/l10n_ro_partner_unique/models/__init__.py new file mode 100644 index 000000000..6aa2fbbdb --- /dev/null +++ b/l10n_ro_partner_unique/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2015 Forest and Biomass Services Romania +# See README.rst file on addons root folder for license details + +from . import res_partner diff --git a/l10n_ro_partner_unique/models/res_partner.py b/l10n_ro_partner_unique/models/res_partner.py new file mode 100644 index 000000000..40e38f2d5 --- /dev/null +++ b/l10n_ro_partner_unique/models/res_partner.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# © 2015 Forest and Biomass Services Romania +# See README.rst file on addons root folder for license details + +from openerp import models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + def _auto_init(self, cr, context=None): + # Remove vat and nrc unique constraints from Odoo base addons from + # https://github.com/odoo/odoo/blob/8.0/addons/l10n_ro/res_partner.py + # history, if exists, and add a new one based on + # company_id, vat and nrc pair. + result = super(ResPartner, self)._auto_init(cr, context=context) + # Real implementation of the vat/nrc constraints: only + # "commercial entities" need to have unique numbers, and the condition + # for being a commercial entity is "is_company or parent_id IS NULL". + # Contacts inside a company automatically have a copy of the company's + # commercial fields (see _commercial_fields()), so they are + # automatically consistent. + cr.execute(""" + DROP INDEX IF EXISTS res_partner_vat_nrc_uniq_for_companies; + DROP INDEX IF EXISTS res_partner_vat_uniq_for_companies; + DROP INDEX IF EXISTS res_partner_nrc_uniq_for_companies; + CREATE UNIQUE INDEX res_partner_vat_nrc_uniq_for_companies + ON res_partner (company_id, vat, nrc) WHERE is_company OR + parent_id IS NULL; + """) + return result diff --git a/l10n_ro_partner_unique/static/description/icon.png b/l10n_ro_partner_unique/static/description/icon.png new file mode 100644 index 000000000..7ba9c1019 Binary files /dev/null and b/l10n_ro_partner_unique/static/description/icon.png differ