Skip to content

Commit

Permalink
[MIG] partner_identification_unique_by_category: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chaule97 committed Oct 25, 2024
1 parent d7a57f3 commit 0cac5b8
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 20 deletions.
9 changes: 8 additions & 1 deletion partner_identification_unique_by_category/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,19 @@ Credits
Authors
-------

* Camptocamp SA
* Camptocamp

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
-----------
Expand Down
4 changes: 2 additions & 2 deletions partner_identification_unique_by_category/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "Partner Identification Numbers Unique By Category",
"category": "Customer Relationship Management",
"version": "14.0.1.0.1",
"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)",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact",
"development_status": "Production/Stable",
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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 import api, fields, models
from odoo.exceptions import ValidationError


Expand All @@ -24,8 +24,9 @@ def validate_must_be_unique(self):
unique_numbers = set(ids.mapped("name"))
if len(ids) != len(unique_numbers):
raise ValidationError(
_(
"The category {} can not be set to use unique numbers, "
"because it already contains duplicates."
).format(rec.name)
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
@@ -1,7 +1,7 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import _, api, models
from odoo import api, models
from odoo.exceptions import ValidationError


Expand All @@ -12,6 +12,7 @@ class ResPartnerIdNumber(models.Model):

@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:
Expand All @@ -21,8 +22,10 @@ def validate_id_number(self):
)
if count > 1:
raise ValidationError(
_(
"The Id {} in the category {} could not be created because "
"it already exists"
).format(rec.name, rec.category_id.name)
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,
)
)
Original file line number Diff line number Diff line change
@@ -1 +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
Expand Up @@ -379,7 +379,8 @@ <h1 class="title">Partner Identification Numbers Unique By Category</h1>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-5">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
Expand All @@ -397,17 +398,23 @@ <h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<ul class="simple">
<li>Camptocamp SA</li>
<li>Camptocamp</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>Thierry Ducrest &lt;<a class="reference external" href="mailto:thierry.ducrest&#64;camptocamp.com">thierry.ducrest&#64;camptocamp.com</a>&gt;</li>
<li>Chau Le &lt;<a class="reference external" href="mailto:chaulb&#64;trobz.com">chaulb&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-5">Other credits</a></h2>
<p>The migration of this module from 14.0 to 18.0 was financially supported
by Camptocamp.</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo.exceptions import ValidationError
from odoo.tests.common import SavepointCase

from odoo.addons.base.tests.common import BaseCommon

class TestPartnerIdentificationUniqueByCategory(SavepointCase):

class TestPartnerIdentificationUniqueByCategory(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down Expand Up @@ -67,7 +68,6 @@ def test_category_unique_activation(self):
"partner_id": self.partner_1.id,
}
)
self.category_1.has_unique_numbers = True
self.category_1.has_unique_numbers = False
self.env["res.partner.id_number"].create(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</field>
</record>
<record model="ir.ui.view" id="view_partner_id_category_tree">
<field name="name">res.partner.id_category.tree</field>
<field name="name">res.partner.id_category.list</field>
<field name="model">res.partner.id_category</field>
<field
name="inherit_id"
Expand Down

0 comments on commit 0cac5b8

Please sign in to comment.