Skip to content
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
wants to merge 32 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Feb 9, 2021
76f77f4
Apply suggestions from code review
guewen Feb 11, 2021
0654d07
[UPD] Update stock_helper.pot
oca-travis Feb 11, 2021
cc44e15
[UPD] README.rst
OCA-git-bot Feb 11, 2021
617fb14
[ADD] icon.png
OCA-git-bot Feb 11, 2021
48e080a
stock_helper 13.0.1.1.0
OCA-git-bot Feb 11, 2021
c4a720f
[MIG] stock_helper: Migration to 14.0
DavidBForgeFlow Mar 19, 2021
918d211
[UPD] Update stock_helper.pot
oca-travis Mar 23, 2021
f4833f9
[UPD] README.rst
OCA-git-bot Mar 23, 2021
39f872d
[15.0][MIG] stock_helper
ChrisOForgeFlow Dec 10, 2021
20c3ef8
[UPD] Update stock_helper.pot
Dec 20, 2021
6d7dd1f
[UPD] README.rst
OCA-git-bot Dec 20, 2021
67ec923
[MIG] stock_helper: Migration to 16.0
lmignon Nov 7, 2022
9e53465
[UPD] Update stock_helper.pot
Nov 14, 2022
f6f5247
[UPD] README.rst
OCA-git-bot Nov 14, 2022
c2bd866
stock_helper 16.0.1.0.1
OCA-git-bot Nov 14, 2022
5d48da3
Added translation using Weblate (Croatian)
badbole Feb 16, 2023
ffa62bd
Translated using Weblate (Croatian)
badbole Feb 16, 2023
421dee7
[IMP] stock_helper: add location._get_source_location_from_route
mt-software-de Apr 17, 2023
7aeb508
stock_helper 16.0.1.1.0
OCA-git-bot Apr 26, 2023
6d111c9
[UPD] README.rst
OCA-git-bot Sep 3, 2023
2451d55
Added translation using Weblate (Italian)
mymage Nov 17, 2023
74021a5
Translated using Weblate (Italian)
mymage Nov 21, 2023
4b05c89
[IMP] stock_helper: pre-commit auto fixes
CarlosVForgeFlow Mar 14, 2024
fa3916e
[MIG] stock_helper: Migration to 17.0
CarlosVForgeFlow Mar 15, 2024
738b9bc
[UPD] Update stock_helper.pot
Jun 13, 2024
774bc19
[BOT] post-merge updates
OCA-git-bot Jun 13, 2024
55e640c
[UPD] stock_helper: bump development status
LoisRForgeFlow Jul 1, 2024
46ae108
[BOT] post-merge updates
OCA-git-bot Jul 1, 2024
b8b4466
[FIX] stock_helper: fix tests based on modules installed
LoisRForgeFlow Dec 12, 2024
2230932
[BOT] post-merge updates
OCA-git-bot Dec 13, 2024
cf93f34
[MIG] stock_helper: Migration to 18.0
JasminSForgeFlow Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions stock_helper/README.rst
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.
1 change: 1 addition & 0 deletions stock_helper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions stock_helper/__manifest__.py
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",
}
23 changes: 23 additions & 0 deletions stock_helper/i18n/hr.po
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"
22 changes: 22 additions & 0 deletions stock_helper/i18n/it.po
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"
19 changes: 19 additions & 0 deletions stock_helper/i18n/stock_helper.pot
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 ""
1 change: 1 addition & 0 deletions stock_helper/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_location
50 changes: 50 additions & 0 deletions stock_helper/models/stock_location.py
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):
Copy link
Contributor

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 on stock.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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
3 changes: 3 additions & 0 deletions stock_helper/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions stock_helper/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Guewen Baconnier \<<[email protected]>\>
- Christopher Ormaza \<<[email protected]>\>
2 changes: 2 additions & 0 deletions stock_helper/readme/DESCRIPTION.md
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.
Binary file added stock_helper/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading