diff --git a/rma/models/rma.py b/rma/models/rma.py index 8367c5b3..b547b3d4 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -599,7 +599,10 @@ class Rma(models.Model): """Invoked when 'Replace' button in rma form view is clicked.""" self.ensure_one() self._ensure_can_be_replaced() - action = self.env.ref("rma.rma_delivery_wizard_action").read()[0] + # Force active_id to avoid issues when coming from smart buttons + # in other models + action = self.env.ref("rma.rma_delivery_wizard_action").with_context( + active_id=self.id).read()[0] action['name'] = 'Replace product(s)' action['context'] = dict(self.env.context) action['context'].update( @@ -615,7 +618,10 @@ class Rma(models.Model): """ self.ensure_one() self._ensure_can_be_returned() - action = self.env.ref("rma.rma_delivery_wizard_action").read()[0] + # Force active_id to avoid issues when coming from smart buttons + # in other models + action = self.env.ref("rma.rma_delivery_wizard_action").with_context( + active_id=self.id).read()[0] action['context'] = dict(self.env.context) action['context'].update( active_id=self.id, @@ -628,9 +634,12 @@ class Rma(models.Model): """Invoked when 'Split' button in rma form view is clicked.""" self.ensure_one() self._ensure_can_be_split() - action = self.env.ref("rma.rma_split_wizard_action").read()[0] + # Force active_id to avoid issues when coming from smart buttons + # in other models + action = self.env.ref("rma.rma_split_wizard_action").with_context( + active_id=self.id).read()[0] action['context'] = dict(self.env.context) - action['context'].update(active_ids=self.ids) + action['context'].update(active_id=self.id, active_ids=self.ids) return action def action_cancel(self): @@ -663,7 +672,10 @@ class Rma(models.Model): def action_view_receipt(self): """Invoked when 'Receipt' smart button in rma form view is clicked.""" self.ensure_one() - action = self.env.ref('stock.action_picking_tree_all').read()[0] + # Force active_id to avoid issues when coming from smart buttons + # in other models + action = self.env.ref('stock.action_picking_tree_all').with_context( + active_id=self.id).read()[0] action.update( res_id=self.reception_move_id.picking_id.id, view_mode="form", @@ -687,7 +699,8 @@ class Rma(models.Model): def action_view_delivery(self): """Invoked when 'Delivery' smart button in rma form view is clicked.""" - action = self.env.ref('stock.action_picking_tree_all').read()[0] + action = self.env.ref('stock.action_picking_tree_all').with_context( + active_id=self.id).read()[0] picking = self.delivery_move_ids.mapped('picking_id') if len(picking) > 1: action['domain'] = [('id', 'in', picking.ids)] diff --git a/rma/views/rma_portal_templates.xml b/rma/views/rma_portal_templates.xml index 16cff15b..e4ae704e 100644 --- a/rma/views/rma_portal_templates.xml +++ b/rma/views/rma_portal_templates.xml @@ -50,7 +50,8 @@