diff --git a/payment_acquirer_multi_pms_properties/README.rst b/payment_acquirer_multi_pms_properties/README.rst new file mode 100644 index 000000000..7c8d78033 --- /dev/null +++ b/payment_acquirer_multi_pms_properties/README.rst @@ -0,0 +1,81 @@ +============================== +Payment Acquirer Multiproperty +============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fpms-lightgray.png?logo=github + :target: https://github.com/OCA/pms/tree/14.0/payment_acquirer_multi_pms_properties + :alt: OCA/pms +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pms-14-0/pms-14-0-payment_acquirer_multi_pms_properties + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/293/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Set the pms property in the payment acquirer to filter on website payments + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Sets one or more properties in the payment acquirer so that payment method is only available for documents of those properties. +If you leave it blank, it will be available to everyone. + +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 +~~~~~~~ + +* Commit [Sun] + +Contributors +~~~~~~~~~~~~ + +* `Commit [Sun] `: + + * Dario Lodeiros + +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/pms `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/payment_acquirer_multi_pms_properties/__init__.py b/payment_acquirer_multi_pms_properties/__init__.py new file mode 100644 index 000000000..f7209b171 --- /dev/null +++ b/payment_acquirer_multi_pms_properties/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import controllers diff --git a/payment_acquirer_multi_pms_properties/__manifest__.py b/payment_acquirer_multi_pms_properties/__manifest__.py new file mode 100644 index 000000000..76612f5f7 --- /dev/null +++ b/payment_acquirer_multi_pms_properties/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2009-2020 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Payment Acquirer Multiproperty", + "author": "Commit [Sun], Odoo Community Association (OCA)", + "website": "https://github.com/OCA/pms", + "category": "Generic Modules/Property Management System", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "depends": [ + "pms", + ], + "data": [ + "views/payment_acquirer.xml", + ], + "installable": True, +} diff --git a/payment_acquirer_multi_pms_properties/controllers/__init__.py b/payment_acquirer_multi_pms_properties/controllers/__init__.py new file mode 100644 index 000000000..10ef4ca2e --- /dev/null +++ b/payment_acquirer_multi_pms_properties/controllers/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import portal diff --git a/payment_acquirer_multi_pms_properties/controllers/portal.py b/payment_acquirer_multi_pms_properties/controllers/portal.py new file mode 100644 index 000000000..66872f8c7 --- /dev/null +++ b/payment_acquirer_multi_pms_properties/controllers/portal.py @@ -0,0 +1,23 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.addons.account.controllers.portal import PortalAccount + + +class PortalAccount(PortalAccount): + def _invoice_get_page_view_values(self, invoice, access_token, **kwargs): + """ + Override to add the pms property filter + """ + values = super(PortalAccount, self)._invoice_get_page_view_values( + invoice, access_token, **kwargs + ) + for acquirer in values["acquirers"]: + if ( + acquirer.pms_property_ids + and invoice.pms_property_id.id not in acquirer.pms_property_ids.ids + ): + values["acquirers"] -= acquirer + for pms in values["pms"]: + if pms.acquirer_id not in values["acquirers"].ids: + values["pms"] -= pms + return values diff --git a/payment_acquirer_multi_pms_properties/models/__init__.py b/payment_acquirer_multi_pms_properties/models/__init__.py new file mode 100644 index 000000000..14289a55a --- /dev/null +++ b/payment_acquirer_multi_pms_properties/models/__init__.py @@ -0,0 +1 @@ +from . import payment_acquirer diff --git a/payment_acquirer_multi_pms_properties/models/payment_acquirer.py b/payment_acquirer_multi_pms_properties/models/payment_acquirer.py new file mode 100644 index 000000000..0cdece11e --- /dev/null +++ b/payment_acquirer_multi_pms_properties/models/payment_acquirer.py @@ -0,0 +1,21 @@ +# Copyright 2009-2020 Noviat +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class PaymentAcquirer(models.Model): + _inherit = "payment.acquirer" + _check_pms_properties_auto = True + + pms_property_ids = fields.Many2many( + string="Properties", + help="Properties with access to the element;" + " if not set, all properties can access", + required=False, + comodel_name="pms.property", + relation="pms_acquirer_property_rel", + column1="acquirer_id", + column2="property_id", + check_pms_properties=True, + ) diff --git a/payment_acquirer_multi_pms_properties/readme/CONTRIBUTORS.rst b/payment_acquirer_multi_pms_properties/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..f94c25c48 --- /dev/null +++ b/payment_acquirer_multi_pms_properties/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Commit [Sun] `: + + * Dario Lodeiros diff --git a/payment_acquirer_multi_pms_properties/readme/DESCRIPTION.rst b/payment_acquirer_multi_pms_properties/readme/DESCRIPTION.rst new file mode 100644 index 000000000..867281477 --- /dev/null +++ b/payment_acquirer_multi_pms_properties/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Set the pms property in the payment acquirer to filter on website payments diff --git a/payment_acquirer_multi_pms_properties/readme/USAGE.rst b/payment_acquirer_multi_pms_properties/readme/USAGE.rst new file mode 100644 index 000000000..ab14d2bed --- /dev/null +++ b/payment_acquirer_multi_pms_properties/readme/USAGE.rst @@ -0,0 +1,2 @@ +Sets one or more properties in the payment acquirer so that payment method is only available for documents of those properties. +If you leave it blank, it will be available to everyone. diff --git a/payment_acquirer_multi_pms_properties/static/description/index.html b/payment_acquirer_multi_pms_properties/static/description/index.html new file mode 100644 index 000000000..242d6557f --- /dev/null +++ b/payment_acquirer_multi_pms_properties/static/description/index.html @@ -0,0 +1,428 @@ + + + + + + +Payment Acquirer Multiproperty + + + +
+

Payment Acquirer Multiproperty

+ + +

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

+

Set the pms property in the payment acquirer to filter on website payments

+

Table of contents

+ +
+

Usage

+

Sets one or more properties in the payment acquirer so that payment method is only available for documents of those properties. +If you leave it blank, it will be available to everyone.

+
+
+

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

+
    +
  • Commit [Sun]
  • +
+
+
+

Contributors

+
    +
  • Commit [Sun] <https://www.commitsun.com>:
      +
    • Dario Lodeiros
    • +
    +
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/payment_acquirer_multi_pms_properties/views/payment_acquirer.xml b/payment_acquirer_multi_pms_properties/views/payment_acquirer.xml new file mode 100644 index 000000000..068bed062 --- /dev/null +++ b/payment_acquirer_multi_pms_properties/views/payment_acquirer.xml @@ -0,0 +1,15 @@ + + + + + muliproperty.payment.acquirer.form + payment.acquirer + + + + + + + + + diff --git a/setup/payment_acquirer_multi_pms_properties/odoo/addons/payment_acquirer_multi_pms_properties b/setup/payment_acquirer_multi_pms_properties/odoo/addons/payment_acquirer_multi_pms_properties new file mode 120000 index 000000000..b15d2cda5 --- /dev/null +++ b/setup/payment_acquirer_multi_pms_properties/odoo/addons/payment_acquirer_multi_pms_properties @@ -0,0 +1 @@ +../../../../payment_acquirer_multi_pms_properties \ No newline at end of file diff --git a/setup/payment_acquirer_multi_pms_properties/setup.py b/setup/payment_acquirer_multi_pms_properties/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/payment_acquirer_multi_pms_properties/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)