From 7775d105f4dcaf0996cf668c7aa80e76cb502933 Mon Sep 17 00:00:00 2001 From: Ernesto Tejeda Date: Fri, 9 Dec 2022 09:55:37 +0100 Subject: [PATCH] [MIG] account_banking_mandate_contact: Migration to 15.0 --- account_banking_mandate_contact/README.rst | 46 +- .../__manifest__.py | 2 +- .../i18n/account_banking_mandate_contact.pot | 2 +- .../models/account_move_line.py | 2 +- .../models/res_partner.py | 2 +- .../readme/CONTRIBUTORS.rst | 6 +- .../readme/DESCRIPTION.rst | 4 +- .../readme/USAGE.rst | 15 +- .../static/description/index.html | 447 ++++++++++++++++++ .../tests/test_account_payment_order.py | 44 +- 10 files changed, 541 insertions(+), 29 deletions(-) create mode 100644 account_banking_mandate_contact/static/description/index.html diff --git a/account_banking_mandate_contact/README.rst b/account_banking_mandate_contact/README.rst index b858bc439..b5390d6bd 100644 --- a/account_banking_mandate_contact/README.rst +++ b/account_banking_mandate_contact/README.rst @@ -2,10 +2,13 @@ Account Banking Mandate Contact =============================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:72ef0855d177fa6dd1f3596940a04f53c849846bbe4590ff8a273197d0eaea1e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png :target: https://odoo-community.org/page/development-status @@ -14,18 +17,20 @@ Account Banking Mandate Contact :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github - :target: https://github.com/OCA/bank-payment/tree/12.0/account_banking_mandate_contact + :target: https://github.com/OCA/bank-payment/tree/15.0/account_banking_mandate_contact :alt: OCA/bank-payment .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/bank-payment-12-0/bank-payment-12-0-account_banking_mandate_contact + :target: https://translation.odoo-community.org/projects/bank-payment-15-0/bank-payment-15-0-account_banking_mandate_contact :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/173/12.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/bank-payment&target_branch=15.0 + :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| -Manage specific banking mandate in contact level +This module allows to select a specific banking mandate +(and thus, a specific bank account) at contact level, so that when doing +a debit order, such mandate is used for the invoices issued to that contact. **Table of contents** @@ -35,15 +40,28 @@ Manage specific banking mandate in contact level Usage ===== -To use this module you need to: +For selecting the mandate at contact level: + +#. Go to *Invoicing > Customers > Customers*. +#. Open or create one contact that has a parent. +#. On the "..." page, fill *Contact Mandate*. +#. That mandate will be populated in the debit order. + +Then the normal flow will be: + +#. Go to Invoicing > Customers > Customer invoices. +#. Create a new invoice for that contact. +#. Post the invoice. +#. Add it to a payment order, by any of the options that you can check on the *account_payment_order* module. +#. The populated mandate will be the one on the contact. 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 `_. +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. @@ -58,7 +76,11 @@ Authors Contributors ~~~~~~~~~~~~ -* Carlos Dauden +* `Tecnativa `_: + + * Carlos Dauden + * Ernesto Tejeda + * Pedro M. Baeza Maintainers ~~~~~~~~~~~ @@ -73,6 +95,6 @@ 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/bank-payment `_ project on GitHub. +This module is part of the `OCA/bank-payment `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_banking_mandate_contact/__manifest__.py b/account_banking_mandate_contact/__manifest__.py index b87ba80f8..026a6a89c 100644 --- a/account_banking_mandate_contact/__manifest__.py +++ b/account_banking_mandate_contact/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Account Banking Mandate Contact", "summary": "Assign specific banking mandates in contact level", - "version": "13.0.1.0.0", + "version": "15.0.1.0.0", "development_status": "Production/Stable", "category": "Banking addons", "website": "https://github.com/OCA/bank-payment", diff --git a/account_banking_mandate_contact/i18n/account_banking_mandate_contact.pot b/account_banking_mandate_contact/i18n/account_banking_mandate_contact.pot index 7a501e0b3..f129f31cf 100644 --- a/account_banking_mandate_contact/i18n/account_banking_mandate_contact.pot +++ b/account_banking_mandate_contact/i18n/account_banking_mandate_contact.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0\n" +"Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" diff --git a/account_banking_mandate_contact/models/account_move_line.py b/account_banking_mandate_contact/models/account_move_line.py index cf979797e..3ff0fd57a 100644 --- a/account_banking_mandate_contact/models/account_move_line.py +++ b/account_banking_mandate_contact/models/account_move_line.py @@ -11,7 +11,7 @@ class AccountMoveLine(models.Model): # Extended to use partner_shipping_id mandate if it have set def _prepare_payment_line_vals(self, payment_order): vals = super(AccountMoveLine, self)._prepare_payment_line_vals(payment_order) - if payment_order.payment_type != "inbound" or self.mandate_id: + if payment_order.payment_type != "inbound" or self.move_id.mandate_id: return vals mandate = ( self.move_id.partner_shipping_id.valid_mandate_id diff --git a/account_banking_mandate_contact/models/res_partner.py b/account_banking_mandate_contact/models/res_partner.py index d8906e70b..4a397d3a3 100644 --- a/account_banking_mandate_contact/models/res_partner.py +++ b/account_banking_mandate_contact/models/res_partner.py @@ -18,4 +18,4 @@ class ResPartner(models.Model): if partner.contact_mandate_id.state == "valid": partner.valid_mandate_id = partner.contact_mandate_id procesed_partners |= partner - super(ResPartner, self - procesed_partners)._compute_valid_mandate_id() + return super(ResPartner, self - procesed_partners)._compute_valid_mandate_id() diff --git a/account_banking_mandate_contact/readme/CONTRIBUTORS.rst b/account_banking_mandate_contact/readme/CONTRIBUTORS.rst index d4af61ff6..35b76b8b0 100644 --- a/account_banking_mandate_contact/readme/CONTRIBUTORS.rst +++ b/account_banking_mandate_contact/readme/CONTRIBUTORS.rst @@ -1 +1,5 @@ -* Carlos Dauden +* `Tecnativa `_: + + * Carlos Dauden + * Ernesto Tejeda + * Pedro M. Baeza diff --git a/account_banking_mandate_contact/readme/DESCRIPTION.rst b/account_banking_mandate_contact/readme/DESCRIPTION.rst index f53813c8c..24fdda832 100644 --- a/account_banking_mandate_contact/readme/DESCRIPTION.rst +++ b/account_banking_mandate_contact/readme/DESCRIPTION.rst @@ -1 +1,3 @@ -Manage specific banking mandate in contact level +This module allows to select a specific banking mandate +(and thus, a specific bank account) at contact level, so that when doing +a debit order, such mandate is used for the invoices issued to that contact. diff --git a/account_banking_mandate_contact/readme/USAGE.rst b/account_banking_mandate_contact/readme/USAGE.rst index 334d594cb..4a571f4fc 100644 --- a/account_banking_mandate_contact/readme/USAGE.rst +++ b/account_banking_mandate_contact/readme/USAGE.rst @@ -1 +1,14 @@ -To use this module you need to: +For selecting the mandate at contact level: + +#. Go to *Invoicing > Customers > Customers*. +#. Open or create one contact that has a parent. +#. On the "..." page, fill *Contact Mandate*. +#. That mandate will be populated in the debit order. + +Then the normal flow will be: + +#. Go to Invoicing > Customers > Customer invoices. +#. Create a new invoice for that contact. +#. Post the invoice. +#. Add it to a payment order, by any of the options that you can check on the *account_payment_order* module. +#. The populated mandate will be the one on the contact. diff --git a/account_banking_mandate_contact/static/description/index.html b/account_banking_mandate_contact/static/description/index.html new file mode 100644 index 000000000..af46009bb --- /dev/null +++ b/account_banking_mandate_contact/static/description/index.html @@ -0,0 +1,447 @@ + + + + + + +Account Banking Mandate Contact + + + +
+

