From d7e3c0744545a3d1da1b04b838d3245eb18542ab Mon Sep 17 00:00:00 2001 From: yostashiro Date: Wed, 29 Apr 2026 08:35:44 +0000 Subject: [PATCH] [FIX] stock_secondary_unit: handle wrong default_move_id in MO context --- stock_secondary_unit/models/stock_move.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stock_secondary_unit/models/stock_move.py b/stock_secondary_unit/models/stock_move.py index 7493ce4..599039e 100644 --- a/stock_secondary_unit/models/stock_move.py +++ b/stock_secondary_unit/models/stock_move.py @@ -84,8 +84,12 @@ def default_get(self, fields_list): res = super().default_get(fields_list) move_id = self.env.context.get("default_move_id") or res.get("move_id") if move_id and not res.get("secondary_uom_id"): - move = self.env["stock.move"].browse(move_id) - if move.secondary_uom_id: + # default_move_id may resolve to the MO id instead of the stock.move id + # when saving the detailed operations dialog from an MO component line + # (https://github.com/odoo/odoo/issues/261740); a wrong default here + # should be harmless as it only pre-fills the line + move = self.env["stock.move"].browse(move_id).exists() + if move and move.secondary_uom_id: res["secondary_uom_id"] = move.secondary_uom_id.id return res