-
-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] stock_helper: Migration to 18.0
- Loading branch information
1 parent
2230932
commit cf93f34
Showing
5 changed files
with
38 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,13 @@ Stock Helpers | |
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github | ||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/17.0/stock_helper | ||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/18.0/stock_helper | ||
:alt: OCA/stock-logistics-warehouse | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-17-0/stock-logistics-warehouse-17-0-stock_helper | ||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-18-0/stock-logistics-warehouse-18-0-stock_helper | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=17.0 | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=18.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
@@ -42,7 +42,7 @@ Bug Tracker | |
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`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**>`_. | ||
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_helper%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
|
@@ -57,8 +57,8 @@ Authors | |
Contributors | ||
------------ | ||
|
||
- Guewen Baconnier <[email protected]> | ||
- Christopher Ormaza <[email protected]> | ||
- Guewen Baconnier <[email protected]> | ||
- Christopher Ormaza <[email protected]> | ||
|
||
Maintainers | ||
----------- | ||
|
@@ -73,6 +73,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose | |
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
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. | ||
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/18.0/stock_helper>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# Copyright 2022-2023 Michael Tietz (MT Software) <[email protected]> | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from odoo import models | ||
from odoo import api, models | ||
|
||
|
||
class StockLocation(models.Model): | ||
|
@@ -20,19 +20,31 @@ def is_sublocation_of(self, others, func=any): | |
# below one of the other location without using SQL. | ||
return func(self.parent_path.startswith(other.parent_path) for other in others) | ||
|
||
@api.model | ||
def _get_stock_rule(self, location, route, procure_method): | ||
Rule = self.env["stock.rule"] | ||
res = Rule.search( | ||
[ | ||
("route_id", "=", route.id), | ||
("location_dest_id", "=", location.id), | ||
("procure_method", "=", procure_method), | ||
], | ||
limit=1, | ||
) | ||
if not res: | ||
res = Rule.search( | ||
[ | ||
("route_id", "=", route.id), | ||
("location_src_id", "=", location.id), | ||
], | ||
limit=1, | ||
) | ||
return res | ||
|
||
def _get_source_location_from_route(self, route, procure_method): | ||
self.ensure_one() | ||
route.ensure_one() | ||
values = { | ||
"route_ids": route, | ||
} | ||
current_location = self | ||
while current_location: | ||
rule = self.env["procurement.group"]._get_rule( | ||
self.env["product.product"], current_location, values | ||
) | ||
if not rule: | ||
return self.browse() | ||
if rule.procure_method == procure_method: | ||
return rule.location_src_id | ||
current_location = rule.location_src_id | ||
rule = self._get_stock_rule(self, route, procure_method) | ||
if not rule: | ||
return self.browse() | ||
return rule.location_src_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters