diff --git a/stock_picking_show_linked/__manifest__.py b/stock_picking_show_linked/__manifest__.py index 0f10fb16ff4..c1cefdc338e 100644 --- a/stock_picking_show_linked/__manifest__.py +++ b/stock_picking_show_linked/__manifest__.py @@ -1,4 +1,5 @@ # Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) { "name": "Stock Picking Show Linked", "summary": """ diff --git a/stock_picking_show_linked/models/stock_picking.py b/stock_picking_show_linked/models/stock_picking.py index 0507062d1c2..f93845ddfe1 100644 --- a/stock_picking_show_linked/models/stock_picking.py +++ b/stock_picking_show_linked/models/stock_picking.py @@ -1,4 +1,5 @@ # Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) from odoo import api, fields, models @@ -9,22 +10,26 @@ class StockPicking(models.Model): dest_picking_count = fields.Integer(compute="_compute_picking_count") origin_picking_count = fields.Integer(compute="_compute_picking_count") - @api.depends("move_ids") + @api.depends("move_ids.move_orig_ids", "move_ids.move_dest_ids") def _compute_picking_count(self): for record in self: origin_pickings = record.mapped("move_ids.move_orig_ids.picking_id") dest_pickings = record.mapped("move_ids.move_dest_ids.picking_id") - record.origin_picking_count = len(origin_pickings) - record.dest_picking_count = len(dest_pickings) - - def _get_action_link(self, pickings): + record.update( + { + "origin_picking_count": len(origin_pickings), + "dest_picking_count": len(dest_pickings), + } + ) + + def _get_action_link(self, picking_ids): result = self.env["ir.actions.actions"]._for_xml_id( "stock.action_picking_tree_all" ) # choose the view_mode accordingly - if not pickings or len(pickings) > 1: - result["domain"] = f"[('id','in',{pickings})]" - elif len(pickings) == 1: + if not picking_ids or len(picking_ids) > 1: + result["domain"] = f"[('id','in',{picking_ids})]" + elif len(picking_ids) == 1: res = self.env.ref("stock.view_picking_form", False) form_view = [(res and res.id or False, "form")] if "views" in result: @@ -33,7 +38,7 @@ def _get_action_link(self, pickings): ] else: result["views"] = form_view - result["res_id"] = pickings[0] + result["res_id"] = picking_ids[0] return result def action_stock_picking_origin(self): diff --git a/stock_picking_show_linked/views/stock_picking.xml b/stock_picking_show_linked/views/stock_picking.xml index 50d7ee87339..ee627965526 100644 --- a/stock_picking_show_linked/views/stock_picking.xml +++ b/stock_picking_show_linked/views/stock_picking.xml @@ -1,4 +1,6 @@ + stock_picking_show_linked.form