Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
79 changes: 79 additions & 0 deletions stock_move_common_dest/README.rst
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:637c94d65c39f5154e9272d6a41049cf2c5ddea8993300e9eb5e503769db989f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/16.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-16-0/stock-logistics-warehouse-16-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=16.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:%2016.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 <akim.juillerat@camptocamp.com>
* Hughes Damry <hughes.damry@acsone.eu>

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/16.0/stock_move_common_dest>`_ 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_move_common_dest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions stock_move_common_dest/__manifest__.py
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": "17.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"],
}
41 changes: 41 additions & 0 deletions stock_move_common_dest/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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: 2025-09-26 14:43+0000\n"
"Last-Translator: Bastian Günther <mail@bastian-guenther.de>\n"
"Language-Team: none\n"
"Language: de\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 5.10.4\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 ""
"Alle Lagerbewegungen mit einer verketteten Zielbewegung, die denselben "
"Kommissionierungsvorgang wie die Zielbewegung der aktuellen Bewegung teilen"

#. 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 "Gemeinsame Zielbewegung"

#. 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 "Gemeinsame Zielbewegungen"

#. module: stock_move_common_dest
#: model:ir.model,name:stock_move_common_dest.model_stock_move
msgid "Stock Move"
msgstr "Lagerbewegung"
42 changes: 42 additions & 0 deletions stock_move_common_dest/i18n/fr.po
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 <hughes@damry.org>\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"
42 changes: 42 additions & 0 deletions stock_move_common_dest/i18n/it.po
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 <stefano.consolaro@mymage.it>\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"
36 changes: 36 additions & 0 deletions stock_move_common_dest/i18n/stock_move_common_dest.pot
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 16.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 ""
1 change: 1 addition & 0 deletions stock_move_common_dest/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_move
76 changes: 76 additions & 0 deletions stock_move_common_dest/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# 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):
if not self.ids:
self.common_dest_move_ids = [(5, 0, 0)]
return
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)]
3 changes: 3 additions & 0 deletions stock_move_common_dest/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_move_common_dest/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Akim Juillerat <akim.juillerat@camptocamp.com>
* Hughes Damry <hughes.damry@acsone.eu>
3 changes: 3 additions & 0 deletions stock_move_common_dest/readme/DESCRIPTION.rst
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.
Loading
Loading