Skip to content

Commit 02a0dac

Browse files
[MIG] sale_operating_unit: Migration to 18.0
1 parent 7cb7cdc commit 02a0dac

File tree

8 files changed

+83
-28
lines changed

8 files changed

+83
-28
lines changed

sale_operating_unit/README.rst

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Operating Unit in Sales
1717
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1818
:alt: License: LGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
20-
:target: https://github.com/OCA/operating-unit/tree/17.0/sale_operating_unit
20+
:target: https://github.com/OCA/operating-unit/tree/18.0/sale_operating_unit
2121
:alt: OCA/operating-unit
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/operating-unit-17-0/operating-unit-17-0-sale_operating_unit
23+
:target: https://translation.odoo-community.org/projects/operating-unit-18-0/operating-unit-18-0-sale_operating_unit
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&target_branch=17.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&target_branch=18.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -61,7 +61,7 @@ Bug Tracker
6161
Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/issues>`_.
6262
In case of trouble, please check there if your issue has already been reported.
6363
If you spotted it first, help us to smash it by providing a detailed and welcomed
64-
`feedback <https://github.com/OCA/operating-unit/issues/new?body=module:%20sale_operating_unit%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
64+
`feedback <https://github.com/OCA/operating-unit/issues/new?body=module:%20sale_operating_unit%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
6565

6666
Do not contact contributors directly about support or help with technical issues.
6767

@@ -77,15 +77,18 @@ Authors
7777
Contributors
7878
------------
7979

80-
- Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
81-
- Aaron Henriquez <ahforgeflow@forgeflow.com>
82-
- Lois Rilo <lois.rilo@forgeflow.com>
83-
- Miquel Raich <miquel.raich@forgeflow.com>
84-
- Sudhir Arya <sudhir.arya@serpentcs.com>
85-
- Darshan Patel <darshan.patel.serpencs@gmail.com>
86-
- Alan Ramos <alan.ramos@jarsa.com.mx>
87-
- Jorge Alberto Olvera Cuenca <jorge.olvera@jarsa.com>
88-
- Alejandro Padrón <alejandro.padron@bt-group.com>
80+
- Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
81+
- Aaron Henriquez <ahforgeflow@forgeflow.com>
82+
- Lois Rilo <lois.rilo@forgeflow.com>
83+
- Miquel Raich <miquel.raich@forgeflow.com>
84+
- Sudhir Arya <sudhir.arya@serpentcs.com>
85+
- Darshan Patel <darshan.patel.serpencs@gmail.com>
86+
- Alan Ramos <alan.ramos@jarsa.com.mx>
87+
- Jorge Alberto Olvera Cuenca <jorge.olvera@jarsa.com>
88+
- Alejandro Padrón <alejandro.padron@bt-group.com>
89+
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__
90+
91+
- Bhavesh Heliconia
8992

9093
Maintainers
9194
-----------
@@ -100,6 +103,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
100103
mission is to support the collaborative development of Odoo features and
101104
promote its widespread use.
102105

103-
This module is part of the `OCA/operating-unit <https://github.com/OCA/operating-unit/tree/17.0/sale_operating_unit>`_ project on GitHub.
106+
This module is part of the `OCA/operating-unit <https://github.com/OCA/operating-unit/tree/18.0/sale_operating_unit>`_ project on GitHub.
104107

105108
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

