João Marques
4 years ago
committed by
Pedro M. Baeza
12 changed files with 114 additions and 103 deletions
-
21partner_ref_unique/README.rst
-
1partner_ref_unique/__init__.py
-
8partner_ref_unique/__manifest__.py
-
33partner_ref_unique/hooks.py
-
15partner_ref_unique/models/res_company.py
-
27partner_ref_unique/models/res_partner.py
-
2partner_ref_unique/readme/CONFIGURE.rst
-
1partner_ref_unique/readme/CONTRIBUTORS.rst
-
2partner_ref_unique/readme/DESCRIPTION.rst
-
6partner_ref_unique/readme/USAGE.rst
-
17partner_ref_unique/static/description/index.html
-
84partner_ref_unique/tests/test_res_partner_ref.py
@ -1,4 +1,3 @@ |
|||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
from . import models |
from . import models |
||||
from .hooks import pre_init_hook |
|
@ -1,18 +1,18 @@ |
|||||
# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa |
# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa |
||||
# Copyright 2017 Tecnativa - Vicent Cubells |
# Copyright 2017 Tecnativa - Vicent Cubells |
||||
|
# Copyright 2020 Tecnativa - João Marques |
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
{ |
{ |
||||
"name": "Partner unique reference", |
"name": "Partner unique reference", |
||||
"summary": "Add an unique constraint to partner ref field", |
"summary": "Add an unique constraint to partner ref field", |
||||
"version": "12.0.1.0.2", |
|
||||
|
"version": "13.0.1.0.0", |
||||
"category": "Customer Relationship Management", |
"category": "Customer Relationship Management", |
||||
"website": "https://github.com/OCA/partner-contact/", |
"website": "https://github.com/OCA/partner-contact/", |
||||
"author": "Tecnativa, " "Odoo Community Association (OCA)", |
"author": "Tecnativa, " "Odoo Community Association (OCA)", |
||||
"license": "AGPL-3", |
"license": "AGPL-3", |
||||
"application": False, |
"application": False, |
||||
"installable": True, |
"installable": True, |
||||
"pre_init_hook": "pre_init_hook", |
|
||||
"depends": ["base",], |
|
||||
"data": ["views/res_company_view.xml",], |
|
||||
|
"depends": ["base"], |
||||
|
"data": ["views/res_company_view.xml"], |
||||
} |
} |
@ -1,33 +0,0 @@ |
|||||
# Copyright 2020 Camptocamp SA |
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) |
|
||||
import logging |
|
||||
|
|
||||
_logger = logging.getLogger(__name__) |
|
||||
|
|
||||
|
|
||||
def pre_init_hook(cr): |
|
||||
"""Create column using SQL to avoid auto-init updating the table row by row |
|
||||
:param odoo.sql_db.Cursor cr: |
|
||||
Database cursor. |
|
||||
""" |
|
||||
_logger.info("Creating res.company.partner_ref_unique column") |
|
||||
cr.execute("ALTER TABLE res_company ADD partner_ref_unique varchar NULL;") |
|
||||
cr.execute( |
|
||||
"COMMENT ON COLUMN public.res_company.partner_ref_unique " |
|
||||
"IS 'Unique partner reference for';" |
|
||||
) |
|
||||
cr.execute("UPDATE res_company SET partner_ref_unique = 'none';") |
|
||||
_logger.info( |
|
||||
"Creating res.partner.partner_ref_unique column with value from " "res.company" |
|
||||
) |
|
||||
cr.execute("ALTER TABLE res_partner ADD partner_ref_unique varchar NULL;") |
|
||||
cr.execute( |
|
||||
"COMMENT ON COLUMN res_partner.partner_ref_unique " |
|
||||
"IS 'Unique partner reference for';" |
|
||||
) |
|
||||
cr.execute( |
|
||||
"UPDATE res_partner rp " |
|
||||
"SET partner_ref_unique = rc.partner_ref_unique " |
|
||||
"FROM res_company rc " |
|
||||
"WHERE rc.id = rp.company_id;" |
|
||||
) |
|
@ -1,5 +1,5 @@ |
|||||
To configure this module, you need to: |
To configure this module, you need to: |
||||
|
|
||||
#. Go to **Settings > Companies**. |
|
||||
|
#. Go to **Settings > Users & Companies > Companies**. |
||||
#. Select a company. |
#. Select a company. |
||||
#. Choose an option on section *Partners*. |
#. Choose an option on section *Partners*. |
@ -1 +1 @@ |
|||||
This module allows add an unique constraint to partner ref field. |
|
||||
|
This module allows add a unique constraint to partner ref field. |
@ -1,6 +1,6 @@ |
|||||
#. Go to any partner in **Contacts > Contacts** |
#. Go to any partner in **Contacts > Contacts** |
||||
#. Try to create two partners with the same ref. |
#. Try to create two partners with the same ref. |
||||
|
|
||||
* If you selcted the option 'All partners' you can't create two partners with the same ref. |
|
||||
* If you selcted the option 'Only companies' you can't create two companies with the same ref. |
|
||||
* If you selcted the option 'None' you can create two partners with the same ref. |
|
||||
|
* If you selected the option 'All partners' you can't create two partners with the same ref. |
||||
|
* If you selected the option 'Only companies' you can't create two companies with the same ref. |
||||
|
* If you selected the option 'None' you can create two partners with the same ref. |
Write
Preview
Loading…
Cancel
Save
Reference in new issue