diff --git a/account_payment_select_account/README.rst b/account_payment_select_account/README.rst new file mode 100644 index 00000000000..5ce1414f8d7 --- /dev/null +++ b/account_payment_select_account/README.rst @@ -0,0 +1,82 @@ +================================ +Account Payment - Select Account +================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:05d5197f40bd5ec35c10135b477053a293aa05430fb8f3c578a65c6fbdcfc3a2 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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--payment-lightgray.png?logo=github + :target: https://github.com/OCA/account-payment/tree/18.0/account_payment_select_account + :alt: OCA/account-payment +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-payment-18-0/account-payment-18-0-account_payment_select_account + :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-payment&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allow user to select the account on Register Payment of Invoice if the +Outstanding Receipts / Payment account is not set in the selected +Payment Method + +**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 +------- + +* La Louve +* Druidoo + +Contributors +------------ + +- ajayjaviya +- `Trobz `__ + + - Phan Hong Phuc + +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-payment `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_payment_select_account/__init__.py b/account_payment_select_account/__init__.py new file mode 100644 index 00000000000..8ad85b98ccc --- /dev/null +++ b/account_payment_select_account/__init__.py @@ -0,0 +1,7 @@ +# Copyright (C) 2016-Today: La Louve () +# Copyright (C) 2019-Today: Druidoo () +# @author: La Louve +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html + +from . import models +from . import wizard diff --git a/account_payment_select_account/__manifest__.py b/account_payment_select_account/__manifest__.py new file mode 100644 index 00000000000..4f8312a96d8 --- /dev/null +++ b/account_payment_select_account/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright (C) 2016-Today: La Louve () +# Copyright (C) 2019-Today: Druidoo () +# @author: La Louve +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html + +{ + "name": "Account Payment - Select Account", + "version": "18.0.1.0.0", + "category": "Accounting & Finance", + "author": "La Louve, Druidoo, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-payment", + "license": "AGPL-3", + "depends": [ + "account", + ], + "data": [ + "wizard/account_payment_register_views.xml", + ], + "demo": [], +} diff --git a/account_payment_select_account/i18n/account_payment_select_account.pot b/account_payment_select_account/i18n/account_payment_select_account.pot new file mode 100644 index 00000000000..75bf5ec2fe7 --- /dev/null +++ b/account_payment_select_account/i18n/account_payment_select_account.pot @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_select_account +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-11-21 04:23+0000\n" +"PO-Revision-Date: 2025-11-21 04:23+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_payment_select_account +#: model:ir.model.fields,field_description:account_payment_select_account.field_account_payment_register__payment_account_id +msgid "Account" +msgstr "" + +#. module: account_payment_select_account +#: model:ir.model.fields,field_description:account_payment_select_account.field_account_payment__outstanding_account_id +msgid "Outstanding Account" +msgstr "" + +#. module: account_payment_select_account +#: model:ir.model,name:account_payment_select_account.model_account_payment_register +msgid "Pay" +msgstr "" + +#. module: account_payment_select_account +#: model:ir.model,name:account_payment_select_account.model_account_payment +msgid "Payments" +msgstr "" + +#. module: account_payment_select_account +#: model:ir.model.fields,field_description:account_payment_select_account.field_account_payment_register__require_payment_account +msgid "Require Payment Account" +msgstr "" diff --git a/account_payment_select_account/i18n/fr.po b/account_payment_select_account/i18n/fr.po new file mode 100644 index 00000000000..d26c9cd5fb3 --- /dev/null +++ b/account_payment_select_account/i18n/fr.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_select_account +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-11-21 04:21+0000\n" +"PO-Revision-Date: 2025-11-21 04:21+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_payment_select_account +#: model:ir.model.fields,field_description:account_payment_select_account.field_account_payment_register__payment_account_id +msgid "Account" +msgstr "Compte" + +#. module: account_payment_select_account +#: model:ir.model.fields,field_description:account_payment_select_account.field_account_payment__outstanding_account_id +msgid "Outstanding Account" +msgstr "Compte en suspens" + +#. module: account_payment_select_account +#: model:ir.model,name:account_payment_select_account.model_account_payment_register +msgid "Pay" +msgstr "Payer" + +#. module: account_payment_select_account +#: model:ir.model,name:account_payment_select_account.model_account_payment +msgid "Payments" +msgstr "Paiements" + +#. module: account_payment_select_account +#: model:ir.model.fields,field_description:account_payment_select_account.field_account_payment_register__require_payment_account +msgid "Require Payment Account" +msgstr "Compte de paiement requis" diff --git a/account_payment_select_account/models/__init__.py b/account_payment_select_account/models/__init__.py new file mode 100644 index 00000000000..abcf5ed90bb --- /dev/null +++ b/account_payment_select_account/models/__init__.py @@ -0,0 +1,6 @@ +# Copyright (C) 2016-Today: La Louve () +# Copyright (C) 2019-Today: Druidoo () +# @author: La Louve +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html + +from . import account_payment diff --git a/account_payment_select_account/models/account_payment.py b/account_payment_select_account/models/account_payment.py new file mode 100644 index 00000000000..687bd3092b7 --- /dev/null +++ b/account_payment_select_account/models/account_payment.py @@ -0,0 +1,12 @@ +# Copyright (C) 2016-Today: La Louve () +# Copyright (C) 2019-Today: Druidoo () +# @author: La Louve +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html + +from odoo import fields, models + + +class AccountPayment(models.Model): + _inherit = "account.payment" + + outstanding_account_id = fields.Many2one(readonly=False) diff --git a/account_payment_select_account/pyproject.toml b/account_payment_select_account/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/account_payment_select_account/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_payment_select_account/readme/CONTRIBUTORS.md b/account_payment_select_account/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..2424efc4d72 --- /dev/null +++ b/account_payment_select_account/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- ajayjaviya +- [Trobz](https://www.trobz.com) + - Phan Hong Phuc \ diff --git a/account_payment_select_account/readme/DESCRIPTION.md b/account_payment_select_account/readme/DESCRIPTION.md new file mode 100644 index 00000000000..7a93d9ea30d --- /dev/null +++ b/account_payment_select_account/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +Allow user to select the account on Register Payment of Invoice if the +Outstanding Receipts / Payment account is not set in the selected Payment Method diff --git a/account_payment_select_account/static/description/icon.png b/account_payment_select_account/static/description/icon.png new file mode 100644 index 00000000000..fd60220fbe2 Binary files /dev/null and b/account_payment_select_account/static/description/icon.png differ diff --git a/account_payment_select_account/static/description/index.html b/account_payment_select_account/static/description/index.html new file mode 100644 index 00000000000..faf581531b2 --- /dev/null +++ b/account_payment_select_account/static/description/index.html @@ -0,0 +1,430 @@ + + + + + +Account Payment - Select Account + + + +
+

