Skip to content

Commit d0bbcf1

Browse files
committed
Merge PR #2181 into 18.0
Signed-off-by NL66278
2 parents 8869c6a + 761b5ff commit d0bbcf1

12 files changed

Lines changed: 653 additions & 0 deletions

File tree

partner_rank_single/README.rst

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
===================
2+
Partner Rank Single
3+
===================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:09d036807482ee3c651a0348ac22d5a60ddd2298c0415edcb6f93862ac76ead3
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
20+
:target: https://github.com/OCA/partner-contact/tree/18.0/partner_rank_single
21+
:alt: OCA/partner-contact
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_rank_single
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module introduces a constraint to ensure that a contact cannot
32+
simultaneously be both a customer and a supplier.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Bug Tracker
40+
===========
41+
42+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/issues>`_.
43+
In case of trouble, please check there if your issue has already been reported.
44+
If you spotted it first, help us to smash it by providing a detailed and welcomed
45+
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_rank_single%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
46+
47+
Do not contact contributors directly about support or help with technical issues.
48+
49+
Credits
50+
=======
51+
52+
Authors
53+
-------
54+
55+
* Camptocamp
56+
57+
Contributors
58+
------------
59+
60+
- Ivan Todorovich <ivan.todorovich@camptocamp.com>
61+
- Maksym Yankin <maksym.yankin@camptocamp.com>
62+
63+
Other credits
64+
-------------
65+
66+
- Camptocamp
67+
68+
Maintainers
69+
-----------
70+
71+
This module is maintained by the OCA.
72+
73+
.. image:: https://odoo-community.org/logo.png
74+
:alt: Odoo Community Association
75+
:target: https://odoo-community.org
76+
77+
OCA, or the Odoo Community Association, is a nonprofit organization whose
78+
mission is to support the collaborative development of Odoo features and
79+
promote its widespread use.
80+
81+
.. |maintainer-ivantodorovich| image:: https://github.com/ivantodorovich.png?size=40px
82+
:target: https://github.com/ivantodorovich
83+
:alt: ivantodorovich
84+
.. |maintainer-yankinmax| image:: https://github.com/yankinmax.png?size=40px
85+
:target: https://github.com/yankinmax
86+
:alt: yankinmax
87+
88+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
89+
90+
|maintainer-ivantodorovich| |maintainer-yankinmax|
91+
92+
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/18.0/partner_rank_single>`_ project on GitHub.
93+
94+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

partner_rank_single/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2025 Camptocamp SA
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
{
5+
"name": "Partner Rank Single",
6+
"summary": "Introduce single rank for partners.",
7+
"version": "18.0.1.0.0",
8+
"category": "Partner Management",
9+
"website": "https://github.com/OCA/partner-contact",
10+
"author": "Camptocamp, Odoo Community Association (OCA)",
11+
"license": "AGPL-3",
12+
"installable": True,
13+
"maintainers": ["ivantodorovich", "yankinmax"],
14+
"depends": ["account"],
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import res_partner
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2025 Camptocamp SA
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import api, models
5+
from odoo.exceptions import ValidationError
6+
7+
8+
class Contact(models.Model):
9+
_inherit = "res.partner"
10+
11+
@api.constrains("customer_rank", "supplier_rank")
12+
def _constrains_single_rank(self):
13+
for record in self:
14+
if record.customer_rank > 0 and record.supplier_rank > 0:
15+
raise ValidationError(
16+
self.env._("A contact cannot be both a customer and a supplier.")
17+
)
18+
19+
def _increase_rank(self, field, n=1):
20+
# OVERRIDE: to check single rank
21+
# Because of direct SQL update in the super method
22+
res = super()._increase_rank(field, n=n)
23+
self._constrains_single_rank()
24+
return res

partner_rank_single/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Ivan Todorovich \<<ivan.todorovich@camptocamp.com>\>
2+
- Maksym Yankin \<<maksym.yankin@camptocamp.com>\>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Camptocamp
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module introduces a constraint to ensure that a contact cannot simultaneously be both a customer and a supplier.

0 commit comments

Comments
 (0)