@@ -599,7 +599,10 @@ def action_replace(self):
599599 """Invoked when 'Replace' button in rma form view is clicked."""
600600 self .ensure_one ()
601601 self ._ensure_can_be_replaced ()
602- action = self .env .ref ("rma.rma_delivery_wizard_action" ).read ()[0 ]
602+ # Force active_id to avoid issues when coming from smart buttons
603+ # in other models
604+ action = self .env .ref ("rma.rma_delivery_wizard_action" ).with_context (
605+ active_id = self .id ).read ()[0 ]
603606 action ['name' ] = 'Replace product(s)'
604607 action ['context' ] = dict (self .env .context )
605608 action ['context' ].update (
@@ -615,7 +618,10 @@ def action_return(self):
615618 """
616619 self .ensure_one ()
617620 self ._ensure_can_be_returned ()
618- action = self .env .ref ("rma.rma_delivery_wizard_action" ).read ()[0 ]
621+ # Force active_id to avoid issues when coming from smart buttons
622+ # in other models
623+ action = self .env .ref ("rma.rma_delivery_wizard_action" ).with_context (
624+ active_id = self .id ).read ()[0 ]
619625 action ['context' ] = dict (self .env .context )
620626 action ['context' ].update (
621627 active_id = self .id ,
@@ -628,9 +634,12 @@ def action_split(self):
628634 """Invoked when 'Split' button in rma form view is clicked."""
629635 self .ensure_one ()
630636 self ._ensure_can_be_split ()
631- action = self .env .ref ("rma.rma_split_wizard_action" ).read ()[0 ]
637+ # Force active_id to avoid issues when coming from smart buttons
638+ # in other models
639+ action = self .env .ref ("rma.rma_split_wizard_action" ).with_context (
640+ active_id = self .id ).read ()[0 ]
632641 action ['context' ] = dict (self .env .context )
633- action ['context' ].update (active_ids = self .ids )
642+ action ['context' ].update (active_id = self . id , active_ids = self .ids )
634643 return action
635644
636645 def action_cancel (self ):
@@ -663,7 +672,10 @@ def action_preview(self):
663672 def action_view_receipt (self ):
664673 """Invoked when 'Receipt' smart button in rma form view is clicked."""
665674 self .ensure_one ()
666- action = self .env .ref ('stock.action_picking_tree_all' ).read ()[0 ]
675+ # Force active_id to avoid issues when coming from smart buttons
676+ # in other models
677+ action = self .env .ref ('stock.action_picking_tree_all' ).with_context (
678+ active_id = self .id ).read ()[0 ]
667679 action .update (
668680 res_id = self .reception_move_id .picking_id .id ,
669681 view_mode = "form" ,
@@ -687,7 +699,8 @@ def action_view_refund(self):
687699
688700 def action_view_delivery (self ):
689701 """Invoked when 'Delivery' smart button in rma form view is clicked."""
690- action = self .env .ref ('stock.action_picking_tree_all' ).read ()[0 ]
702+ action = self .env .ref ('stock.action_picking_tree_all' ).with_context (
703+ active_id = self .id ).read ()[0 ]
691704 picking = self .delivery_move_ids .mapped ('picking_id' )
692705 if len (picking ) > 1 :
693706 action ['domain' ] = [('id' , 'in' , picking .ids )]
0 commit comments