From a8cbfe711708a9f9565562cca4d3aeb99b1d221d Mon Sep 17 00:00:00 2001 From: Christopher Ormaza Date: Wed, 2 Mar 2022 15:31:57 -0500 Subject: [PATCH 1/8] [14.0][ADD] rma_account_unreconciled --- rma_account_unreconciled/README.rst | 62 +++ rma_account_unreconciled/__init__.py | 1 + rma_account_unreconciled/__manifest__.py | 17 + rma_account_unreconciled/models/__init__.py | 1 + rma_account_unreconciled/models/rma_line.py | 91 ++++ .../readme/CONTRIBUTORS.rst | 2 + .../readme/DESCRIPTION.rst | 5 + .../static/description/index.html | 418 ++++++++++++++++++ rma_account_unreconciled/tests/__init__.py | 1 + .../tests/test_rma_account_unreconciled.py | 108 +++++ .../views/rma_line_view.xml | 54 +++ 11 files changed, 760 insertions(+) create mode 100644 rma_account_unreconciled/README.rst create mode 100644 rma_account_unreconciled/__init__.py create mode 100644 rma_account_unreconciled/__manifest__.py create mode 100644 rma_account_unreconciled/models/__init__.py create mode 100644 rma_account_unreconciled/models/rma_line.py create mode 100644 rma_account_unreconciled/readme/CONTRIBUTORS.rst create mode 100644 rma_account_unreconciled/readme/DESCRIPTION.rst create mode 100644 rma_account_unreconciled/static/description/index.html create mode 100644 rma_account_unreconciled/tests/__init__.py create mode 100644 rma_account_unreconciled/tests/test_rma_account_unreconciled.py create mode 100644 rma_account_unreconciled/views/rma_line_view.xml diff --git a/rma_account_unreconciled/README.rst b/rma_account_unreconciled/README.rst new file mode 100644 index 00000000..4d6f0581 --- /dev/null +++ b/rma_account_unreconciled/README.rst @@ -0,0 +1,62 @@ +======================= +RMA Account Unreconcile +======================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-ForgeFlow%2Fstock--rma-lightgray.png?logo=github + :target: https://github.com/ForgeFlow/stock-rma/tree/14.0/rma_account_unreconciled + :alt: ForgeFlow/stock-rma + +|badge1| |badge2| |badge3| + +This module adds a new fields "Unreconciled" on RMA Order Lines, that allows +to find Order's with unreconciled journal items related. + +This module allows to reconcile those Orders in a single click. In accounting +settings users will be able to set up a specific account for write-off. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Jordi Ballester Alomar +* Christopher Ormaza + +Maintainers +~~~~~~~~~~~ + +This module is part of the `ForgeFlow/stock-rma `_ project on GitHub. + +You are welcome to contribute. diff --git a/rma_account_unreconciled/__init__.py b/rma_account_unreconciled/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/rma_account_unreconciled/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/rma_account_unreconciled/__manifest__.py b/rma_account_unreconciled/__manifest__.py new file mode 100644 index 00000000..b3202a48 --- /dev/null +++ b/rma_account_unreconciled/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2022 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +{ + "name": "RMA Account Unreconcile", + "version": "14.0.1.0.0", + "license": "LGPL-3", + "category": "RMA", + "summary": "Integrates RMA with Invoice Processing", + "author": "ForgeFlow", + "website": "https://github.com/ForgeFlow/stock-rma", + "depends": ["account_move_line_rma_order_line", "rma"], + "data": [ + "views/rma_line_view.xml", + ], + "installable": True, +} diff --git a/rma_account_unreconciled/models/__init__.py b/rma_account_unreconciled/models/__init__.py new file mode 100644 index 00000000..9c48acd4 --- /dev/null +++ b/rma_account_unreconciled/models/__init__.py @@ -0,0 +1 @@ +from . import rma_line diff --git a/rma_account_unreconciled/models/rma_line.py b/rma_account_unreconciled/models/rma_line.py new file mode 100644 index 00000000..f8865366 --- /dev/null +++ b/rma_account_unreconciled/models/rma_line.py @@ -0,0 +1,91 @@ +# Copyright 2022 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import _, api, fields, models +from odoo.osv import expression + + +class RmaOrderLine(models.Model): + + _inherit = "rma.order.line" + + unreconciled = fields.Boolean( + compute="_compute_unreconciled", + search="_search_unreconciled", + help="Indicates that a Purchase Order has related Journal items not " + "reconciled.\nNote that if it is false it can be either that " + "everything is reconciled or that the related accounts do not " + "allow reconciliation", + ) + + def _compute_unreconciled(self): + acc_item = self.env["account.move.line"] + for rec in self: + domain = rec._get_rma_unreconciled_base_domain() + unreconciled_domain = expression.AND( + [domain, [("rma_line_id", "=", rec.id)]] + ) + unreconciled_items = acc_item.search(unreconciled_domain) + rec.unreconciled = len(unreconciled_items) > 0 + + def _search_unreconciled(self, operator, value): + if operator != "=" or not isinstance(value, bool): + raise ValueError(_("Unsupported search operator")) + acc_item = self.env["account.move.line"] + domain = self._get_rma_unreconciled_base_domain() + unreconciled_domain = expression.AND([domain, [("rma_line_id", "!=", False)]]) + unreconciled_items = acc_item.search(unreconciled_domain) + unreconciled_pos = unreconciled_items.mapped("rma_line_id") + if value: + return [("id", "in", unreconciled_pos.ids)] + else: + return [("id", "not in", unreconciled_pos.ids)] + + @api.model + def _get_rma_unreconciled_base_domain(self): + categories = self.env["product.category"].search( + [("property_valuation", "=", "real_time")] + ) + included_accounts = ( + categories.mapped("property_stock_account_input_categ_id").ids + ) + (categories.mapped("property_stock_account_output_categ_id").ids) + unreconciled_domain = [ + ("account_id.reconcile", "=", True), + ("account_id", "in", included_accounts), + ("move_id.state", "=", "posted"), + # for some reason when amount_residual is zero + # is marked as reconciled, this is better check + ("full_reconcile_id", "=", False), + ("company_id", "in", self.env.companies.ids), + ] + return unreconciled_domain + + def action_view_unreconciled(self): + self.ensure_one() + acc_item = self.env["account.move.line"] + domain = self._get_rma_unreconciled_base_domain() + unreconciled_domain = expression.AND([domain, [("rma_line_id", "=", self.id)]]) + unreconciled_items = acc_item.search(unreconciled_domain) + action = self.env.ref("account.action_account_moves_all") + action_dict = action.read()[0] + action_dict["domain"] = [("id", "in", unreconciled_items.ids)] + return action_dict + + def action_open_reconcile(self): + aml_model = self.env["account.move.line"] + action = self.action_view_unreconciled() + 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, + } + return { + "type": "ir.actions.client", + "tag": "manual_reconciliation_view", + "context": action_context, + } diff --git a/rma_account_unreconciled/readme/CONTRIBUTORS.rst b/rma_account_unreconciled/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..68f3dbd5 --- /dev/null +++ b/rma_account_unreconciled/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Jordi Ballester Alomar +* Christopher Ormaza diff --git a/rma_account_unreconciled/readme/DESCRIPTION.rst b/rma_account_unreconciled/readme/DESCRIPTION.rst new file mode 100644 index 00000000..1378495d --- /dev/null +++ b/rma_account_unreconciled/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module adds a new fields "Unreconciled" on RMA Order Lines, that allows +to find Order's with unreconciled journal items related. + +This module allows to reconcile those Orders in a single click. In accounting +settings users will be able to set up a specific account for write-off. diff --git a/rma_account_unreconciled/static/description/index.html b/rma_account_unreconciled/static/description/index.html new file mode 100644 index 00000000..5595ade8 --- /dev/null +++ b/rma_account_unreconciled/static/description/index.html @@ -0,0 +1,418 @@ + + + + + + +RMA Account Unreconcile + + + +
+