Account Payment - Select Account

+ + +

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

+

Allow user to select the account on Register Payment of Invoice if the +Outstanding Receipts / Payment account is not set in the selected +Payment Method

+

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

+
    +
  • La Louve
  • +
  • Druidoo
  • +
+
+
+

Contributors

+ +
+
+

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-payment project on GitHub.

+

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

+
+
+
+ + diff --git a/account_payment_select_account/tests/__init__.py b/account_payment_select_account/tests/__init__.py new file mode 100644 index 00000000000..07a6977b518 --- /dev/null +++ b/account_payment_select_account/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_payment_select_account diff --git a/account_payment_select_account/tests/test_account_payment_select_account.py b/account_payment_select_account/tests/test_account_payment_select_account.py new file mode 100644 index 00000000000..f597201f8c5 --- /dev/null +++ b/account_payment_select_account/tests/test_account_payment_select_account.py @@ -0,0 +1,122 @@ +from odoo.tests import tagged + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon +from odoo.addons.payment.tests.common import PaymentCommon + + +@tagged("-at_install", "post_install") +class TestAccountPaymentRegister(AccountTestInvoicingCommon, PaymentCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.AccountPaymentRegister = cls.env["account.payment.register"] + cls.PaymentMethod = cls.env["account.payment.method"] + cls.PaymentMethodLine = cls.env["account.payment.method.line"] + cls.AccountAccount = cls.env["account.account"] + cls.payment_account = cls.AccountAccount.create( + { + "name": "Test Payment Account", + "code": "TEST.ACC", + "account_type": "asset_cash", + } + ) + cls.payment_method = cls.PaymentMethod.sudo().create( + { + "name": "Test Method", + "code": "test_method", + "payment_type": "outbound", + } + ) + cls.payment_method_line_with_acc = cls.PaymentMethodLine.sudo().create( + { + "name": "Method with Account", + "payment_method_id": cls.payment_method.id, + "payment_account_id": cls.payment_account.id, + "payment_type": "outbound", + "company_id": cls.env.company.id, + } + ) + cls.payment_method_line_without_acc = cls.PaymentMethodLine.sudo().create( + { + "name": "Method without Account", + "payment_method_id": cls.payment_method.id, + "payment_type": "outbound", + "company_id": cls.env.company.id, + } + ) + cls.out_invoice_1 = cls.env["account.move"].create( + { + "move_type": "out_invoice", + "date": "2017-01-01", + "invoice_date": "2017-01-01", + "partner_id": cls.partner_a.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "product_id": cls.product_a.id, + "price_unit": 1000.0, + "tax_ids": [], + }, + ) + ], + } + ) + + def test_require_payment_account_compute(self): + """It should require a payment account only if payment method has no account.""" + + wizard = self.AccountPaymentRegister.new( + { + "payment_method_line_id": self.payment_method_line_without_acc.id, + } + ) + wizard._compute_require_payment_account() + self.assertTrue(wizard.require_payment_account) + + wizard_with_acc = self.AccountPaymentRegister.new( + { + "payment_method_line_id": self.payment_method_line_with_acc.id, + } + ) + wizard_with_acc._compute_require_payment_account() + self.assertFalse(wizard_with_acc.require_payment_account) + + def test_create_payment_vals_with_custom_account(self): + """When require_payment_account=True and payment_account_id is set, + it should add outstanding_account_id to payment vals.""" + active_ids = self.out_invoice_1.ids + wizard = self.AccountPaymentRegister.with_context( + active_model="account.move", active_ids=active_ids + ).create( + { + "payment_method_line_id": self.payment_method_line_without_acc.id, + "payment_account_id": self.payment_account.id, + } + ) + wizard._compute_require_payment_account() + batch_result = self.env["account.payment"].new({}) # dummy batch result + + vals = wizard._create_payment_vals_from_wizard(batch_result) + self.assertEqual(vals.get("outstanding_account_id"), self.payment_account.id) + payments = wizard._create_payments() + self.assertEqual(len(payments), 1) + self.assertEqual(payments.outstanding_account_id, self.payment_account) + + def test_create_payment_vals_without_custom_account(self): + """If require_payment_account=False, + no outstanding_account_id should be added.""" + active_ids = self.out_invoice_1.ids + wizard = self.AccountPaymentRegister.with_context( + active_model="account.move", active_ids=active_ids + ).create( + { + "payment_method_line_id": self.payment_method_line_with_acc.id, + } + ) + wizard._compute_require_payment_account() + batch_result = self.env["account.payment"].new({}) # dummy batch result + + vals = wizard._create_payment_vals_from_wizard(batch_result) + self.assertNotIn("outstanding_account_id", vals) diff --git a/account_payment_select_account/wizard/__init__.py b/account_payment_select_account/wizard/__init__.py new file mode 100644 index 00000000000..019698a882d --- /dev/null +++ b/account_payment_select_account/wizard/__init__.py @@ -0,0 +1 @@ +from . import account_payment_register diff --git a/account_payment_select_account/wizard/account_payment_register.py b/account_payment_select_account/wizard/account_payment_register.py new file mode 100644 index 00000000000..800ffb38e36 --- /dev/null +++ b/account_payment_select_account/wizard/account_payment_register.py @@ -0,0 +1,25 @@ +from odoo import api, fields, models + + +class AccountPaymentRegister(models.TransientModel): + _inherit = "account.payment.register" + + payment_account_id = fields.Many2one("account.account", string="Account") + require_payment_account = fields.Boolean( + compute="_compute_require_payment_account", + ) + + @api.depends( + "payment_method_line_id.payment_account_id", + ) + def _compute_require_payment_account(self): + for rec in self: + rec.require_payment_account = ( + not rec.payment_method_line_id.payment_account_id + ) + + def _create_payment_vals_from_wizard(self, batch_result): + res = super()._create_payment_vals_from_wizard(batch_result) + if self.require_payment_account and self.payment_account_id: + res["outstanding_account_id"] = self.payment_account_id.id + return res diff --git a/account_payment_select_account/wizard/account_payment_register_views.xml b/account_payment_select_account/wizard/account_payment_register_views.xml new file mode 100644 index 00000000000..bedcef95c4b --- /dev/null +++ b/account_payment_select_account/wizard/account_payment_register_views.xml @@ -0,0 +1,18 @@ + + + + account.payment.register.form.inherit + account.payment.register + + + + + + + +