-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squash commits, add unique partners module. (#8)
- Loading branch information
1 parent
59758e3
commit 4a57cca
Showing
6 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.