RMA Account Unreconcile

+ + +

Beta License: LGPL-3 ForgeFlow/stock-rma

+

This module adds a new fields “Unreconciled” on RMA Order Lines, that allows +to find Order’s with unreconciled journal items related.

+

This module allows to reconcile those Orders in a single click. In accounting +settings users will be able to set up a specific account for write-off.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the ForgeFlow/stock-rma project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/rma_account_unreconciled/tests/__init__.py b/rma_account_unreconciled/tests/__init__.py new file mode 100644 index 00000000..ba3f6aeb --- /dev/null +++ b/rma_account_unreconciled/tests/__init__.py @@ -0,0 +1 @@ +from . import test_rma_account_unreconciled diff --git a/rma_account_unreconciled/tests/test_rma_account_unreconciled.py b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py new file mode 100644 index 00000000..82427a76 --- /dev/null +++ b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py @@ -0,0 +1,108 @@ +# Copyright 2022 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + + +from odoo.addons.rma.tests.test_rma import TestRma + + +class TestRmaAccountUnreconciled(TestRma): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.rma_refund_wiz = cls.env["rma.refund"] + for categ in cls.rma_customer_id.mapped("rma_line_ids.product_id.categ_id"): + categ.write( + { + "property_valuation": "real_time", + "property_cost_method": "fifo", + } + ) + categ.property_stock_account_input_categ_id.write( + { + "reconcile": True, + } + ) + categ.property_stock_account_output_categ_id.write( + { + "reconcile": True, + } + ) + for product in cls.rma_customer_id.mapped("rma_line_ids.product_id"): + product.write( + { + "standard_price": 10.0, + } + ) + + def test_unreconciled_moves(self): + for rma_line in self.rma_customer_id.rma_line_ids: + rma_line.write( + { + "refund_policy": "received", + } + ) + rma_line.action_rma_approve() + self.assertFalse(rma_line.unreconciled) + self.rma_customer_id.rma_line_ids.action_rma_to_approve() + wizard = self.rma_make_picking.with_context( + { + "active_ids": self.rma_customer_id.rma_line_ids.ids, + "active_model": "rma.order.line", + "picking_type": "incoming", + "active_id": 1, + } + ).create({}) + wizard._create_picking() + res = self.rma_customer_id.rma_line_ids.action_view_in_shipments() + picking = self.env["stock.picking"].browse(res["res_id"]) + picking.action_assign() + for mv in picking.move_lines: + mv.quantity_done = mv.product_uom_qty + picking.button_validate() + for rma_line in self.rma_customer_id.rma_line_ids: + rma_line._compute_unreconciled() + self.assertTrue(rma_line.unreconciled) + make_refund = self.rma_refund_wiz.with_context( + { + "customer": True, + "active_ids": self.rma_customer_id.rma_line_ids.ids, + "active_model": "rma.order.line", + } + ).create( + { + "description": "Test refund", + } + ) + for item in make_refund.item_ids: + item.write( + { + "qty_to_refund": item.product_qty, + } + ) + make_refund.invoice_refund() + self.rma_customer_id.rma_line_ids.refund_line_ids.move_id.filtered( + lambda x: x.state != "posted" + ).action_post() + for rma_line in self.rma_customer_id.rma_line_ids: + rma_line._compute_unreconciled() + self.assertTrue(rma_line.unreconciled) + + self.assertEqual( + self.env["rma.order.line"].search_count( + [ + ("type", "=", "customer"), + ("unreconciled", "=", True), + ("rma_id", "=", self.rma_customer_id.id), + ] + ), + 3, + ) + for rma_line in self.rma_customer_id.rma_line_ids: + aml_domain = rma_line.action_view_unreconciled().get("domain") + aml_lines = ( + aml_domain and self.env["account.move.line"].search(aml_domain) or False + ) + if aml_lines: + aml_lines.reconcile() + rma_line._compute_unreconciled() + self.assertFalse(rma_line.unreconciled) diff --git a/rma_account_unreconciled/views/rma_line_view.xml b/rma_account_unreconciled/views/rma_line_view.xml new file mode 100644 index 00000000..3ccc9fbd --- /dev/null +++ b/rma_account_unreconciled/views/rma_line_view.xml @@ -0,0 +1,54 @@ + + + + + + rma.order.line.view.form + rma.order.line + + +
+ + + +
+
+
+ + + rma.order.line.search.view + rma.order.line + + + + + + + + +
+
From cae4546d9b53c75dd16fa92c3c4834e5b7d6203c Mon Sep 17 00:00:00 2001 From: Jordi Ballester Date: Thu, 12 May 2022 17:40:23 +0200 Subject: [PATCH 2/8] make module AGPL --- rma_account_unreconciled/__manifest__.py | 4 ++-- rma_account_unreconciled/models/rma_line.py | 2 +- .../tests/test_rma_account_unreconciled.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rma_account_unreconciled/__manifest__.py b/rma_account_unreconciled/__manifest__.py index b3202a48..c64901a4 100644 --- a/rma_account_unreconciled/__manifest__.py +++ b/rma_account_unreconciled/__manifest__.py @@ -1,10 +1,10 @@ # Copyright 2022 ForgeFlow S.L. -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) { "name": "RMA Account Unreconcile", "version": "14.0.1.0.0", - "license": "LGPL-3", + "license": "AGPL-3", "category": "RMA", "summary": "Integrates RMA with Invoice Processing", "author": "ForgeFlow", diff --git a/rma_account_unreconciled/models/rma_line.py b/rma_account_unreconciled/models/rma_line.py index f8865366..3e37d23f 100644 --- a/rma_account_unreconciled/models/rma_line.py +++ b/rma_account_unreconciled/models/rma_line.py @@ -1,5 +1,5 @@ # Copyright 2022 ForgeFlow S.L. -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) from odoo import _, api, fields, models from odoo.osv import expression diff --git a/rma_account_unreconciled/tests/test_rma_account_unreconciled.py b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py index 82427a76..c82111ad 100644 --- a/rma_account_unreconciled/tests/test_rma_account_unreconciled.py +++ b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py @@ -1,5 +1,5 @@ # Copyright 2022 ForgeFlow S.L. -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) from odoo.addons.rma.tests.test_rma import TestRma From 18f64b703c784852e82a530b607b368095a0ba87 Mon Sep 17 00:00:00 2001 From: AaronHForgeFlow Date: Fri, 4 Mar 2022 10:56:07 +0100 Subject: [PATCH 3/8] [FIX] rma: rma_custmer_user has no write permissions in partner, so compute method fails. [IMP] rma: use rma user in tests [FIX] rma_account: move_line_id field string [IMP] rma, rma_account, rma_sale, rma_purchase: tests for stock valuation [FIX] account_move_line_rma_order_line: minor lint, make auto-install [IMP] rma_account_unreconciled: use manager user in test --- .../tests/test_rma_account_unreconciled.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rma_account_unreconciled/tests/test_rma_account_unreconciled.py b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py index c82111ad..db0e6c5f 100644 --- a/rma_account_unreconciled/tests/test_rma_account_unreconciled.py +++ b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py @@ -10,7 +10,9 @@ class TestRmaAccountUnreconciled(TestRma): def setUpClass(cls): super().setUpClass() cls.rma_refund_wiz = cls.env["rma.refund"] - for categ in cls.rma_customer_id.mapped("rma_line_ids.product_id.categ_id"): + for categ in cls.rma_customer_id.with_user(cls.rma_manager_user).mapped( + "rma_line_ids.product_id.categ_id" + ): categ.write( { "property_valuation": "real_time", @@ -27,7 +29,9 @@ class TestRmaAccountUnreconciled(TestRma): "reconcile": True, } ) - for product in cls.rma_customer_id.mapped("rma_line_ids.product_id"): + for product in cls.rma_customer_id.with_user(cls.rma_manager_user).mapped( + "rma_line_ids.product_id" + ): product.write( { "standard_price": 10.0, @@ -80,7 +84,9 @@ class TestRmaAccountUnreconciled(TestRma): } ) make_refund.invoice_refund() - self.rma_customer_id.rma_line_ids.refund_line_ids.move_id.filtered( + self.rma_customer_id.with_user( + self.rma_manager_user + ).rma_line_ids.refund_line_ids.move_id.filtered( lambda x: x.state != "posted" ).action_post() for rma_line in self.rma_customer_id.rma_line_ids: @@ -98,7 +104,7 @@ class TestRmaAccountUnreconciled(TestRma): 3, ) for rma_line in self.rma_customer_id.rma_line_ids: - aml_domain = rma_line.action_view_unreconciled().get("domain") + aml_domain = rma_line.sudo().action_view_unreconciled().get("domain") aml_lines = ( aml_domain and self.env["account.move.line"].search(aml_domain) or False ) From fc6f6837773bfa8fc199a63486c4cc8f636b27db Mon Sep 17 00:00:00 2001 From: DavidJForgeFlow Date: Thu, 16 Jun 2022 11:53:30 +0200 Subject: [PATCH 4/8] [FIX]rma: remove test_rma dependency to Account --- .../tests/test_rma_account_unreconciled.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/rma_account_unreconciled/tests/test_rma_account_unreconciled.py b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py index db0e6c5f..27082e0d 100644 --- a/rma_account_unreconciled/tests/test_rma_account_unreconciled.py +++ b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py @@ -10,7 +10,13 @@ class TestRmaAccountUnreconciled(TestRma): def setUpClass(cls): super().setUpClass() cls.rma_refund_wiz = cls.env["rma.refund"] - for categ in cls.rma_customer_id.with_user(cls.rma_manager_user).mapped( + cls.g_account_manager = cls.env.ref("account.group_account_manager") + cls.rma_manager_user_account = cls._create_user( + "rma manager account", + [cls.g_stock_manager, cls.g_rma_manager, cls.g_account_manager], + cls.company, + ) + for categ in cls.rma_customer_id.with_user(cls.rma_manager_user_account).mapped( "rma_line_ids.product_id.categ_id" ): categ.write( @@ -29,9 +35,9 @@ class TestRmaAccountUnreconciled(TestRma): "reconcile": True, } ) - for product in cls.rma_customer_id.with_user(cls.rma_manager_user).mapped( - "rma_line_ids.product_id" - ): + for product in cls.rma_customer_id.with_user( + cls.rma_manager_user_account + ).mapped("rma_line_ids.product_id"): product.write( { "standard_price": 10.0, @@ -85,7 +91,7 @@ class TestRmaAccountUnreconciled(TestRma): ) make_refund.invoice_refund() self.rma_customer_id.with_user( - self.rma_manager_user + self.rma_manager_user_account ).rma_line_ids.refund_line_ids.move_id.filtered( lambda x: x.state != "posted" ).action_post() From 3dd26e22f299ea58d10b544ba1528b269c0d08b2 Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Mon, 21 Nov 2022 15:13:06 +0100 Subject: [PATCH 5/8] [FIX] include anglo-saxon price unit calculation in refunds. Otherwise the anglo saxon entries won't be correct. For example, the Interim (Delivered) account should balance after receiving and triggering a refund on a customer rma. --- .../tests/test_rma_account_unreconciled.py | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/rma_account_unreconciled/tests/test_rma_account_unreconciled.py b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py index 27082e0d..42ce79dd 100644 --- a/rma_account_unreconciled/tests/test_rma_account_unreconciled.py +++ b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py @@ -96,25 +96,6 @@ class TestRmaAccountUnreconciled(TestRma): lambda x: x.state != "posted" ).action_post() for rma_line in self.rma_customer_id.rma_line_ids: - rma_line._compute_unreconciled() - self.assertTrue(rma_line.unreconciled) - - self.assertEqual( - self.env["rma.order.line"].search_count( - [ - ("type", "=", "customer"), - ("unreconciled", "=", True), - ("rma_id", "=", self.rma_customer_id.id), - ] - ), - 3, - ) - for rma_line in self.rma_customer_id.rma_line_ids: - aml_domain = rma_line.sudo().action_view_unreconciled().get("domain") - aml_lines = ( - aml_domain and self.env["account.move.line"].search(aml_domain) or False - ) - if aml_lines: - aml_lines.reconcile() + # The debits and credits are reconciled automatically rma_line._compute_unreconciled() self.assertFalse(rma_line.unreconciled) From 4073972609226b305ac385d173ecb5c1aeebb3be Mon Sep 17 00:00:00 2001 From: AlexPForgeFlow Date: Wed, 4 Oct 2023 16:01:29 +0200 Subject: [PATCH 6/8] [IMP] rma_account_unreconciled: pre-commit stuff --- .../odoo/addons/rma_account_unreconciled | 1 + setup/rma_account_unreconciled/setup.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 120000 setup/rma_account_unreconciled/odoo/addons/rma_account_unreconciled create mode 100644 setup/rma_account_unreconciled/setup.py diff --git a/setup/rma_account_unreconciled/odoo/addons/rma_account_unreconciled b/setup/rma_account_unreconciled/odoo/addons/rma_account_unreconciled new file mode 120000 index 00000000..94f2a8c8 --- /dev/null +++ b/setup/rma_account_unreconciled/odoo/addons/rma_account_unreconciled @@ -0,0 +1 @@ +../../../../rma_account_unreconciled \ No newline at end of file diff --git a/setup/rma_account_unreconciled/setup.py b/setup/rma_account_unreconciled/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/rma_account_unreconciled/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From d83db3b81c389fd64579b015cf40a477dce4da86 Mon Sep 17 00:00:00 2001 From: AlexPForgeFlow Date: Mon, 9 Oct 2023 15:01:20 +0200 Subject: [PATCH 7/8] [MIG] rma_account_unreconciled: Migration to 16.0 --- rma_account_unreconciled/__manifest__.py | 4 +- rma_account_unreconciled/models/rma_line.py | 12 ++- .../readme/DESCRIPTION.rst | 2 +- .../tests/test_rma_account_unreconciled.py | 6 +- .../views/rma_line_view.xml | 94 +++++++++---------- 5 files changed, 58 insertions(+), 60 deletions(-) diff --git a/rma_account_unreconciled/__manifest__.py b/rma_account_unreconciled/__manifest__.py index c64901a4..54564ab1 100644 --- a/rma_account_unreconciled/__manifest__.py +++ b/rma_account_unreconciled/__manifest__.py @@ -3,13 +3,13 @@ { "name": "RMA Account Unreconcile", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "license": "AGPL-3", "category": "RMA", "summary": "Integrates RMA with Invoice Processing", "author": "ForgeFlow", "website": "https://github.com/ForgeFlow/stock-rma", - "depends": ["account_move_line_rma_order_line", "rma"], + "depends": ["account_move_line_rma_order_line", "rma", "account_reconcile_oca"], "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 3e37d23f..d0b7ae59 100644 --- a/rma_account_unreconciled/models/rma_line.py +++ b/rma_account_unreconciled/models/rma_line.py @@ -84,8 +84,10 @@ class RmaOrderLine(models.Model): "active_model": "account.move.line", "active_ids": amls.ids, } - return { - "type": "ir.actions.client", - "tag": "manual_reconciliation_view", - "context": action_context, - } + 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 diff --git a/rma_account_unreconciled/readme/DESCRIPTION.rst b/rma_account_unreconciled/readme/DESCRIPTION.rst index 1378495d..98b3a5af 100644 --- a/rma_account_unreconciled/readme/DESCRIPTION.rst +++ b/rma_account_unreconciled/readme/DESCRIPTION.rst @@ -1,5 +1,5 @@ This module adds a new fields "Unreconciled" on RMA Order Lines, that allows to find Order's with unreconciled journal items related. -This module allows to reconcile those Orders in a single click. In accounting +**(Features pending of new version)** This module allows to reconcile those Orders in a single click. In accounting settings users will be able to set up a specific account for write-off. diff --git a/rma_account_unreconciled/tests/test_rma_account_unreconciled.py b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py index 42ce79dd..948f3564 100644 --- a/rma_account_unreconciled/tests/test_rma_account_unreconciled.py +++ b/rma_account_unreconciled/tests/test_rma_account_unreconciled.py @@ -55,7 +55,7 @@ class TestRmaAccountUnreconciled(TestRma): self.assertFalse(rma_line.unreconciled) self.rma_customer_id.rma_line_ids.action_rma_to_approve() wizard = self.rma_make_picking.with_context( - { + **{ "active_ids": self.rma_customer_id.rma_line_ids.ids, "active_model": "rma.order.line", "picking_type": "incoming", @@ -66,14 +66,14 @@ class TestRmaAccountUnreconciled(TestRma): res = self.rma_customer_id.rma_line_ids.action_view_in_shipments() picking = self.env["stock.picking"].browse(res["res_id"]) picking.action_assign() - for mv in picking.move_lines: + for mv in picking.move_ids: mv.quantity_done = mv.product_uom_qty picking.button_validate() for rma_line in self.rma_customer_id.rma_line_ids: rma_line._compute_unreconciled() self.assertTrue(rma_line.unreconciled) make_refund = self.rma_refund_wiz.with_context( - { + **{ "customer": True, "active_ids": self.rma_customer_id.rma_line_ids.ids, "active_model": "rma.order.line", diff --git a/rma_account_unreconciled/views/rma_line_view.xml b/rma_account_unreconciled/views/rma_line_view.xml index 3ccc9fbd..eeec3851 100644 --- a/rma_account_unreconciled/views/rma_line_view.xml +++ b/rma_account_unreconciled/views/rma_line_view.xml @@ -1,54 +1,50 @@ - + + rma.order.line.view.form + rma.order.line + + +
+ + + +
+
+
- - rma.order.line.view.form - rma.order.line - - -
- - - -
+ + rma.order.line.search.view + rma.order.line + + + + - - - - rma.order.line.search.view - rma.order.line - - - - - - - - -
+ +
From def1b22feb7626ef9cf44f08377e17c187d35bc8 Mon Sep 17 00:00:00 2001 From: BernatPForgeFlow Date: Thu, 20 Jun 2024 13:10:36 +0200 Subject: [PATCH 8/8] [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.") + )