diff --git a/account_in_payment/README.rst b/account_in_payment/README.rst new file mode 100644 index 00000000..5aa46ebb --- /dev/null +++ b/account_in_payment/README.rst @@ -0,0 +1,78 @@ +================== +Account In Payment +================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:27e59f268e2e2ed3367855cec9765674bd9fccaa2d2e7bf4a7aa222502802972 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github + :target: https://github.com/OCA/account-reconcile/tree/16.0/account_in_payment + :alt: OCA/account-reconcile +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-reconcile-16-0/account-reconcile-16-0-account_in_payment + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-reconcile&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module enables in-payment management for all your accounting. + +Should not be installed with Enterprise Edition accounting. + +**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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Dixmit + +Contributors +------------ + +- Enric Tobella (``Dixmit ``\ \__) + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/account-reconcile `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_in_payment/__init__.py b/account_in_payment/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/account_in_payment/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_in_payment/__manifest__.py b/account_in_payment/__manifest__.py new file mode 100644 index 00000000..4bc74f0f --- /dev/null +++ b/account_in_payment/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2024 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Account In Payment", + "summary": """ + This module enables in-payment mode for your accounting""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Dixmit,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-reconcile", + "depends": ["account_reconcile_oca"], + "data": [], + "demo": [], +} diff --git a/account_in_payment/models/__init__.py b/account_in_payment/models/__init__.py new file mode 100644 index 00000000..9c0a4213 --- /dev/null +++ b/account_in_payment/models/__init__.py @@ -0,0 +1 @@ +from . import account_move diff --git a/account_in_payment/models/account_move.py b/account_in_payment/models/account_move.py new file mode 100644 index 00000000..903f6fef --- /dev/null +++ b/account_in_payment/models/account_move.py @@ -0,0 +1,22 @@ +# Copyright 2024 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models +from odoo.tools import config + + +class AccountMove(models.Model): + + _inherit = "account.move" + + @api.model + def _get_invoice_in_payment_state(self): + """ + We override this method to change the state of the invoice to in_payment + when the payment is created from the invoice. + """ + if config["test_enable"] and not self._context.get( + "test_get_invoice_in_payment_state" + ): + return super()._get_invoice_in_payment_state() + return "in_payment" diff --git a/account_in_payment/readme/CONTRIBUTORS.md b/account_in_payment/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..50d19cd9 --- /dev/null +++ b/account_in_payment/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Enric Tobella (`Dixmit `__) diff --git a/account_in_payment/readme/DESCRIPTION.md b/account_in_payment/readme/DESCRIPTION.md new file mode 100644 index 00000000..99f347aa --- /dev/null +++ b/account_in_payment/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module enables in-payment management for all your accounting. + +Should not be installed with Enterprise Edition accounting. diff --git a/account_in_payment/static/description/icon.png b/account_in_payment/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/account_in_payment/static/description/icon.png differ diff --git a/account_in_payment/static/description/index.html b/account_in_payment/static/description/index.html new file mode 100644 index 00000000..2f5986eb --- /dev/null +++ b/account_in_payment/static/description/index.html @@ -0,0 +1,421 @@ + + + + + +Account In Payment + + + +
+

Account In Payment

+ + +

Beta License: AGPL-3 OCA/account-reconcile Translate me on Weblate Try me on Runboat

+

This module enables in-payment management for all your accounting.

+

Should not be installed with Enterprise Edition accounting.

+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Dixmit
  • +
+
+
+

Contributors

