Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2fa195d

Browse files
committedMar 13, 2025·
[ADD] stock_route_location_source: Migration to 18.0 split feature from stock_helper
1 parent f6bd62c commit 2fa195d

24 files changed

+171
-283
lines changed
 

‎stock_helper/__manifest__.py

-16
This file was deleted.

‎stock_helper/i18n/hr.po

-23
This file was deleted.

‎stock_helper/i18n/it.po

-22
This file was deleted.

‎stock_helper/i18n/stock_helper.pot

-19
This file was deleted.

‎stock_helper/models/__init__.py

-1
This file was deleted.

‎stock_helper/models/stock_location.py

-38
This file was deleted.

‎stock_helper/readme/CONTRIBUTORS.md

-2
This file was deleted.

‎stock_helper/readme/DESCRIPTION.md

-2
This file was deleted.

‎stock_helper/tests/__init__.py

-2
This file was deleted.

‎stock_helper/tests/common.py

-19
This file was deleted.

‎stock_helper/tests/test_location_is_sublocation_of.py

-48
This file was deleted.

‎stock_helper/tests/test_location_source_from_route.py

-54
This file was deleted.

‎stock_helper/README.rst ‎stock_route_location_source/README.rst

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
=============
2-
Stock Helpers
3-
=============
1+
===========================
2+
Stock Route Location Source
3+
===========================
44

55
..
66
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:fb518cc48413d9879c043a9164bdaf25cee06d723fb62343a910233620a2c893
10+
!! source digest: sha256:a664ab61d30f26747d004db1f98084e755c1a3434a16ddc4898f5b31c91344d2
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
@@ -17,13 +17,13 @@ Stock Helpers
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%2Fstock--logistics--warehouse-lightgray.png?logo=github
20-
:target: https://github.com/OCA/stock-logistics-warehouse/tree/17.0/stock_helper
20+
:target: https://github.com/OCA/stock-logistics-warehouse/tree/18.0/stock_route_location_source
2121
:alt: OCA/stock-logistics-warehouse
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-17-0/stock-logistics-warehouse-17-0-stock_helper
23+
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-18-0/stock-logistics-warehouse-18-0-stock_route_location_source
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/stock-logistics-warehouse&target_branch=17.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=18.0
2727
:alt: Try me on Runboat
2828

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

4747
Do not contact contributors directly about support or help with technical issues.
4848

@@ -52,7 +52,7 @@ Credits
5252
Authors
5353
-------
5454

55-
* Camptocamp
55+
* MT Software
5656

5757
Contributors
5858
------------
@@ -73,6 +73,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
7373
mission is to support the collaborative development of Odoo features and
7474
promote its widespread use.
7575

76-
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/17.0/stock_helper>`_ project on GitHub.
76+
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/18.0/stock_route_location_source>`_ project on GitHub.
7777

7878
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2025 Michael Tietz (MT Software) <mtietz@mt-software.de>
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
{
5+
"name": "Stock Route Location Source",
6+
"summary": "Add method to get source location of Inventory Routes",
7+
"version": "18.0.1.0.0",
8+
"development_status": "Production/Stable",
9+
"author": "MT Software, Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/stock-logistics-warehouse",
11+
"category": "Hidden",
12+
"depends": ["stock"],
13+
"license": "LGPL-3",
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import stock_route
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2023 Michael Tietz (MT Software) <mtietz@mt-software.de>
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
from odoo import models
5+
6+
7+
class StockRoute(models.Model):
8+
_inherit = "stock.route"
9+
10+
def _get_source_location(self, dest_location):
11+
self.ensure_one()
12+
dest_location.ensure_one()
13+
src_location = self.env["stock.location"]
14+
while True:
15+
values = {}
16+
_dest_location = src_location or dest_location
17+
if not src_location:
18+
values["route_ids"] = self
19+
rule = self.env["procurement.group"]._get_rule(
20+
self.env["product.product"], _dest_location, values
21+
)
22+
if not rule or rule.action not in ["pull", "pull_push"]:
23+
break
24+
src_location = rule.location_src_id
25+
if rule.procure_method == "make_to_stock":
26+
break
27+
return src_location
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Michael Tietz (MT Software) <mtietz@mt-software.de>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add method to get source location of Inventory Routes

‎stock_helper/static/description/index.html ‎stock_route_location_source/static/description/index.html

+24-27
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5-
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>Stock Helpers</title>
5+
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
6+
<title>Stock Route Location Source</title>
77
<style type="text/css">
88

99
/*
1010
:Author: David Goodger (goodger@python.org)
11-
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
11+
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
1212
:Copyright: This stylesheet has been placed in the public domain.
1313
1414
Default cascading style sheet for the HTML output of Docutils.
15-
Despite the name, some widely supported CSS2 features are used.
1615
17-
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
16+
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
1817
customize this style sheet.
1918
*/
2019

@@ -275,7 +274,7 @@
275274
margin-left: 2em ;
276275
margin-right: 2em }
277276

