diff --git a/README.md b/README.md deleted file mode 100644 index d1fdb4af5996..000000000000 --- a/README.md +++ /dev/null @@ -1,21 +0,0 @@ -[![Runbot Status](https://runbot.odoo-community.org/runbot/badge/flat/96/12.0.svg)](https://runbot.odoo-community.org/runbot/repo/github-com-oca-account-payment-96) -[![Build Status](https://travis-ci.org/OCA/account-payment.svg?branch=12.0)](https://travis-ci.org/OCA/account-payment) -[![Coverage Status](https://coveralls.io/repos/OCA/account-payment/badge.png?branch=12.0)](https://coveralls.io/r/OCA/account-payment?branch=12.0) - -Odoo account payment modules -============================ - -This project includes modules that handle payment related tasks: - -* Manage payment modes like the official ones Paypal. Ogone... -* Easy the visualization of payment related stuff. -* Modules that modifies the flow involved in the payment. -* ... - -You can find complementary modules for handling bank payment related tasks on: - - * https://github.com/OCA/bank-payment - -Contributing ------------- -Do you want to contribute? Please read our [contributing guidelines](https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md). diff --git a/account_payment_return_revoke_mandate/README.rst b/account_payment_return_revoke_mandate/README.rst new file mode 100644 index 000000000000..d6adda5963c7 --- /dev/null +++ b/account_payment_return_revoke_mandate/README.rst @@ -0,0 +1,81 @@ +===================================== +Account Payment Return Revoke Mandate +===================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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-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/12.0/account_payment_return_revoke_mandate + :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-12-0/account-payment-12-0-account_payment_return_revoke_mandate + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/96/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds an option on return codes in order to cancel mandates associated. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Check 'Revoke mandates' on payment return reasons that should revoke mandates. + +#. When a payment return line is received with such a reason, automatically cancel + mandates linked to concerned invoices. + +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 +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Quentin Groulard + +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_return_revoke_mandate/__init__.py b/account_payment_return_revoke_mandate/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/account_payment_return_revoke_mandate/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_payment_return_revoke_mandate/__manifest__.py b/account_payment_return_revoke_mandate/__manifest__.py new file mode 100644 index 000000000000..4b4a23529246 --- /dev/null +++ b/account_payment_return_revoke_mandate/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Account Payment Return Revoke Mandate", + "summary": """ + This addon adds an option on return codes + in order to cancel mandates associated.""", + "version": "12.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-payment", + "depends": ["account_banking_mandate", "account_payment_return"], + "data": [], + "demo": [], +} diff --git a/account_payment_return_revoke_mandate/models/__init__.py b/account_payment_return_revoke_mandate/models/__init__.py new file mode 100644 index 000000000000..84cff05cf98b --- /dev/null +++ b/account_payment_return_revoke_mandate/models/__init__.py @@ -0,0 +1,2 @@ +from . import payment_return_reason +from . import account_move_line diff --git a/account_payment_return_revoke_mandate/models/account_move_line.py b/account_payment_return_revoke_mandate/models/account_move_line.py new file mode 100644 index 000000000000..27497e5da1b0 --- /dev/null +++ b/account_payment_return_revoke_mandate/models/account_move_line.py @@ -0,0 +1,25 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models +from odoo.exceptions import UserError + + +class AccountMoveLine(models.Model): + + _inherit = "account.move.line" + + @api.multi + def _payment_returned(self, return_line): + super()._payment_returned(return_line) + if return_line.reason_id.revoke_mandates and self.mandate_id: + try: + self.mandate_id.cancel() + msg = ( + "Mandate revoked in payment return %s" + % return_line.return_id.name + ) + self.mandate_id.message_post(body=msg) + except UserError: + # May happen if the mandate is not in draft or valid state + pass diff --git a/account_payment_return_revoke_mandate/models/payment_return_reason.py b/account_payment_return_revoke_mandate/models/payment_return_reason.py new file mode 100644 index 000000000000..a6df5b87070b --- /dev/null +++ b/account_payment_return_revoke_mandate/models/payment_return_reason.py @@ -0,0 +1,11 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class PaymentReturnReason(models.Model): + + _inherit = 'payment.return.reason' + + revoke_mandates = fields.Boolean(company_dependent=True) diff --git a/account_payment_return_revoke_mandate/readme/CONTRIBUTORS.rst b/account_payment_return_revoke_mandate/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..5914f5529ef8 --- /dev/null +++ b/account_payment_return_revoke_mandate/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Quentin Groulard diff --git a/account_payment_return_revoke_mandate/readme/DESCRIPTION.rst b/account_payment_return_revoke_mandate/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..690ad0563675 --- /dev/null +++ b/account_payment_return_revoke_mandate/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds an option on return codes in order to cancel mandates associated. diff --git a/account_payment_return_revoke_mandate/readme/USAGE.rst b/account_payment_return_revoke_mandate/readme/USAGE.rst new file mode 100644 index 000000000000..4098c6dd3c64 --- /dev/null +++ b/account_payment_return_revoke_mandate/readme/USAGE.rst @@ -0,0 +1,4 @@ +#. Check 'Revoke mandates' on payment return reasons that should revoke mandates. + +#. When a payment return line is received with such a reason, automatically cancel + mandates linked to concerned invoices. diff --git a/account_payment_return_revoke_mandate/static/description/icon.png b/account_payment_return_revoke_mandate/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/account_payment_return_revoke_mandate/static/description/icon.png differ diff --git a/account_payment_return_revoke_mandate/static/description/index.html b/account_payment_return_revoke_mandate/static/description/index.html new file mode 100644 index 000000000000..a2ac0ead31a3 --- /dev/null +++ b/account_payment_return_revoke_mandate/static/description/index.html @@ -0,0 +1,428 @@ + + + + + + +Account Payment Return Revoke Mandate + + + +
+

Account Payment Return Revoke Mandate

+ + +

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

+

This module adds an option on return codes in order to cancel mandates associated.

+

Table of contents

+ +
+

Usage

+
    +
  1. Check ‘Revoke mandates’ on payment return reasons that should revoke mandates.
  2. +
  3. When a payment return line is received with such a reason, automatically cancel +mandates linked to concerned invoices.
  4. +
+
+
+

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

+
    +
  • ACSONE SA/NV
  • +
+
+
+

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/setup/account_payment_return_revoke_mandate/odoo/addons/account_payment_return_revoke_mandate b/setup/account_payment_return_revoke_mandate/odoo/addons/account_payment_return_revoke_mandate new file mode 120000 index 000000000000..b7282377e6dc --- /dev/null +++ b/setup/account_payment_return_revoke_mandate/odoo/addons/account_payment_return_revoke_mandate @@ -0,0 +1 @@ +../../../../account_payment_return_revoke_mandate \ No newline at end of file diff --git a/setup/account_payment_return_revoke_mandate/setup.py b/setup/account_payment_return_revoke_mandate/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/account_payment_return_revoke_mandate/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)