Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] partner_identification_unique_by_category: Migration to 18.0 #1859

Open
wants to merge 12 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:98d16bef8b56dddb6baa47de906e52a643012db5d60387c2c09fac755c33f8f4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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 SA

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

- Thierry Ducrest <[email protected]>
- Chau Le <[email protected]>

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 SA, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact",
"development_status": "Production/Stable",
}
73 changes: 73 additions & 0 deletions partner_identification_unique_by_category/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 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 <[email protected]>\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__display_name
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_number__display_name
msgid "Display Name"
msgstr "Mostrar Nombre"

#. 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.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_category__id
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_number__id
msgid "ID"
msgstr "ID"

#. module: partner_identification_unique_by_category
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_category____last_update
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_number____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"

#. 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
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_number.py:0
#, 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"

#. module: partner_identification_unique_by_category
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_category.py:0
#, 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."

#. 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."
68 changes: 68 additions & 0 deletions partner_identification_unique_by_category/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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__display_name
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_number__display_name
msgid "Display Name"
msgstr ""

#. 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.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_category__id
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_number__id
msgid "ID"
msgstr ""

#. module: partner_identification_unique_by_category
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_category____last_update
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_number____last_update
msgid "Last Modified on"
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
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_number.py:0
#, python-format
msgid ""
"The Id {} in the category {} could not be created because it already exists"
msgstr ""

#. module: partner_identification_unique_by_category
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_category.py:0
#, python-format
msgid ""
"The category {} 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,67 @@
# 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: \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__display_name
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_number__display_name
msgid "Display Name"
msgstr ""

#. 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.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_category__id
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_number__id
msgid "ID"
msgstr ""

#. module: partner_identification_unique_by_category
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_category____last_update
#: model:ir.model.fields,field_description:partner_identification_unique_by_category.field_res_partner_id_number____last_update
msgid "Last Modified on"
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
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_number.py:0
#, python-format
msgid ""
"The Id {} in the category {} could not be created because it already exists"
msgstr ""

#. module: partner_identification_unique_by_category
#: code:addons/partner_identification_unique_by_category/models/res_partner_id_category.py:0
#, python-format
msgid ""
"The category {} 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,30 @@
# 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):
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 \<<[email protected]>\>
- Chau Le \<<[email protected]>\>
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
Loading