forked from OCA/stock-logistics-warehouse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1619 from OCA/18.0
Syncing from upstream OCA/stock-logistics-warehouse (18.0)
- Loading branch information
Showing
18 changed files
with
920 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
============================= | ||
Stock Move Common Destination | ||
============================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:8ae775e2580e771eec4de492030c46f20043e9019dd9bb300f7c9e4d324278f4 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-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_move_common_dest | ||
: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_move_common_dest | ||
: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| | ||
|
||
This module adds a M2m field common_dest_move_ids on stock.move in order | ||
to compute all the moves having a chained destination move sharing the | ||
same picking as the actual move's destination move. | ||
|
||
**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_move_common_dest%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 | ||
------------ | ||
|
||
- Akim Juillerat <[email protected]> | ||
- Hughes Damry <[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_move_common_dest>`_ 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,15 @@ | ||
# Copyright 2020 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
{ | ||
"name": "Stock Move Common Destination", | ||
"summary": "Adds field for common destination moves", | ||
"version": "18.0.1.0.0", | ||
"category": "Warehouse Management", | ||
"website": "https://github.com/OCA/stock-logistics-warehouse", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": ["stock"], | ||
"data": ["views/stock_move.xml"], | ||
} |
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,42 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_move_common_dest | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2023-05-05 16:33+0000\n" | ||
"Last-Translator: Hughes Damry <[email protected]>\n" | ||
"Language-Team: none\n" | ||
"Language: fr\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.14.1\n" | ||
|
||
#. module: stock_move_common_dest | ||
#: model:ir.model.fields,help:stock_move_common_dest.field_stock_move__common_dest_move_ids | ||
msgid "" | ||
"All the stock moves having a chained destination move sharing the same " | ||
"picking as the actual move's destination move" | ||
msgstr "" | ||
"Tous les mouvements de stock ayant un mouvement de destination chaîné " | ||
"partageant le même transfert que le mouvement de destination du mouvement " | ||
"courant" | ||
|
||
#. module: stock_move_common_dest | ||
#: model:ir.model.fields,field_description:stock_move_common_dest.field_stock_move__common_dest_move_ids | ||
msgid "Common Dest Move" | ||
msgstr "Mouv. Dst. commun" | ||
|
||
#. module: stock_move_common_dest | ||
#: model_terms:ir.ui.view,arch_db:stock_move_common_dest.view_move_form_inherit | ||
msgid "Common destination moves" | ||
msgstr "Mouvements de destination communs" | ||
|
||
#. module: stock_move_common_dest | ||
#: model:ir.model,name:stock_move_common_dest.model_stock_move | ||
msgid "Stock Move" | ||
msgstr "Mouvement de stock" |
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,42 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_move_common_dest | ||
# | ||
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_move_common_dest | ||
#: model:ir.model.fields,help:stock_move_common_dest.field_stock_move__common_dest_move_ids | ||
msgid "" | ||
"All the stock moves having a chained destination move sharing the same " | ||
"picking as the actual move's destination move" | ||
msgstr "" | ||
"Tutti i movimenti che hanno un movimento di destinazione collegato, che " | ||
"condividono lo stesso prelievo del movimento di destinazione di questo " | ||
"movimento" | ||
|
||
#. module: stock_move_common_dest | ||
#: model:ir.model.fields,field_description:stock_move_common_dest.field_stock_move__common_dest_move_ids | ||
msgid "Common Dest Move" | ||
msgstr "Movimento di destinazione comune" | ||
|
||
#. module: stock_move_common_dest | ||
#: model_terms:ir.ui.view,arch_db:stock_move_common_dest.view_move_form_inherit | ||
msgid "Common destination moves" | ||
msgstr "Movimenti con destinazione comune" | ||
|
||
#. module: stock_move_common_dest | ||
#: model:ir.model,name:stock_move_common_dest.model_stock_move | ||
msgid "Stock Move" | ||
msgstr "Movimento di magazzino" |
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,36 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_move_common_dest | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 18.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_move_common_dest | ||
#: model:ir.model.fields,help:stock_move_common_dest.field_stock_move__common_dest_move_ids | ||
msgid "" | ||
"All the stock moves having a chained destination move sharing the same " | ||
"picking as the actual move's destination move" | ||
msgstr "" | ||
|
||
#. module: stock_move_common_dest | ||
#: model:ir.model.fields,field_description:stock_move_common_dest.field_stock_move__common_dest_move_ids | ||
msgid "Common Dest Move" | ||
msgstr "" | ||
|
||
#. module: stock_move_common_dest | ||
#: model_terms:ir.ui.view,arch_db:stock_move_common_dest.view_move_form_inherit | ||
msgid "Common destination moves" | ||
msgstr "" | ||
|
||
#. module: stock_move_common_dest | ||
#: model:ir.model,name:stock_move_common_dest.model_stock_move | ||
msgid "Stock Move" | ||
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_move |
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,73 @@ | ||
# Copyright 2020 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import api, fields, models | ||
from odoo.osv.expression import FALSE_DOMAIN | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
common_dest_move_ids = fields.Many2many( | ||
"stock.move", | ||
compute="_compute_common_dest_move_ids", | ||
search="_search_compute_dest_move_ids", | ||
help="All the stock moves having a chained destination move sharing the" | ||
" same picking as the actual move's destination move", | ||
) | ||
|
||
def _flush_common_dest_move_query(self): | ||
# flush is necessary before a SELECT | ||
self.flush_recordset(["move_orig_ids", "move_dest_ids"]) | ||
|
||
def _common_dest_move_query(self): | ||
sql = """SELECT smmr.move_orig_id move_id | ||
, array_agg(smmr2.move_orig_id) common_move_dest_ids | ||
FROM stock_move_move_rel smmr | ||
, stock_move sm_dest | ||
, stock_picking sp | ||
, stock_move sm_pick | ||
, stock_move_move_rel smmr2 | ||
WHERE smmr.move_dest_id = sm_dest.id | ||
AND sm_dest.picking_id = sp.id | ||
AND sp.id = sm_pick.picking_id | ||
AND sm_pick.id = smmr2.move_dest_id | ||
AND smmr.move_orig_id != smmr2.move_orig_id | ||
AND smmr.move_orig_id IN %s | ||
GROUP BY smmr.move_orig_id; | ||
""" | ||
return sql | ||
|
||
@api.depends( | ||
"move_dest_ids", | ||
"move_dest_ids.picking_id", | ||
"move_dest_ids.picking_id.move_ids", | ||
"move_dest_ids.picking_id.move_ids.move_orig_ids", | ||
) | ||
def _compute_common_dest_move_ids(self): | ||
self._flush_common_dest_move_query() | ||
sql = self._common_dest_move_query() | ||
self.env.cr.execute(sql, (tuple(self.ids),)) | ||
res = { | ||
row.get("move_id"): row.get("common_move_dest_ids") | ||
for row in self.env.cr.dictfetchall() | ||
} | ||
for move in self: | ||
common_move_ids = res.get(move.id) | ||
if common_move_ids: | ||
move.common_dest_move_ids = [(6, 0, common_move_ids)] | ||
else: | ||
move.common_dest_move_ids = [(5, 0, 0)] | ||
|
||
def _search_compute_dest_move_ids(self, operator, value): | ||
moves = self.search([("id", operator, value)]) | ||
if not moves: | ||
return FALSE_DOMAIN | ||
self._flush_common_dest_move_query() | ||
sql = self._common_dest_move_query() | ||
self.env.cr.execute(sql, (tuple(moves.ids),)) | ||
res = [ | ||
move_dest_id | ||
for row in self.env.cr.dictfetchall() | ||
for move_dest_id in row.get("common_move_dest_ids") or [] | ||
] | ||
return [("id", "in", res)] |
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 @@ | ||
- Akim Juillerat \<<[email protected]>\> | ||
- Hughes Damry \<<[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,3 @@ | ||
This module adds a M2m field common_dest_move_ids on stock.move in order | ||
to compute all the moves having a chained destination move sharing the | ||
same picking as the actual move's destination move. |
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.