Skip to content

Commit

Permalink
Merge pull request #1302 from OCA/18.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/partner-contact (18.0)
  • Loading branch information
bt-admin authored Oct 28, 2024
2 parents b42dbcc + 38edaee commit 64e3a26
Show file tree
Hide file tree
Showing 20 changed files with 895 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ addon | version | maintainers | summary
[base_partner_sequence](base_partner_sequence/) | 18.0.1.0.0 | | Sets customer's code from a sequence
[partner_firstname](partner_firstname/) | 18.0.1.0.0 | | Split first name and last name for non company partners
[partner_identification](partner_identification/) | 18.0.1.0.0 | | Partner Identification Numbers
[partner_identification_unique_by_category](partner_identification_unique_by_category/) | 18.0.1.0.0 | | Partner Identification Numbers Unique By Category
[partner_pricelist_search](partner_pricelist_search/) | 18.0.1.0.0 | | Partner pricelist search
[partner_ref_unique](partner_ref_unique/) | 18.0.1.0.0 | | Add an unique constraint to partner ref field
[partner_tz](partner_tz/) | 18.0.1.0.0 | | Remove partner timezone default value and display on form
Expand Down
84 changes: 84 additions & 0 deletions partner_identification_unique_by_category/README.rst
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.
1 change: 1 addition & 0 deletions partner_identification_unique_by_category/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
11 changes: 11 additions & 0 deletions partner_identification_unique_by_category/__manifest__.py
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",
}
77 changes: 77 additions & 0 deletions partner_identification_unique_by_category/i18n/es.po
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."
51 changes: 51 additions & 0 deletions partner_identification_unique_by_category/i18n/it.po
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 ""
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 ""
2 changes: 2 additions & 0 deletions partner_identification_unique_by_category/models/__init__.py
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
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,
)
)
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,
)
)
3 changes: 3 additions & 0 deletions partner_identification_unique_by_category/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
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>\>
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 64e3a26

Please sign in to comment.