+
    +
  • Enric Tobella (Dixmit <https://www.dixmit.com/>__)
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/account-reconcile project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_in_payment/tests/__init__.py b/account_in_payment/tests/__init__.py new file mode 100644 index 00000000..78da099c --- /dev/null +++ b/account_in_payment/tests/__init__.py @@ -0,0 +1 @@ +from . import test_bank_account_reconcile diff --git a/account_in_payment/tests/test_bank_account_reconcile.py b/account_in_payment/tests/test_bank_account_reconcile.py new file mode 100644 index 00000000..1eb0624e --- /dev/null +++ b/account_in_payment/tests/test_bank_account_reconcile.py @@ -0,0 +1,145 @@ +import time + +from odoo.tests import Form, tagged + +from odoo.addons.account.tests.common import TestAccountReconciliationCommon + + +@tagged("post_install", "-at_install") +class TestReconciliationWidget(TestAccountReconciliationCommon): + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) + cls.env = cls.env( + context=dict( + cls.env.context, + test_get_invoice_in_payment_state=True, + ) + ) + cls.acc_bank_stmt_model = cls.env["account.bank.statement"] + cls.acc_bank_stmt_line_model = cls.env["account.bank.statement.line"] + cls.bank_journal_usd.suspense_account_id = ( + cls.company.account_journal_suspense_account_id + ) + cls.bank_journal_euro.suspense_account_id = ( + cls.company.account_journal_suspense_account_id + ) + cls.current_assets_account = cls.env["account.account"].search( + [ + ("account_type", "=", "asset_current"), + ("company_id", "=", cls.company.id), + ], + limit=1, + ) + cls.current_assets_account.reconcile = True + # We need to make some fields visible in order to make the tests work + cls.env["ir.ui.view"].create( + { + "name": "DEMO Account bank statement", + "model": "account.bank.statement.line", + "inherit_id": cls.env.ref( + "account_reconcile_oca.bank_statement_line_form_reconcile_view" + ).id, + "arch": """ + + + 0 + + + 0 + + + 0 + + + """, + } + ) + + # Testing reconcile action + + def test_payment(self): + inv1 = self.create_invoice( + currency_id=self.currency_euro_id, + invoice_amount=100, + move_type="in_invoice", + ) + bank_stmt = self.acc_bank_stmt_model.create( + { + "company_id": self.env.ref("base.main_company").id, + "journal_id": self.bank_journal_euro.id, + "date": time.strftime("%Y-07-15"), + "name": "test", + } + ) + bank_stmt_line = self.acc_bank_stmt_line_model.create( + { + "name": "testLine", + "journal_id": self.bank_journal_euro.id, + "statement_id": bank_stmt.id, + "amount": -100, + "date": time.strftime("%Y-07-15"), + } + ) + receivable1 = inv1.line_ids.filtered( + lambda line: line.account_id.account_type == "liability_payable" + ) + with Form( + bank_stmt_line, + view="account_reconcile_oca.bank_statement_line_form_reconcile_view", + ) as f: + self.assertFalse(f.can_reconcile) + f.add_account_move_line_id = receivable1 + self.assertFalse(f.add_account_move_line_id) + self.assertTrue(f.can_reconcile) + self.assertEqual(inv1.amount_residual_signed, -100) + bank_stmt_line.reconcile_bank_line() + self.assertEqual(inv1.payment_state, "paid") + + def test_in_payment(self): + inv1 = self.create_invoice( + currency_id=self.currency_euro_id, + invoice_amount=100, + move_type="in_invoice", + ) + action = inv1.action_register_payment() + form = Form( + self.env[action["res_model"]].with_context( + mail_create_nolog=True, **action["context"] + ) + ) + payments = form.save()._create_payments() + self.assertEqual(inv1.payment_state, "in_payment") + bank_stmt = self.acc_bank_stmt_model.create( + { + "company_id": self.env.ref("base.main_company").id, + "journal_id": self.bank_journal_euro.id, + "date": time.strftime("%Y-07-15"), + "name": "test", + } + ) + bank_stmt_line = self.acc_bank_stmt_line_model.create( + { + "name": "testLine", + "journal_id": self.bank_journal_euro.id, + "statement_id": bank_stmt.id, + "amount": -100, + "date": time.strftime("%Y-07-15"), + } + ) + receivable1 = payments.line_ids.filtered(lambda line: not line.reconciled) + self.assertEqual(inv1.amount_residual_signed, 0) + with Form( + bank_stmt_line, + view="account_reconcile_oca.bank_statement_line_form_reconcile_view", + ) as f: + self.assertFalse(f.can_reconcile) + f.add_account_move_line_id = receivable1 + self.assertFalse(f.add_account_move_line_id) + self.assertTrue(f.can_reconcile) + self.assertEqual(inv1.amount_residual_signed, 0) + self.assertFalse(receivable1.reconciled) + bank_stmt_line.reconcile_bank_line() + self.assertEqual(inv1.payment_state, "paid") + self.assertEqual(inv1.amount_residual_signed, 0) + self.assertTrue(receivable1.reconciled) diff --git a/setup/account_in_payment/odoo/addons/account_in_payment b/setup/account_in_payment/odoo/addons/account_in_payment new file mode 120000 index 00000000..b921413d --- /dev/null +++ b/setup/account_in_payment/odoo/addons/account_in_payment @@ -0,0 +1 @@ +../../../../account_in_payment \ No newline at end of file diff --git a/setup/account_in_payment/setup.py b/setup/account_in_payment/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_in_payment/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)