forked from OCA/partner-contact
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1302 from OCA/18.0
Syncing from upstream OCA/partner-contact (18.0)
- Loading branch information
Showing
20 changed files
with
895 additions
and
1 deletion.
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
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,84 @@ | ||
================================================= | ||
Partner Identification Numbers Unique By Category | ||
================================================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:5ed85dd53d73055ff809768ba6037901387c9f2eb456c5f83ef98441f180223a | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Production/Stable | ||
.. |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%2Fpartner--contact-lightgray.png?logo=github | ||
:target: https://github.com/OCA/partner-contact/tree/18.0/partner_identification_unique_by_category | ||
:alt: OCA/partner-contact | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_identification_unique_by_category | ||
: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/partner-contact&target_branch=18.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module extends the module partner_identification to enforce having | ||
unique id numbers by categories. This option can be set by category. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/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 <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_identification_unique_by_category%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* Camptocamp | ||
|
||
Contributors | ||
------------ | ||
|
||
- Thierry Ducrest <thierry.ducrest@camptocamp.com> | ||
- Chau Le <chaulb@trobz.com> | ||
|
||
Other credits | ||
------------- | ||
|
||
The migration of this module from 14.0 to 18.0 was financially supported | ||
by Camptocamp. | ||
|
||
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/partner-contact <https://github.com/OCA/partner-contact/tree/18.0/partner_identification_unique_by_category>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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 @@ | ||
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,11 @@ | ||
{ | ||
"name": "Partner Identification Numbers Unique By Category", | ||
"category": "Customer Relationship Management", | ||
"version": "18.0.1.0.0", | ||
"license": "AGPL-3", | ||
"depends": ["partner_identification"], | ||
"data": ["views/res_partner_id_category_view.xml"], | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/partner-contact", | ||
"development_status": "Production/Stable", | ||
} |
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,77 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * partner_identification_unique_by_category | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2024-01-13 13:33+0000\n" | ||
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\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: partner_identification_unique_by_category | ||
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_category__has_unique_numbers | ||
msgid "Enforce unicity" | ||
msgstr "Reforzar la unicidad" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#: model:ir.model,name:partner_identification_unique_by_category.model_res_partner_id_category | ||
msgid "Partner ID Category" | ||
msgstr "Categoría ID de Socio" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#: model:ir.model,name:partner_identification_unique_by_category.model_res_partner_id_number | ||
msgid "Partner ID Number" | ||
msgstr "Número ID de Socio" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#. odoo-python | ||
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_number.py:0 | ||
msgid "" | ||
"The Id %(name)s in the category %(category_name)s could not be created " | ||
"because it already exists" | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#. odoo-python | ||
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_category.py:0 | ||
msgid "" | ||
"The category %s can not be set to use unique numbers, because it already " | ||
"contains duplicates." | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#: model:ir.model.fields,help:partner_identification_unique_by_category.field_res_partner_id_category__has_unique_numbers | ||
msgid "When set, duplicate numbers will not be allowed for this category." | ||
msgstr "" | ||
"Si se establece, no se permitirán números duplicados para esta categoría." | ||
|
||
#~ msgid "Display Name" | ||
#~ msgstr "Mostrar Nombre" | ||
|
||
#~ msgid "ID" | ||
#~ msgstr "ID" | ||
|
||
#~ msgid "Last Modified on" | ||
#~ msgstr "Última Modificación el" | ||
|
||
#, python-format | ||
#~ msgid "" | ||
#~ "The Id {} in the category {} could not be created because it already " | ||
#~ "exists" | ||
#~ msgstr "El Id {} de la categoría {} no se ha podido crear porque ya existe" | ||
|
||
#, python-format | ||
#~ msgid "" | ||
#~ "The category {} can not be set to use unique numbers, because it already " | ||
#~ "contains duplicates." | ||
#~ msgstr "" | ||
#~ "La categoría {} no puede configurarse para utilizar números únicos, " | ||
#~ "porque ya contiene duplicados." |
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,51 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * partner_identification_unique_by_category | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: Automatically generated\n" | ||
"Language-Team: none\n" | ||
"Language: it\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: partner_identification_unique_by_category | ||
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_category__has_unique_numbers | ||
msgid "Enforce unicity" | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#: model:ir.model,name:partner_identification_unique_by_category.model_res_partner_id_category | ||
msgid "Partner ID Category" | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#: model:ir.model,name:partner_identification_unique_by_category.model_res_partner_id_number | ||
msgid "Partner ID Number" | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#. odoo-python | ||
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_number.py:0 | ||
msgid "" | ||
"The Id %(name)s in the category %(category_name)s could not be created " | ||
"because it already exists" | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#. odoo-python | ||
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_category.py:0 | ||
msgid "" | ||
"The category %s can not be set to use unique numbers, because it already " | ||
"contains duplicates." | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#: model:ir.model.fields,help:partner_identification_unique_by_category.field_res_partner_id_category__has_unique_numbers | ||
msgid "When set, duplicate numbers will not be allowed for this category." | ||
msgstr "" |
50 changes: 50 additions & 0 deletions
50
partner_identification_unique_by_category/i18n/partner_identification_unique_by_category.pot
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,50 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * partner_identification_unique_by_category | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 18.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: partner_identification_unique_by_category | ||
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_category__has_unique_numbers | ||
msgid "Enforce unicity" | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#: model:ir.model,name:partner_identification_unique_by_category.model_res_partner_id_category | ||
msgid "Partner ID Category" | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#: model:ir.model,name:partner_identification_unique_by_category.model_res_partner_id_number | ||
msgid "Partner ID Number" | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#. odoo-python | ||
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_number.py:0 | ||
msgid "" | ||
"The Id %(name)s in the category %(category_name)s could not be created " | ||
"because it already exists" | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#. odoo-python | ||
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_category.py:0 | ||
msgid "" | ||
"The category %s can not be set to use unique numbers, because it already " | ||
"contains duplicates." | ||
msgstr "" | ||
|
||
#. module: partner_identification_unique_by_category | ||
#: model:ir.model.fields,help:partner_identification_unique_by_category.field_res_partner_id_category__has_unique_numbers | ||
msgid "When set, duplicate numbers will not be allowed for this category." | ||
msgstr "" |
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,2 @@ | ||
from . import res_partner_id_number | ||
from . import res_partner_id_category |
32 changes: 32 additions & 0 deletions
32
partner_identification_unique_by_category/models/res_partner_id_category.py
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,32 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo import api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class ResPartnerIdCategory(models.Model): | ||
_inherit = "res.partner.id_category" | ||
|
||
has_unique_numbers = fields.Boolean( | ||
string="Enforce unicity", | ||
help="When set, duplicate numbers will not be allowed for this category.", | ||
) | ||
|
||
@api.constrains("has_unique_numbers") | ||
def validate_must_be_unique(self): | ||
for rec in self: | ||
if not rec.has_unique_numbers: | ||
continue | ||
ids = self.env["res.partner.id_number"].search( | ||
[("category_id", "in", rec.ids)] | ||
) | ||
unique_numbers = set(ids.mapped("name")) | ||
if len(ids) != len(unique_numbers): | ||
raise ValidationError( | ||
self.env._( | ||
"The category %s can not be set to use unique numbers, " | ||
"because it already contains duplicates.", | ||
rec.name, | ||
) | ||
) |
31 changes: 31 additions & 0 deletions
31
partner_identification_unique_by_category/models/res_partner_id_number.py
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 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo import api, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class ResPartnerIdNumber(models.Model): | ||
_inherit = "res.partner.id_number" | ||
_description = "Partner ID Number" | ||
_order = "name" | ||
|
||
@api.constrains("name", "category_id") | ||
def validate_id_number(self): | ||
# pylint: disable=W8110 | ||
super().validate_id_number() | ||
for rec in self: | ||
if not rec.category_id.has_unique_numbers: | ||
continue | ||
count = self.search_count( | ||
[("name", "=", rec.name), ("category_id", "in", rec.category_id.ids)] | ||
) | ||
if count > 1: | ||
raise ValidationError( | ||
self.env._( | ||
"The Id %(name)s in the category %(category_name)s " | ||
"could not be created because it already exists", | ||
name=rec.name, | ||
category_name=rec.category_id.name, | ||
) | ||
) |
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,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
2 changes: 2 additions & 0 deletions
2
partner_identification_unique_by_category/readme/CONTRIBUTORS.md
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,2 @@ | ||
- Thierry Ducrest \<<thierry.ducrest@camptocamp.com>\> | ||
- Chau Le \<<chaulb@trobz.com>\> |
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 @@ | ||
The migration of this module from 14.0 to 18.0 was financially supported by Camptocamp. |
2 changes: 2 additions & 0 deletions
2
partner_identification_unique_by_category/readme/DESCRIPTION.md
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,2 @@ | ||
This module extends the module partner_identification to enforce having | ||
unique id numbers by categories. This option can be set by category. |
Binary file added
BIN
+9.23 KB
partner_identification_unique_by_category/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.