sale_operating_unit/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
55
{
66
"name": "Operating Unit in Sales",
7-
"version": "17.0.1.0.0",
7+
"version": "18.0.1.0.0",
88
"summary": "An operating unit (OU) is an organizational entity part of a "
99
"company",
1010
"author": "ForgeFlow, "

sale_operating_unit/models/crm_team.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# - Jordi Ballester Alomar
33
# © 2019 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
44
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
5-
from odoo import SUPERUSER_ID, _, api, models
5+
from odoo import SUPERUSER_ID, api, models
66
from odoo.exceptions import ValidationError
77

88

@@ -24,7 +24,7 @@ def _check_sales_order_operating_unit(self):
2424
)
2525
if orders:
2626
raise ValidationError(
27-
_(
27+
self.env._(
2828
"Configuration error. It is not "
2929
"possible to change this "
3030
"team. There are sale orders "

sale_operating_unit/models/sale_order.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# - Jordi Ballester Alomar
33
# © 2019 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
44
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
5-
from odoo import _, api, fields, models
5+
from odoo import api, fields, models
66
from odoo.exceptions import ValidationError
77

88

@@ -68,7 +68,7 @@ def _check_team_operating_unit(self):
6868
for rec in self:
6969
if rec.team_id and rec.team_id.operating_unit_id != rec.operating_unit_id:
7070
raise ValidationError(
71-
_(
71+
self.env._(
7272
"Configuration error. The Operating "
7373
"Unit of the sales team must match "
7474
"with that of the quote/sales order."

sale_operating_unit/readme/CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
- Alan Ramos \<<alan.ramos@jarsa.com.mx>\>
88
- Jorge Alberto Olvera Cuenca \<<jorge.olvera@jarsa.com>\>
99
- Alejandro Padrón \<<alejandro.padron@bt-group.com>\>
10+
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
11+
- Bhavesh Heliconia

sale_operating_unit/static/description/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ <h1 class="title">Operating Unit in Sales</h1>
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370370
!! source digest: sha256:3213285322c7ae5f333caf42c36bbbef3b229f3235f1c7062918e291a63cc81a
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/operating-unit/tree/17.0/sale_operating_unit"><img alt="OCA/operating-unit" src="https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/operating-unit-17-0/operating-unit-17-0-sale_operating_unit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/operating-unit/tree/18.0/sale_operating_unit"><img alt="OCA/operating-unit" src="https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/operating-unit-18-0/operating-unit-18-0-sale_operating_unit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module extends the Sales capabilities of Odoo and introduces the
374374
operating unit to the Sales Order. Security rules are defined to ensure
375375
that users can only display the Sales Orders in which they are allowed
@@ -409,7 +409,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
409409
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/operating-unit/issues">GitHub Issues</a>.
410410
In case of trouble, please check there if your issue has already been reported.
411411
If you spotted it first, help us to smash it by providing a detailed and welcomed
412-
<a class="reference external" href="https://github.com/OCA/operating-unit/issues/new?body=module:%20sale_operating_unit%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
412+
<a class="reference external" href="https://github.com/OCA/operating-unit/issues/new?body=module:%20sale_operating_unit%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
413413
<p>Do not contact contributors directly about support or help with technical issues.</p>
414414
</div>
415415
<div class="section" id="credits">
@@ -433,6 +433,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
433433
<li>Alan Ramos &lt;<a class="reference external" href="mailto:alan.ramos&#64;jarsa.com.mx">alan.ramos&#64;jarsa.com.mx</a>&gt;</li>
434434
<li>Jorge Alberto Olvera Cuenca &lt;<a class="reference external" href="mailto:jorge.olvera&#64;jarsa.com">jorge.olvera&#64;jarsa.com</a>&gt;</li>
435435
<li>Alejandro Padrón &lt;<a class="reference external" href="mailto:alejandro.padron&#64;bt-group.com">alejandro.padron&#64;bt-group.com</a>&gt;</li>
436+
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a><ul>
437+
<li>Bhavesh Heliconia</li>
438+
</ul>
439+
</li>
436440
</ul>
437441
</div>
438442
<div class="section" id="maintainers">
@@ -444,7 +448,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
444448
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
445449
mission is to support the collaborative development of Odoo features and
446450
promote its widespread use.</p>
447-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/operating-unit/tree/17.0/sale_operating_unit">OCA/operating-unit</a> project on GitHub.</p>
451+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/operating-unit/tree/18.0/sale_operating_unit">OCA/operating-unit</a> project on GitHub.</p>
448452
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
449453
</div>
450454
</div>

sale_operating_unit/tests/test_sale_operating_unit.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# © 2019 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
44
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
55

6+
from odoo.exceptions import ValidationError
67
from odoo.models import Command
78

89
from odoo.addons.operating_unit.tests.common import OperatingUnitCommon
@@ -83,7 +84,11 @@ def _create_sale_team(cls, uid, operating_unit):
8384
cls.sale_team_model.with_user(uid)
8485
.with_context(mail_create_nosubscribe=True)
8586
.create(
86-
{"name": operating_unit.name, "operating_unit_id": operating_unit.id}
87+
{
88+
"name": operating_unit.name,
89+
"operating_unit_id": operating_unit.id,
90+
"company_id": operating_unit.company_id.id,
91+
}
8792
)
8893
)
8994
return team
@@ -166,3 +171,49 @@ def test_security_2(self):
166171
self.assertEqual(
167172
len(sale.ids), 1, f"User 1 should have access to OU {self.b2c.name}"
168173
)
174+
175+
def test_check_sales_order_operating_unit(self):
176+
"""Test that changing the operating unit of a sales team
177+
with existing sale orders raises an error."""
178+
with self.assertRaises(ValidationError):
179+
self.sale_team_ou1.operating_unit_id = self.b2c.id
180+
181+
def test_compute_operating_unit_id(self):
182+
"""Test that changing the sales team updates the
183+
operating unit in sale order."""
184+
sale_order = self.sale_model.create(
185+
{
186+
"partner_id": self.customer.id,
187+
"team_id": self.sale_team_ou1.id,
188+
}
189+
)
190+
self.assertEqual(sale_order.operating_unit_id, self.ou1)
191+
sale_order.team_id = self.sale_team_b2c.id
192+
self.assertEqual(sale_order.operating_unit_id, self.b2c)
193+
194+
def test_compute_team_id(self):
195+
"""Test that sales team resets if its operating unit does not match."""
196+
sale_order = self.sale_model.create(
197+
{
198+
"partner_id": self.customer.id,
199+
"operating_unit_id": self.ou1.id,
200+
"team_id": self.sale_team_ou1.id,
201+
}
202+
)
203+
self.assertEqual(sale_order.team_id, self.sale_team_ou1)
204+
sale_order.operating_unit_id = self.b2c.id
205+
self.assertFalse(
206+
sale_order.team_id, "Team should reset when operating unit mismatches"
207+
)
208+
209+
def test_check_team_operating_unit_violation(self):
210+
"""Test that a ValidationError is raised when the team
211+
and operating unit do not match."""
212+
with self.assertRaises(ValidationError):
213+
self.sale_model.create(
214+
{
215+
"partner_id": self.customer.id,
216+
"operating_unit_id": self.ou1.id,
217+
"team_id": self.sale_team_b2c.id,
218+
}
219+
)

sale_operating_unit/views/sale_view.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@
4747
groups="!operating_unit.group_multi_operating_unit"
4848
/>
4949
</field>
50-
<field name="analytic_account_id" position="attributes">
51-
<attribute
52-
name="domain"
53-
>['|', ('company_id', '=', False), ('company_id', '=', company_id), "|",("operating_unit_ids","in", operating_unit_id),("operating_unit_ids","=", False)]</attribute>
54-
</field>
5550
<field name="journal_id" position="attributes">
5651
<attribute
5752
name="domain"

0 commit comments

Comments
 (0)