From 63f3dd39e8c20fd4860582f5caa4663580ec82fd Mon Sep 17 00:00:00 2001 From: Unai Beristain Date: Wed, 16 Oct 2024 12:54:10 +0200 Subject: [PATCH] [ADD] website_payment_acquirer_bank_account --- .../website_payment_acquirer_bank_account | 1 + .../setup.py | 6 + .../README.rst | 73 +++++++ .../__init__.py | 1 + .../__manifest__.py | 16 ++ .../models/__init__.py | 3 + .../models/res_bank_account.py | 10 + .../models/res_partner.py | 11 + .../models/sale_order.py | 29 +++ .../views/payment_view.xml | 196 ++++++++++++++++++ 10 files changed, 346 insertions(+) create mode 120000 setup/website_payment_acquirer_bank_account/odoo/addons/website_payment_acquirer_bank_account create mode 100644 setup/website_payment_acquirer_bank_account/setup.py create mode 100644 website_payment_acquirer_bank_account/README.rst create mode 100644 website_payment_acquirer_bank_account/__init__.py create mode 100644 website_payment_acquirer_bank_account/__manifest__.py create mode 100644 website_payment_acquirer_bank_account/models/__init__.py create mode 100644 website_payment_acquirer_bank_account/models/res_bank_account.py create mode 100644 website_payment_acquirer_bank_account/models/res_partner.py create mode 100644 website_payment_acquirer_bank_account/models/sale_order.py create mode 100644 website_payment_acquirer_bank_account/views/payment_view.xml diff --git a/setup/website_payment_acquirer_bank_account/odoo/addons/website_payment_acquirer_bank_account b/setup/website_payment_acquirer_bank_account/odoo/addons/website_payment_acquirer_bank_account new file mode 120000 index 0000000000..781efd05bb --- /dev/null +++ b/setup/website_payment_acquirer_bank_account/odoo/addons/website_payment_acquirer_bank_account @@ -0,0 +1 @@ +../../../../website_payment_acquirer_bank_account \ No newline at end of file diff --git a/setup/website_payment_acquirer_bank_account/setup.py b/setup/website_payment_acquirer_bank_account/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/website_payment_acquirer_bank_account/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/website_payment_acquirer_bank_account/README.rst b/website_payment_acquirer_bank_account/README.rst new file mode 100644 index 0000000000..7ad318ca9b --- /dev/null +++ b/website_payment_acquirer_bank_account/README.rst @@ -0,0 +1,73 @@ +.. image:: https://img.shields.io/badge/license-LGPL--3-blue.svg + :target: https://opensource.org/licenses/LGPL-3.0 + :alt: License: LGPL-3 + +================================= +Account Payment Mode and Acquirer +================================= + +Overview +======== + +The **Account Payment Mode and Acquirer** module integrates payment modes with bank accounts in sales. It allows users to select a bank account for payments directly from the sales order, enhancing the payment processing workflow. + +Features +======== + +- **Bank Account Selection**: Users can select a bank account for payments directly from the sales order. + +- **Automatic Payment Mode Assignment**: When confirming an order, the payment mode is automatically set based on the selected bank account. + +- **Bank Account Management**: Users can create new bank accounts linked to partners seamlessly. + +Usage +===== + +1. **Install the Module**: + + - Install the module via Odoo's Apps interface. + +2. **Using Bank Accounts**: + + - When creating or editing a sales order, select a bank account from the dropdown. + - Confirm the order, and the payment mode will automatically be assigned based on the selected bank account. + +Configuration +============= + +No additional configuration is required. The module is ready to use once installed. + +Testing +======= + +Test the following scenarios: + +- **Bank Account Selection**: + + - Create or edit a sales order and select a bank account. + - Confirm the order and verify that the payment mode is set correctly. + +- **Bank Account Creation**: + + - Create a new bank account from the sales order and ensure it links correctly to the partner. + +Bug Tracker +=========== + +If you encounter any issues, please report them on the GitHub repository at `GitHub Issues `_. + +Credits +======= + +Contributors +------------ + +* Unai Beristain +* Ana Juaristi + +For module-specific questions, please contact the contributors directly. Support requests should be made through the official channels. + +License +======= + +This project is licensed under the LGPL-3 License. For more details, please refer to the LICENSE file or visit . diff --git a/website_payment_acquirer_bank_account/__init__.py b/website_payment_acquirer_bank_account/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/website_payment_acquirer_bank_account/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/website_payment_acquirer_bank_account/__manifest__.py b/website_payment_acquirer_bank_account/__manifest__.py new file mode 100644 index 0000000000..18ee311be0 --- /dev/null +++ b/website_payment_acquirer_bank_account/__manifest__.py @@ -0,0 +1,16 @@ +{ + "name": "Account Payment Mode and Acquirer", + "version": "14.0.1.0.0", + "author": "Avanzosc", + "summary": "Integrates payment modes with bank accounts in sales.", + "website": "https://github.com/avanzosc/odoo-addons", + "license": "LGPL-3", + "depends": [ + "sale", + "account", + "payment_acquirer_payment_mode", # trey + ], + "data": ["views/payment_view.xml"], + "installable": True, + "application": False, +} diff --git a/website_payment_acquirer_bank_account/models/__init__.py b/website_payment_acquirer_bank_account/models/__init__.py new file mode 100644 index 0000000000..ad77877f42 --- /dev/null +++ b/website_payment_acquirer_bank_account/models/__init__.py @@ -0,0 +1,3 @@ +from . import res_bank_account +from . import res_partner +from . import sale_order diff --git a/website_payment_acquirer_bank_account/models/res_bank_account.py b/website_payment_acquirer_bank_account/models/res_bank_account.py new file mode 100644 index 0000000000..0de065f836 --- /dev/null +++ b/website_payment_acquirer_bank_account/models/res_bank_account.py @@ -0,0 +1,10 @@ +from odoo import fields, models + + +class ResBankAccount(models.Model): + _name = "res.bank.account" + _description = "Bank Account" + + name = fields.Char(string="Account Name", required=True) + bank_account = fields.Char(string="Bank Account", required=True) + partner_id = fields.Many2one("res.partner", string="Partner", required=True) diff --git a/website_payment_acquirer_bank_account/models/res_partner.py b/website_payment_acquirer_bank_account/models/res_partner.py new file mode 100644 index 0000000000..e3e84ae644 --- /dev/null +++ b/website_payment_acquirer_bank_account/models/res_partner.py @@ -0,0 +1,11 @@ +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + bank_account_ids = fields.One2many( + "res.bank.account", + "partner_id", + string="Bank Accounts", + ) diff --git a/website_payment_acquirer_bank_account/models/sale_order.py b/website_payment_acquirer_bank_account/models/sale_order.py new file mode 100644 index 0000000000..59cf8dff6b --- /dev/null +++ b/website_payment_acquirer_bank_account/models/sale_order.py @@ -0,0 +1,29 @@ +from odoo import _, fields, models +from odoo.exceptions import ValidationError + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + bank_account_id = fields.Many2one( + "res.bank.account", + string="Bank Account", + help="Bank account selected for the payment.", + ) + + def confirm_order(self): + self.ensure_one() + if self.bank_account_id: + # Si hay una cuenta bancaria seleccionada + self.payment_mode_id = self.bank_account_id.payment_method_id + # Crear la cuenta bancaria si es nueva + if not self.bank_account_id.exists(): + self.env["res.bank.account"].create( + { + "name": self.bank_account_id.name, + "bank_account": self.bank_account_id.bank_account, + "partner_id": self.partner_id.id, + } + ) + else: + raise ValidationError(_("Please select a bank account.")) diff --git a/website_payment_acquirer_bank_account/views/payment_view.xml b/website_payment_acquirer_bank_account/views/payment_view.xml new file mode 100644 index 0000000000..7dc7203ee1 --- /dev/null +++ b/website_payment_acquirer_bank_account/views/payment_view.xml @@ -0,0 +1,196 @@ + + + + payment.form.inherit + payment.acquirer + + + + False + + +
+ + + + +
+ + +
+
+ +
+ + + + +
+
+ +
+
+ + + + + + +
+
+
+ + + +
+ + +
+
+
+
+ + + +