Skip to content

Commit

Permalink
Squash commits, add unique partners module. (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
feketemihai authored and moylop260 committed May 6, 2016
1 parent 59758e3 commit 4a57cca
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 0 deletions.
62 changes: 62 additions & 0 deletions l10n_ro_partner_unique/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/l10n-romania/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 <https://github.com/OCA/l10n-romania/issues/new?body=module:%20l10n_ro_partner_unique%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Contributors
------------

* Fekete Mihai <feketemihai@gmail.com>
* Dorin Hongu <dhongu@gmail.com>
* Adrian Vasile <adrian.vasile@gmail.com>

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.
5 changes: 5 additions & 0 deletions l10n_ro_partner_unique/__init__.py
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions l10n_ro_partner_unique/__openerp__.py
Original file line number Diff line number Diff line change
@@ -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,
}
5 changes: 5 additions & 0 deletions l10n_ro_partner_unique/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions l10n_ro_partner_unique/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -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
Binary file added l10n_ro_partner_unique/static/description/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4a57cca

Please sign in to comment.