diff --git a/bemade_picking_upstream/__init__.py b/bemade_picking_upstream/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/bemade_picking_upstream/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/bemade_picking_upstream/__manifest__.py b/bemade_picking_upstream/__manifest__.py new file mode 100644 index 0000000..67a5ba2 --- /dev/null +++ b/bemade_picking_upstream/__manifest__.py @@ -0,0 +1,32 @@ +# +# Bemade Inc. +# +# Copyright (C) 2023-June Bemade Inc. (). +# Author: Marc Durepos (Contact : marc@bemade.org) +# +# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) +# It is forbidden to publish, distribute, sublicense, or sell copies of the Software +# or modified copies of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +{ + "name": "Show Upstream Pickings", + "version": "18.0.1.0.0", + "summary": "Show upstream pickings when a picking is waiting on other moves.", + "category": "Stock", + "author": "Bemade Inc.", + "website": "http://www.bemade.org", + "license": "LGPL-3", + "depends": ["stock"], + "data": ["views/stock_picking_views.xml"], + "assets": {}, + "installable": True, + "auto_install": False, +} diff --git a/bemade_picking_upstream/models/__init__.py b/bemade_picking_upstream/models/__init__.py new file mode 100644 index 0000000..ae4c272 --- /dev/null +++ b/bemade_picking_upstream/models/__init__.py @@ -0,0 +1 @@ +from . import stock_picking diff --git a/bemade_picking_upstream/models/stock_picking.py b/bemade_picking_upstream/models/stock_picking.py new file mode 100644 index 0000000..8573b8b --- /dev/null +++ b/bemade_picking_upstream/models/stock_picking.py @@ -0,0 +1,37 @@ +from odoo import models, fields, api + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + upstream_picking_ids = fields.One2many( + compute="_compute_upstream_picking_ids", + comodel_name="stock.picking", + string="Upstream Transfers", + help="Transfers that this transfer depends on for stock availability.", + compute_sudo=True, + ) + + upstream_picking_count = fields.Integer( + compute="_compute_upstream_picking_ids", + compute_sudo=True, + ) + + @api.depends( + "move_ids", "move_ids.move_orig_ids", "move_ids.move_orig_ids.picking_id" + ) + def _compute_upstream_picking_ids(self): + for rec in self: + rec.upstream_picking_ids = ( + rec.move_ids.mapped("move_orig_ids").mapped("picking_id") - rec + ) + rec.upstream_picking_count = len(rec.upstream_picking_ids) + + def action_view_upstream_transfers(self): + return { + "name": "Upstream Transfers", + "type": "ir.actions.act_window", + "res_model": "stock.picking", + "domain": [("id", "in", self.upstream_picking_ids.ids)], + "view_mode": "list,kanban,form,calendar,map", + } diff --git a/bemade_picking_upstream/views/stock_picking_views.xml b/bemade_picking_upstream/views/stock_picking_views.xml new file mode 100644 index 0000000..b887777 --- /dev/null +++ b/bemade_picking_upstream/views/stock_picking_views.xml @@ -0,0 +1,14 @@ + + + + + stock.picking + + + + +