From 3d972166d9267c78c77dff61a7e1d9033446bb94 Mon Sep 17 00:00:00 2001 From: "chafique.delli" Date: Mon, 9 Sep 2024 20:09:40 +0200 Subject: [PATCH] [FIX] rma, rma_account and rma_sale: following the comments that were made during the review --- rma/models/rma_order.py | 6 ++--- rma/views/rma_order_view.xml | 32 ++++++++++++++----------- rma_account/models/rma_order.py | 29 ++++++++++------------ rma_account/views/rma_order_view.xml | 13 +++++----- rma_account/wizards/rma_refund.py | 13 +++------- rma_sale/models/rma_order.py | 10 ++++---- rma_sale/views/rma_order_view.xml | 20 +++++++++------- rma_sale/wizards/rma_make_sale_order.py | 21 ++-------------- 8 files changed, 62 insertions(+), 82 deletions(-) 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" /> - diff --git a/rma_sale/wizards/rma_make_sale_order.py b/rma_sale/wizards/rma_make_sale_order.py index b2e58dab7..f8296c09e 100644 --- a/rma_sale/wizards/rma_make_sale_order.py +++ b/rma_sale/wizards/rma_make_sale_order.py @@ -61,7 +61,7 @@ def default_get(self, fields_list): items = [] if active_model == "rma.order": rma = rma_obj.browse(active_ids) - lines = rma.rma_line_ids + lines = rma.rma_line_ids.filtered(lambda x: x.qty_to_sell > 0) else: lines = rma_line_obj.browse(active_ids) for line in lines: @@ -161,9 +161,7 @@ class RmaLineMakeSaleOrderItem(models.TransientModel): _description = "RMA Line Make Sale Order Item" wiz_id = fields.Many2one(comodel_name="rma.make.sale.order", string="Wizard") - line_id = fields.Many2one( - comodel_name="rma.order.line", string="RMA Line", compute="_compute_line_id" - ) + line_id = fields.Many2one(comodel_name="rma.order.line", string="RMA Line") rma_id = fields.Many2one( comodel_name="rma.order", related="line_id.rma_id", readonly=False ) @@ -176,21 +174,6 @@ class RmaLineMakeSaleOrderItem(models.TransientModel): ) free_of_charge = fields.Boolean(string="Free of Charge") - def _compute_line_id(self): - rma_line_obj = self.env["rma.order.line"] - rma_obj = self.env["rma.order"] - active_ids = self.env.context.get("active_ids") or [] - active_model = self.env.context.get("active_model") - for rec in self: - if not active_ids: - return - if active_model == "rma.order": - rma = rma_obj.browse(active_ids) - lines = rma.rma_line_ids - else: - lines = rma_line_obj.browse(active_ids) - rec.line_id = lines[0] - @api.onchange("product_id") def onchange_product_id(self): if self.product_id: