From def1b22feb7626ef9cf44f08377e17c187d35bc8 Mon Sep 17 00:00:00 2001 From: BernatPForgeFlow Date: Thu, 20 Jun 2024 13:10:36 +0200 Subject: [PATCH] [FIX] rma_account_unreconciled: Remove 'account_reconcile_oca' dependency RMA lines should be able to reconcile either with OCA or Enterprise reconcile tools. --- rma_account_unreconciled/__manifest__.py | 2 +- rma_account_unreconciled/models/rma_line.py | 23 ++++++++------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/rma_account_unreconciled/__manifest__.py b/rma_account_unreconciled/__manifest__.py index 54564ab1..a39d93d4 100644 --- a/rma_account_unreconciled/__manifest__.py +++ b/rma_account_unreconciled/__manifest__.py @@ -9,7 +9,7 @@ "summary": "Integrates RMA with Invoice Processing", "author": "ForgeFlow", "website": "https://github.com/ForgeFlow/stock-rma", - "depends": ["account_move_line_rma_order_line", "rma", "account_reconcile_oca"], + "depends": ["account_move_line_rma_order_line", "rma"], "data": [ "views/rma_line_view.xml", ], diff --git a/rma_account_unreconciled/models/rma_line.py b/rma_account_unreconciled/models/rma_line.py index d0b7ae59..c9893519 100644 --- a/rma_account_unreconciled/models/rma_line.py +++ b/rma_account_unreconciled/models/rma_line.py @@ -2,6 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) from odoo import _, api, fields, models +from odoo.exceptions import UserError from odoo.osv import expression @@ -77,17 +78,11 @@ class RmaOrderLine(models.Model): amls = ( action.get("domain") and aml_model.search(action.get("domain")) or aml_model ) - accounts = amls.mapped("account_id") - action_context = { - "show_mode_selector": False, - "account_ids": accounts.ids, - "active_model": "account.move.line", - "active_ids": amls.ids, - } - action_def = self.env["ir.actions.act_window"]._for_xml_id( - "account_reconcile_oca.account_account_reconcile_act_window" - ) - action_def["context"] = action_context - action_def["domain"] = [("id", "in", amls.ids)] - action_def["context"]["default_account_move_lines"] = amls.ids - return action_def + if getattr(aml_model, "action_reconcile", False): + return amls.action_reconcile() + elif getattr(aml_model, "action_reconcile_manually", False): + return amls.action_reconcile_manually() + else: + raise UserError( + _("Could not find a method to open the reconciliation view.") + )