diff --git a/rma_sale/models/rma_order.py b/rma_sale/models/rma_order.py index d2e14c71f..f89243cb0 100644 --- a/rma_sale/models/rma_order.py +++ b/rma_sale/models/rma_order.py @@ -16,6 +16,16 @@ def _compute_src_sale_count(self): src_sales = rma.mapped("rma_line_ids.sale_line_id.order_id") rma.src_sale_count = len(src_sales) + @api.depends( + "rma_line_ids", + "rma_line_ids.sale_line_ids", + "rma_line_ids.sale_line_ids.order_id", + ) + def _compute_sale_count(self): + for rma in self: + sales = rma.mapped("rma_line_ids.sale_line_ids.order_id") + rma.sale_count = len(sales) + @api.depends("rma_line_ids", "rma_line_ids.qty_to_sell") def _compute_qty_to_sell(self): for rec in self: @@ -28,6 +38,7 @@ def _compute_qty_to_sell(self): digits="Product Unit of Measure", compute="_compute_qty_to_sell", ) + sale_count = fields.Integer(compute="_compute_sale_count", string="# of Sales") @api.model def _get_line_domain(self, rma_id, line): @@ -41,9 +52,16 @@ def _get_line_domain(self, rma_id, line): domain = super(RmaOrder, self)._get_line_domain(rma_id, line) return domain + def action_view_origin_sale_order(self): + action = self.env.ref("sale.action_orders") + result = action.sudo().read()[0] + so_ids = self.mapped("rma_line_ids.sale_line_id.order_id").ids + result["domain"] = [("id", "in", so_ids)] + return result + def action_view_sale_order(self): action = self.env.ref("sale.action_quotations") result = action.sudo().read()[0] - so_ids = self.mapped("rma_line_ids.sale_line_id.order_id").ids + so_ids = self.mapped("rma_line_ids.sale_line_ids.order_id").ids result["domain"] = [("id", "in", so_ids)] return result diff --git a/rma_sale/views/rma_order_line_view.xml b/rma_sale/views/rma_order_line_view.xml index 84c38fbb4..1f73791d2 100644 --- a/rma_sale/views/rma_order_line_view.xml +++ b/rma_sale/views/rma_order_line_view.xml @@ -22,15 +22,15 @@ />