diff --git a/rma/models/rma_order.py b/rma/models/rma_order.py
index bee01c3b6..ead5aeeed 100644
--- a/rma/models/rma_order.py
+++ b/rma/models/rma_order.py
@@ -253,12 +253,12 @@ def create(self, vals_list):
def _view_shipments(self, result, shipments):
# choose the view_mode accordingly
- if len(shipments) > 1:
- result["domain"] = [("id", "in", shipments.ids)]
- elif len(shipments) == 1:
+ if len(shipments) == 1:
res = self.env.ref("stock.view_picking_form", False)
result["views"] = [(res and res.id or False, "form")]
result["res_id"] = shipments.ids[0]
+ else:
+ result["domain"] = [("id", "in", shipments.ids)]
return result
def action_view_in_shipments(self):
diff --git a/rma/views/rma_order_view.xml b/rma/views/rma_order_view.xml
index f45df2717..6176b7808 100644
--- a/rma/views/rma_order_view.xml
+++ b/rma/views/rma_order_view.xml
@@ -78,20 +78,6 @@
attrs="{'invisible':[('state', 'in', ('done', 'cancel'))]}"
groups="rma.group_rma_customer_user"
/>
-
-
+
+
@@ -124,6 +125,7 @@
name="action_view_in_shipments"
class="oe_stat_button"
icon="fa-truck"
+ attrs="{'invisible': [('in_shipment_count', '=', 0)]}"
groups="stock.group_stock_user"
>
diff --git a/rma_account/models/rma_order.py b/rma_account/models/rma_order.py
index b7154baa0..0df9686ff 100644
--- a/rma_account/models/rma_order.py
+++ b/rma_account/models/rma_order.py
@@ -1,7 +1,7 @@
# Copyright 2017-22 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
-from odoo import api, fields, models
+from odoo import _, api, fields, models
class RmaOrder(models.Model):
@@ -104,25 +104,22 @@ def _prepare_rma_data(self, partner, origin_rma):
return res
def action_view_invoice_refund(self):
- move_ids = self.mapped("rma_line_ids.move_id").ids
+ move_ids = self.mapped("rma_line_ids.refund_line_ids.move_id").ids
form_view_ref = self.env.ref("account.view_move_form", False)
tree_view_ref = self.env.ref("account.view_move_tree", False)
-
- return {
- "domain": [("id", "in", move_ids)],
- "name": "Refunds",
- "res_model": "account.move",
- "views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
- }
+ action = self.env.ref("account.action_move_in_refund_type")
+ result = action.sudo().read()[0]
+ result["domain"] = [("id", "in", move_ids)]
+ result["views"] = [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")]
+ return result
def action_view_invoice(self):
move_ids = self.mapped("rma_line_ids.move_id").ids
form_view_ref = self.env.ref("account.view_move_form", False)
tree_view_ref = self.env.ref("account.view_move_tree", False)
-
- return {
- "domain": [("id", "in", move_ids)],
- "name": "Originating Invoice",
- "res_model": "account.move",
- "views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
- }
+ action = self.env.ref("account.action_move_out_invoice_type")
+ result = action.sudo().read()[0]
+ result["domain"] = [("id", "in", move_ids)]
+ result["views"] = [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")]
+ result["name"] = _("Originating Invoice")
+ return result
diff --git a/rma_account/views/rma_order_view.xml b/rma_account/views/rma_order_view.xml
index 15391a75d..7d46d54e9 100644
--- a/rma_account/views/rma_order_view.xml
+++ b/rma_account/views/rma_order_view.xml
@@ -5,7 +5,10 @@
rma.order
-
+
-