Account Banking Mandate Contact

+ + +

Production/Stable License: AGPL-3 OCA/bank-payment Translate me on Weblate Try me on Runboat

+

This module allows to select a specific banking mandate +(and thus, a specific bank account) at contact level, so that when doing +a debit order, such mandate is used for the invoices issued to that contact.

+

Table of contents

+ +
+

Usage

+

For selecting the mandate at contact level:

+
    +
  1. Go to Invoicing > Customers > Customers.
  2. +
  3. Open or create one contact that has a parent.
  4. +
  5. On the “…” page, fill Contact Mandate.
  6. +
  7. That mandate will be populated in the debit order.
  8. +
+

Then the normal flow will be:

+
    +
  1. Go to Invoicing > Customers > Customer invoices.
  2. +
  3. Create a new invoice for that contact.
  4. +
  5. Post the invoice.
  6. +
  7. Add it to a payment order, by any of the options that you can check on the account_payment_order module.
  8. +
  9. The populated mandate will be the one on the contact.
  10. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Carlos Dauden
    • +
    • Ernesto Tejeda
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/account_banking_mandate_contact/tests/test_account_payment_order.py b/account_banking_mandate_contact/tests/test_account_payment_order.py index 79da668f7..30c6428ce 100644 --- a/account_banking_mandate_contact/tests/test_account_payment_order.py +++ b/account_banking_mandate_contact/tests/test_account_payment_order.py @@ -1,26 +1,30 @@ # Copyright 2021 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl + +from unittest.mock import patch + from odoo import fields from odoo.tests.common import Form, TransactionCase +from odoo.addons.account.models.account_payment_method import AccountPaymentMethod + class TestAccountPaymentOrder(TransactionCase): def setUp(self): - super(TestAccountPaymentOrder, self).setUp() + super().setUp() self.partner = self.env["res.partner"].create({"name": "Test Partner"}) self.product = self.env["product.product"].create({"name": "Test product"}) self.partner_bank_core = self._create_res_partner_bank("N-CORE") self.mandate_core = self._create_mandate(self.partner_bank_core, "CORE") self.partner_bank_b2b = self._create_res_partner_bank("N-B2B") self.mandate_b2b = self._create_mandate(self.partner_bank_b2b, "B2B") - self.method_sepa = self.env["account.payment.method"].create( - { - "name": "SEPA", - "code": "sepa_direct_debit", - "payment_type": "inbound", - "bank_account_required": True, - } - ) + payment_method_vals = { + "name": "SEPA", + "code": "sepa_direct_debit", + "payment_type": "inbound", + "bank_account_required": True, + } + self.method_sepa = self._create_multi_bank_payment_method(payment_method_vals) self.journal_bank = self.env["account.journal"].create( {"name": "BANK", "type": "bank", "code": "bank"} ) @@ -45,6 +49,26 @@ class TestAccountPaymentOrder(TransactionCase): payment_order_form.payment_mode_id = self.payment_core self.payment_order = payment_order_form.save() + def _create_multi_bank_payment_method(self, payment_method_vals): + method_get_payment_method_information = ( + AccountPaymentMethod._get_payment_method_information + ) + + def _get_payment_method_information(self): + res = method_get_payment_method_information(self) + res[payment_method_vals["code"]] = { + "mode": "multi", + "domain": [("type", "=", "bank")], + } + return res + + with patch.object( + AccountPaymentMethod, + "_get_payment_method_information", + _get_payment_method_information, + ): + return self.env["account.payment.method"].create(payment_method_vals) + def _create_res_partner_bank(self, acc_number): res_partner_bank_form = Form(self.env["res.partner.bank"]) res_partner_bank_form.partner_id = self.partner @@ -61,7 +85,7 @@ class TestAccountPaymentOrder(TransactionCase): def _create_invoice(self): invoice_form = Form( - self.env["account.move"].with_context(default_type="out_invoice") + self.env["account.move"].with_context(default_move_type="out_invoice") ) invoice_form.partner_id = self.partner invoice_form.invoice_date = fields.Date.from_string("2021-01-01")