278-
pre.code .ln { color: gray; } /* line numbers */
277+
pre.code .ln { color: grey; } /* line numbers */
279278
pre.code, code { background-color: #eeeeee }
280279
pre.code .comment, code .comment { color: #5C6576 }
281280
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +300,7 @@
301300
span.pre {
302301
white-space: pre }
303302

304-
span.problematic, pre.problematic {
303+
span.problematic {
305304
color: red }
306305

307306
span.section-subtitle {
@@ -360,63 +359,61 @@
360359
</style>
361360
</head>
362361
<body>
363-
<div class="document" id="stock-helpers">
364-
<h1 class="title">Stock Helpers</h1>
362+
<div class="document" id="stock-route-location-source">
363+
<h1 class="title">Stock Route Location Source</h1>
365364

366365
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367366
!! This file is generated by oca-gen-addon-readme !!
368367
!! changes will be overwritten. !!
369368
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:fb518cc48413d9879c043a9164bdaf25cee06d723fb62343a910233620a2c893
369+
!! source digest: sha256:a664ab61d30f26747d004db1f98084e755c1a3434a16ddc4898f5b31c91344d2
371370
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/stock-logistics-warehouse/tree/17.0/stock_helper"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-17-0/stock-logistics-warehouse-17-0-stock_helper"><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/stock-logistics-warehouse&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
371+
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" 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" href="https://github.com/OCA/stock-logistics-warehouse/tree/18.0/stock_route_location_source"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-18-0/stock-logistics-warehouse-18-0-stock_route_location_source"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373372
<p>Add methods to be used by other modules. This is not a functional
374373
module.</p>
375374
<p><strong>Table of contents</strong></p>
376375
<div class="contents local topic" id="contents">
377376
<ul class="simple">
378-
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
379-
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
380-
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
381-
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
382-
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
377+
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
378+
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
379+
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
380+
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
381+
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
383382
</ul>
384383
</li>
385384
</ul>
386385
</div>
387386
<div class="section" id="bug-tracker">
388-
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
387+
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
389388
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
390389
In case of trouble, please check there if your issue has already been reported.
391390
If you spotted it first, help us to smash it by providing a detailed and welcomed
392-
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_helper%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
391+
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_route_location_source%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
393392
<p>Do not contact contributors directly about support or help with technical issues.</p>
394393
</div>
395394
<div class="section" id="credits">
396-
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
395+
<h1><a class="toc-backref" href="#id2">Credits</a></h1>
397396
<div class="section" id="authors">
398-
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
397+
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
399398
<ul class="simple">
400-
<li>Camptocamp</li>
399+
<li>MT Software</li>
401400
</ul>
402401
</div>
403402
<div class="section" id="contributors">
404-
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
403+
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
405404
<ul class="simple">
406405
<li>Guewen Baconnier &lt;<a class="reference external" href="mailto:guewen.baconnier&#64;camptocamp.com">guewen.baconnier&#64;camptocamp.com</a>&gt;</li>
407406
<li>Christopher Ormaza &lt;<a class="reference external" href="mailto:chris.ormaza&#64;forgeflow.com">chris.ormaza&#64;forgeflow.com</a>&gt;</li>
408407
</ul>
409408
</div>
410409
<div class="section" id="maintainers">
411-
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
410+
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
412411
<p>This module is maintained by the OCA.</p>
413-
<a class="reference external image-reference" href="https://odoo-community.org">
414-
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
415-
</a>
412+
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
416413
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
417414
mission is to support the collaborative development of Odoo features and
418415
promote its widespread use.</p>
419-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/17.0/stock_helper">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
416+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/18.0/stock_route_location_source">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
420417
<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>
421418
</div>
422419
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_get_source_location
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Copyright 2022 Michael Tietz (MT Software) <mtietz@mt-software.de>
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
from odoo.tests import TransactionCase
4+
5+
6+
class TestStockRouteGetSourceLocation(TransactionCase):
7+
@classmethod
8+
def setUpClass(cls):
9+
super().setUpClass()
10+
cls.wh = cls.env.ref("stock.warehouse0")
11+
cls.stock_loc = cls.wh.lot_stock_id
12+
cls.view_loc = cls.stock_loc.location_id
13+
cls.customer_loc = cls.env.ref("stock.stock_location_customers")
14+
cls.location4, cls.operation_type4, cls.route4 = cls.create_type_route_and_rule(
15+
"4", cls.customer_loc
16+
)
17+
cls.location3, cls.operation_type3, cls.route3 = cls.create_type_route_and_rule(
18+
"3", cls.location4
19+
)
20+
cls.location2, cls.operation_type2, cls.route2 = cls.create_type_route_and_rule(
21+
"2", cls.location3
22+
)
23+
cls.location1, cls.operation_type1, cls.route1 = cls.create_type_route_and_rule(
24+
"1",
25+
cls.location2,
26+
)
27+
_, cls.operation_type_pick, cls.route_pick = cls.create_type_route_and_rule(
28+
"pick", cls.location1, "make_to_stock", location_src=cls.stock_loc
29+
)
30+
31+
@classmethod
32+
def create_type_route_and_rule(
33+
cls, suffix, location_dest, procure_method="make_to_order", location_src=None
34+
):
35+
location_src = location_src or cls.stock_loc.create(
36+
{"name": f"location{suffix}", "location_id": cls.view_loc.id}
37+
)
38+
operation_type_name = f"operationtype{suffix}"
39+
operation_type = cls.env["stock.picking.type"].create(
40+
{
41+
"name": operation_type_name,
42+
"sequence_code": operation_type_name,
43+
"code": "internal",
44+
"default_location_src_id": location_src.id,
45+
"default_location_dest_id": location_dest.id,
46+
}
47+
)
48+
route_name = f"route{suffix}"
49+
rule_name = f"{route_name} rule{suffix}"
50+
route = cls.env["stock.route"].create(
51+
{
52+
"name": route_name,
53+
"warehouse_ids": [(6, 0, cls.wh.ids)],
54+
"rule_ids": [
55+
(
56+
0,
57+
0,
58+
{
59+
"name": rule_name,
60+
"location_src_id": location_src.id,
61+
"location_dest_id": location_dest.id,
62+
"picking_type_id": operation_type.id,
63+
"procure_method": procure_method,
64+
},
65+
)
66+
],
67+
}
68+
)
69+
return location_src, operation_type, route
70+
71+
def test_get_source_location(self):
72+
source_location = self.route4._get_source_location(self.location4)
73+
self.assertEqual(source_location, self.stock_loc)
74+
75+
source_location = self.route3._get_source_location(self.location3)
76+
self.assertEqual(source_location, self.stock_loc)
77+
78+
source_location = self.route2._get_source_location(self.location2)
79+
self.assertEqual(source_location, self.stock_loc)
80+
81+
source_location = self.route1._get_source_location(self.location1)
82+
self.assertEqual(source_location, self.stock_loc)
83+
84+
# Location is not in route but a valid route is found
85+
# and will return stock location
86+
source_location = self.route1._get_source_location(self.location4)
87+
self.assertEqual(source_location, self.stock_loc)
88+
89+
# Changing the procure_method on rule2
90+
self.route2.rule_ids.procure_method = "make_to_stock"
91+
source_location = self.route4._get_source_location(self.location4)
92+
self.assertEqual(source_location, self.location2)

0 commit comments

Comments
 (0)
Please sign in to comment.