-
-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[18.0][MIG] stock_helper #2223
Open
JasminSForgeFlow
wants to merge
32
commits into
OCA:18.0
Choose a base branch
from
ForgeFlow:18.0-mig-stock_helper
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[18.0][MIG] stock_helper #2223
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
73dc762
Add stock_helper: share common code used by stock modules
guewen 76f77f4
Apply suggestions from code review
guewen 0654d07
[UPD] Update stock_helper.pot
oca-travis cc44e15
[UPD] README.rst
OCA-git-bot 617fb14
[ADD] icon.png
OCA-git-bot 48e080a
stock_helper 13.0.1.1.0
OCA-git-bot c4a720f
[MIG] stock_helper: Migration to 14.0
DavidBForgeFlow 918d211
[UPD] Update stock_helper.pot
oca-travis f4833f9
[UPD] README.rst
OCA-git-bot 39f872d
[15.0][MIG] stock_helper
ChrisOForgeFlow 20c3ef8
[UPD] Update stock_helper.pot
6d7dd1f
[UPD] README.rst
OCA-git-bot 67ec923
[MIG] stock_helper: Migration to 16.0
lmignon 9e53465
[UPD] Update stock_helper.pot
f6f5247
[UPD] README.rst
OCA-git-bot c2bd866
stock_helper 16.0.1.0.1
OCA-git-bot 5d48da3
Added translation using Weblate (Croatian)
badbole ffa62bd
Translated using Weblate (Croatian)
badbole 421dee7
[IMP] stock_helper: add location._get_source_location_from_route
mt-software-de 7aeb508
stock_helper 16.0.1.1.0
OCA-git-bot 6d111c9
[UPD] README.rst
OCA-git-bot 2451d55
Added translation using Weblate (Italian)
mymage 74021a5
Translated using Weblate (Italian)
mymage 4b05c89
[IMP] stock_helper: pre-commit auto fixes
CarlosVForgeFlow fa3916e
[MIG] stock_helper: Migration to 17.0
CarlosVForgeFlow 738b9bc
[UPD] Update stock_helper.pot
774bc19
[BOT] post-merge updates
OCA-git-bot 55e640c
[UPD] stock_helper: bump development status
LoisRForgeFlow 46ae108
[BOT] post-merge updates
OCA-git-bot b8b4466
[FIX] stock_helper: fix tests based on modules installed
LoisRForgeFlow 2230932
[BOT] post-merge updates
OCA-git-bot cf93f34
[MIG] stock_helper: Migration to 18.0
JasminSForgeFlow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
============= | ||
Stock Helpers | ||
============= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:fb518cc48413d9879c043a9164bdaf25cee06d723fb62343a910233620a2c893 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Production/Stable | ||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png | ||
: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/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-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=18.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Add methods to be used by other modules. This is not a functional | ||
module. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
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:%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. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* Camptocamp | ||
|
||
Contributors | ||
------------ | ||
|
||
- Guewen Baconnier <[email protected]> | ||
- Christopher Ormaza <[email protected]> | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
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/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2020-2021 Camptocamp SA | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
{ | ||
"name": "Stock Helpers", | ||
"summary": "Add methods shared between various stock modules", | ||
"version": "18.0.1.0.0", | ||
"development_status": "Production/Stable", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/stock-logistics-warehouse", | ||
"category": "Hidden", | ||
"depends": ["stock"], | ||
"data": [], | ||
"installable": True, | ||
"license": "LGPL-3", | ||
} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_helper | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2023-02-16 15:23+0000\n" | ||
"Last-Translator: Bole <[email protected]>\n" | ||
"Language-Team: none\n" | ||
"Language: hr\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" | ||
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" | ||
"X-Generator: Weblate 4.14.1\n" | ||
|
||
#. module: stock_helper | ||
#: model:ir.model,name:stock_helper.model_stock_location | ||
msgid "Inventory Locations" | ||
msgstr "Skladišne lokacije" |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_helper | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2023-11-21 13:33+0000\n" | ||
"Last-Translator: mymage <[email protected]>\n" | ||
"Language-Team: none\n" | ||
"Language: it\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
"X-Generator: Weblate 4.17\n" | ||
|
||
#. module: stock_helper | ||
#: model:ir.model,name:stock_helper.model_stock_location | ||
msgid "Inventory Locations" | ||
msgstr "Ubicazioni di inventario" |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_helper | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: stock_helper | ||
#: model:ir.model,name:stock_helper.model_stock_location | ||
msgid "Inventory Locations" | ||
msgstr "" |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import stock_location |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2020-2021 Camptocamp SA (http://www.camptocamp.com) | ||
# 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 api, models | ||
|
||
|
||
class StockLocation(models.Model): | ||
_inherit = "stock.location" | ||
|
||
def is_sublocation_of(self, others, func=any): | ||
"""Return True if self is a sublocation of others (or equal) | ||
|
||
By default, it return True if any other is a parent or equal. | ||
``all`` can be passed to ``func`` to require all the other locations | ||
to be parent or equal to be True. | ||
""" | ||
self.ensure_one() | ||
# Efficient way to verify that the current location is | ||
# 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() | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Guewen Baconnier \<<[email protected]>\> | ||
- Christopher Ormaza \<<[email protected]>\> |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Add methods to be used by other modules. This is not a functional | ||
module. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it strange to have that on
stock.location
and not onstock.route
. We are asking the route to return a source location given an end location.I would have moved that to a module like
stock_route_location_source
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @mt-software-de