From d1802c37035a44c93882f928c9bcf7f41b2c3e54 Mon Sep 17 00:00:00 2001 From: JasminSForgeFlow Date: Wed, 8 Jan 2025 12:18:31 +0530 Subject: [PATCH] [MIG] rma_repair: Migration to 17.0 --- rma_repair/__manifest__.py | 2 +- rma_repair/data/repair_sequence.xml | 4 +- rma_repair/models/repair.py | 3 -- rma_repair/models/rma_operation.py | 11 ----- rma_repair/models/rma_order_line.py | 40 ++---------------- rma_repair/models/stock_move.py | 2 +- rma_repair/tests/test_rma_repair.py | 29 ++----------- rma_repair/views/repair_view.xml | 2 +- rma_repair/views/rma_operation_view.xml | 1 - rma_repair/views/rma_order_line_view.xml | 13 +++--- rma_repair/views/rma_order_view.xml | 4 +- .../wizards/rma_order_line_make_repair.py | 20 +-------- .../rma_order_line_make_repair_view.xml | 41 +++++++++---------- 13 files changed, 41 insertions(+), 131 deletions(-) diff --git a/rma_repair/__manifest__.py b/rma_repair/__manifest__.py index 9a3af5c6b..d4b0ef95c 100644 --- a/rma_repair/__manifest__.py +++ b/rma_repair/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "RMA Repair", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "license": "AGPL-3", "category": "RMA", "summary": "Links RMA with Repairs.", diff --git a/rma_repair/data/repair_sequence.xml b/rma_repair/data/repair_sequence.xml index 73ba79dff..c641fad9a 100644 --- a/rma_repair/data/repair_sequence.xml +++ b/rma_repair/data/repair_sequence.xml @@ -1,8 +1,8 @@ - + diff --git a/rma_repair/models/repair.py b/rma_repair/models/repair.py index f48b1d93a..1d0300174 100644 --- a/rma_repair/models/repair.py +++ b/rma_repair/models/repair.py @@ -13,6 +13,3 @@ class RepairOrder(models.Model): under_warranty = fields.Boolean( related="rma_line_id.under_warranty", ) - payment_state = fields.Selection( - related="invoice_id.payment_state", string="Payment Status" - ) diff --git a/rma_repair/models/rma_operation.py b/rma_repair/models/rma_operation.py index 6026e7b94..c72e26659 100644 --- a/rma_repair/models/rma_operation.py +++ b/rma_repair/models/rma_operation.py @@ -24,17 +24,6 @@ class RmaOperation(models.Model): comodel_name="stock.location", help="Indicate here the source location of the product to be repaired", ) - repair_invoice_method = fields.Selection( - selection=[ - ("none", "No Invoice"), - ("b4repair", "Before Repair"), - ("after_repair", "After Repair"), - ], - help="Selecting 'Before Repair' or 'After Repair' will allow you " - "to generate invoice before or after the repair is done " - "respectively. 'No invoice' means you don't want to generate " - "invoice for this repair order.", - ) repair_route_id = fields.Many2one( comodel_name="stock.route", string="Repair Route", diff --git a/rma_repair/models/rma_order_line.py b/rma_repair/models/rma_order_line.py index d9a313d94..c90ddcb22 100644 --- a/rma_repair/models/rma_order_line.py +++ b/rma_repair/models/rma_order_line.py @@ -48,7 +48,6 @@ def _compute_repair_transfer_count(self): inverse_name="rma_line_id", string="Repair Orders", readonly=True, - states={"draft": [("readonly", False)]}, copy=False, ) qty_to_repair = fields.Float( @@ -95,36 +94,6 @@ def _compute_repair_transfer_count(self): selection_add=[("repair", "Based on Repair Quantities")], ondelete={"repair": lambda recs: recs.write({"delivery_policy": "no"})}, ) - qty_to_pay = fields.Float( - compute="_compute_qty_to_pay", - digits="Product Unit of Measure", - ) - - @api.depends( - "delivery_policy", - "product_qty", - "type", - "repair_ids", - "repair_ids.state", - "repair_ids.invoice_method", - "repair_type", - "repair_ids.invoice_id", - "repair_ids.invoice_id.payment_state", - ) - def _compute_qty_to_pay(self): - for rec in self: - qty_to_pay = 0.0 - if rec.delivery_policy == "repair": - for repair in rec.repair_ids.filtered( - lambda r: r.invoice_method != "none" - and r.invoice_id - and r.invoice_id.state != "cancel" - and r.invoice_id.payment_state in ["not_paid", "partial"] - ): - qty_to_pay += self.uom_id._compute_quantity( - repair.product_qty, repair.product_uom - ) - rec.qty_to_pay = qty_to_pay def action_view_repair_order(self): action = self.env.ref("repair.action_repair_order_tree") @@ -168,7 +137,7 @@ def _get_rma_under_repair_qty(self): @api.onchange("operation_id") def _onchange_operation_id(self): - result = super(RmaOrderLine, self)._onchange_operation_id() + result = super()._onchange_operation_id() if self.operation_id: self.repair_type = self.operation_id.repair_type or "no" return result @@ -184,13 +153,10 @@ def _onchange_operation_id(self): "repair_ids", "repair_type", "repair_ids.state", - "qty_to_pay", - "repair_ids.invoice_id", - "repair_ids.payment_state", ) def _compute_qty_to_deliver(self): - res = super(RmaOrderLine, self)._compute_qty_to_deliver() - for rec in self.filtered(lambda l: l.delivery_policy == "repair"): + res = super()._compute_qty_to_deliver() + for rec in self.filtered(lambda line: line.delivery_policy == "repair"): rec.qty_to_deliver = rec.qty_repaired - rec.qty_delivered return res diff --git a/rma_repair/models/stock_move.py b/rma_repair/models/stock_move.py index e1c65cc3e..85094922f 100644 --- a/rma_repair/models/stock_move.py +++ b/rma_repair/models/stock_move.py @@ -13,7 +13,7 @@ class StockMove(models.Model): ) def _is_in_out_rma_move(self, op, states, location_type): - res = super(StockMove, self)._is_in_out_rma_move(op, states, location_type) + res = super()._is_in_out_rma_move(op, states, location_type) if self.is_rma_repair_transfer: return False return res diff --git a/rma_repair/tests/test_rma_repair.py b/rma_repair/tests/test_rma_repair.py index 4f26edcf7..f4f703240 100644 --- a/rma_repair/tests/test_rma_repair.py +++ b/rma_repair/tests/test_rma_repair.py @@ -8,7 +8,7 @@ class TestRmaRepair(common.SingleTransactionCase): @classmethod def setUpClass(cls): - super(TestRmaRepair, cls).setUpClass() + super().setUpClass() cls.rma_obj = cls.env["rma.order"] cls.rma_line_obj = cls.env["rma.order.line"] @@ -16,7 +16,6 @@ def setUpClass(cls): cls.rma_add_invoice_wiz = cls.env["rma_add_account_move"] cls.rma_make_repair_wiz = cls.env["rma.order.line.make.repair"] cls.rma_make_picking = cls.env["rma_make_picking.wizard"] - cls.repair_line_obj = cls.env["repair.line"] cls.acc_obj = cls.env["account.account"] cls.inv_obj = cls.env["account.move"] cls.invl_obj = cls.env["account.move.line"] @@ -262,7 +261,7 @@ def test_03_create_repair_order(self): self.assertEqual(repair_transfer_move.location_id, self.stock_rma_location) self.assertEqual(repair_transfer_move.product_qty, 15.0) self.assertEqual(repair_transfer_move.product_id, rma.product_id) - rma.repair_ids.action_repair_confirm() + rma.repair_ids.action_repair_start() self.assertEqual(rma.repair_count, 1) self.assertEqual(rma.qty_to_repair, 0.0) self.assertEqual(rma.qty_repaired, 0.0) @@ -298,7 +297,7 @@ def test_04_deliver_after_repair(self): picking = self.env["stock.picking"].browse(res["res_id"]) picking.action_assign() for mv in picking.move_ids: - mv.quantity_done = mv.product_uom_qty + mv.quantity = mv.product_uom_qty picking._action_done() self.assertEqual(rma.repair_transfer_count, 0) self.assertEqual(rma.qty_to_deliver, 0.0) @@ -318,31 +317,11 @@ def test_04_deliver_after_repair(self): self.assertEqual(repair_transfer_move.location_id, self.stock_rma_location) self.assertEqual(repair_transfer_move.product_id, rma.product_id) repair = rma.repair_ids - line = self.repair_line_obj.create( - { - "name": "consume stuff to repair", - "repair_id": repair.id, - "type": "add", - "product_id": self.material.id, - "product_uom": self.material.uom_id.id, - "product_uom_qty": 1.0, - "location_id": self.stock_location.id, - "location_dest_id": self.stock_location.id, - "price_unit": 10.0, - } - ) - line.onchange_product_id() - repair.invoice_method = "after_repair" - repair.action_repair_confirm() + repair.action_validate() repair.action_repair_start() repair.action_repair_end() - self.assertEqual(rma.qty_to_pay, 0.0) - repair.action_repair_invoice_create() self.assertEqual(rma.qty_repaired, 1.0) self.assertEqual(rma.qty_to_deliver, 1.0) - repair.invoice_id.action_post() - self.assertEqual(repair.payment_state, "not_paid") - self.assertEqual(rma.qty_to_pay, 1.0) self.assertEqual(rma.qty_repaired, 1.0) self.assertEqual(rma.delivery_policy, "repair") self.assertEqual(rma.qty_delivered, 0.0) diff --git a/rma_repair/views/repair_view.xml b/rma_repair/views/repair_view.xml index 894f897f8..156472804 100644 --- a/rma_repair/views/repair_view.xml +++ b/rma_repair/views/repair_view.xml @@ -6,7 +6,7 @@ repair.order - + diff --git a/rma_repair/views/rma_operation_view.xml b/rma_repair/views/rma_operation_view.xml index 7ee81bc32..b781d03ad 100644 --- a/rma_repair/views/rma_operation_view.xml +++ b/rma_repair/views/rma_operation_view.xml @@ -20,7 +20,6 @@ - diff --git a/rma_repair/views/rma_order_line_view.xml b/rma_repair/views/rma_order_line_view.xml index a6a527166..bcf07d1f8 100644 --- a/rma_repair/views/rma_order_line_view.xml +++ b/rma_repair/views/rma_order_line_view.xml @@ -13,7 +13,7 @@ class="oe_stat_button" icon="fa-wrench" groups="stock.group_stock_user" - attrs="{'invisible': [('repair_count', '=', 0)]}" + invisible="repair_count == 0" > - + - @@ -49,7 +48,7 @@ - + @@ -65,13 +64,13 @@ name="%(action_rma_order_line_make_repair)d" string="Create Repair Order" class="oe_highlight" - attrs="{'invisible':['|', '|', ('type', '!=', 'customer'), '|', ('qty_to_repair', '=', 0), ('qty_to_repair', '<', 0), ('state', '!=', 'approved')]}" + invisible="type != 'customer' or qty_to_repair == 0 or qty_to_repair < 0 or state != 'approved'" type="action" />