Skip to content

Commit b778db3

Browse files
committed
[ADD] repair_warehouse
This module adds a Warehouse field on Repair Orders to simplify repair location selection in multi-warehouse environments. When a repair location is chosen, the warehouse is automatically determined and used to filter available locations. This makes location selection clearer and avoids cross-warehouse mistakes. A consistency rule ensures that the selected warehouse and repair location always belong to the same warehouse.
1 parent 982c7a3 commit b778db3

14 files changed

Lines changed: 690 additions & 0 deletions

File tree

repair_warehouse/README.rst

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
=========================
2+
Repair Warehouse Required
3+
=========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:32ed2355ca8ebe73af3f89fe4d3f39e829f2868c121033b7acbcd9f67d3a2d48
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%2Frepair-lightgray.png?logo=github
20+
:target: https://github.com/OCA/repair/tree/16.0/repair_warehouse
21+
:alt: OCA/repair
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/repair-16-0/repair-16-0-repair_warehouse
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/repair&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module adds a Warehouse field on Repair Orders to simplify repair
32+
location selection in multi-warehouse environments.
33+
34+
When a repair location is chosen, the warehouse is automatically
35+
determined and used to filter available locations. This makes location
36+
selection clearer and avoids cross-warehouse mistakes.
37+
38+
A consistency rule ensures that the selected warehouse and repair
39+
location always belong to the same warehouse.
40+
41+
**Table of contents**
42+
43+
.. contents::
44+
:local:
45+
46+
Bug Tracker
47+
===========
48+
49+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/repair/issues>`_.
50+
In case of trouble, please check there if your issue has already been reported.
51+
If you spotted it first, help us to smash it by providing a detailed and welcomed
52+
`feedback <https://github.com/OCA/repair/issues/new?body=module:%20repair_warehouse%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
53+
54+
Do not contact contributors directly about support or help with technical issues.
55+
56+
Credits
57+
=======
58+
59+
Authors
60+
-------
61+
62+
* ACSONE SA/NV
63+
64+
Contributors
65+
------------
66+
67+
- Souheil Bejaoui [email protected]
68+
69+
Maintainers
70+
-----------
71+
72+
This module is maintained by the OCA.
73+
74+
.. image:: https://odoo-community.org/logo.png
75+
:alt: Odoo Community Association
76+
:target: https://odoo-community.org
77+
78+
OCA, or the Odoo Community Association, is a nonprofit organization whose
79+
mission is to support the collaborative development of Odoo features and
80+
promote its widespread use.
81+
82+
.. |maintainer-sbejaoui| image:: https://github.com/sbejaoui.png?size=40px
83+
:target: https://github.com/sbejaoui
84+
:alt: sbejaoui
85+
86+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
87+
88+
|maintainer-sbejaoui|
89+
90+
This module is part of the `OCA/repair <https://github.com/OCA/repair/tree/16.0/repair_warehouse>`_ project on GitHub.
91+
92+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

repair_warehouse/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

repair_warehouse/__manifest__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2026 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Repair Warehouse Required",
6+
"summary": """This addon""",
7+
"version": "16.0.1.0.0",
8+
"license": "AGPL-3",
9+
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/repair",
11+
"depends": ["repair"],
12+
"data": ["views/repair_order.xml"],
13+
"maintainers": ["sbejaoui"],
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import repair_order
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2026 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import _, api, fields, models
5+
from odoo.exceptions import ValidationError
6+
7+
8+
class RepairOrder(models.Model):
9+
10+
_inherit = "repair.order"
11+
12+
warehouse_id = fields.Many2one(
13+
"stock.warehouse",
14+
compute="_compute_warehouse_id",
15+
store=True,
16+
readonly=True,
17+
help="Warehouse inferred from the repair location. You can override it manually, "
18+
"but it must remain consistent with the selected location.",
19+
states={"draft": [("readonly", False)]},
20+
)
21+
location_id = fields.Many2one(
22+
domain="[('warehouse_id', '=', warehouse_id)]",
23+
)
24+
25+
@api.depends("location_id")
26+
def _compute_warehouse_id(self):
27+
for rec in self:
28+
rec.warehouse_id = rec.location_id.warehouse_id
29+
30+
@api.constrains("location_id", "warehouse_id")
31+
def _check_warehouse_id(self):
32+
for rec in self:
33+
if (
34+
not rec.location_id
35+
or not rec.warehouse_id
36+
or rec.location_id.usage == "customer"
37+
):
38+
continue
39+
loc_wh = rec.location_id.warehouse_id
40+
if loc_wh != rec.warehouse_id:
41+
raise ValidationError(
42+
_(
43+
"Warehouse mismatch:\n"
44+
"- Repair location: %(loc)s (warehouse: %(loc_wh)s)\n"
45+
"- Repair order warehouse: %(order_wh)s\n\n"
46+
"Please select a location belonging to the same warehouse, "
47+
"or change the warehouse to match the location."
48+
)
49+
% {
50+
"loc": rec.location_id.display_name,
51+
"loc_wh": loc_wh.display_name,
52+
"order_wh": rec.warehouse_id.display_name,
53+
}
54+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Souheil Bejaoui <[email protected]>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This module adds a Warehouse field on Repair Orders to simplify
2+
repair location selection in multi-warehouse environments.
3+
4+
When a repair location is chosen, the warehouse is automatically
5+
determined and used to filter available locations. This makes
6+
location selection clearer and avoids cross-warehouse mistakes.
7+
8+
A consistency rule ensures that the selected warehouse and
9+
repair location always belong to the same warehouse.
9.23 KB
Loading

0 commit comments

Comments
 (0)