diff --git a/account_payment_portal/README.rst b/account_payment_portal/README.rst new file mode 100644 index 0000000..05a5636 --- /dev/null +++ b/account_payment_portal/README.rst @@ -0,0 +1,74 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +====================== +Account Payment Portal +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d961a48b7e2fd11928567081091441bb33770a0f2b9b3b1f4f853a95d5589cec + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-madmooose%2Fodooapps-lightgray.png?logo=github + :target: https://github.com/madmooose/odooapps/tree/16.0/account_payment_portal + :alt: madmooose/odooapps + +|badge1| |badge2| |badge3| + +Add a Portal View for Customer Payments + +**Table of contents** + +.. contents:: + :local: + +Changelog +========= + +- 16.0.1.0.0: Initial module +- 16.0.1.0.1: Fix security rules +- 16.0.1.0.2: Add tests +- 16.0.1.0.3: Add and use default image field + +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 +~~~~~~~ + +* BAKEUP +* Niels Göttsch + +Contributors +~~~~~~~~~~~~ + +* Niels Göttsch +* Matthias Brück + +Maintainers +~~~~~~~~~~~ + +This module is part of the `madmooose/odooapps `_ project on GitHub. + +You are welcome to contribute. diff --git a/account_payment_portal/__init__.py b/account_payment_portal/__init__.py new file mode 100644 index 0000000..91c5580 --- /dev/null +++ b/account_payment_portal/__init__.py @@ -0,0 +1,2 @@ +from . import controllers +from . import models diff --git a/account_payment_portal/__manifest__.py b/account_payment_portal/__manifest__.py new file mode 100644 index 0000000..4171f2d --- /dev/null +++ b/account_payment_portal/__manifest__.py @@ -0,0 +1,15 @@ +{ + "name": "Account Payment Portal", + "summary": "Add a Portal View for Customer Payments", + "author": "BAKEUP,Niels Göttsch", + "website": "https://ziemlichoptimal.de", + "category": "Accounting", + "version": "16.0.1.0.2", + "depends": ["account", "portal"], + "data": [ + "security/ir.model.access.csv", + "security/account_security.xml", + "views/portal_templates.xml", + ], + "license": "LGPL-3", +} diff --git a/account_payment_portal/controllers/__init__.py b/account_payment_portal/controllers/__init__.py new file mode 100644 index 0000000..8c3feb6 --- /dev/null +++ b/account_payment_portal/controllers/__init__.py @@ -0,0 +1 @@ +from . import portal diff --git a/account_payment_portal/controllers/portal.py b/account_payment_portal/controllers/portal.py new file mode 100644 index 0000000..551bcab --- /dev/null +++ b/account_payment_portal/controllers/portal.py @@ -0,0 +1,153 @@ +from collections import OrderedDict + +from odoo import _, http +from odoo.http import request +from odoo.osv import expression + +from odoo.addons.portal.controllers.portal import CustomerPortal +from odoo.addons.portal.controllers.portal import pager as portal_pager + + +class AccountPaymentPortal(CustomerPortal): + def _prepare_home_portal_values(self, counters): + values = super()._prepare_home_portal_values(counters) + if "payment_count" in counters: + payment_count = ( + request.env["account.payment"].search_count(self._get_payment_domain()) + if request.env["account.payment"].check_access_rights( + "read", raise_exception=False + ) + else 0 + ) + values["payment_count"] = payment_count + return values + + # ------------------------------------------------------------ + # My Payments + # ------------------------------------------------------------ + + def _payment_get_page_view_values(self, payment, access_token, **kwargs): + values = {"page_name": "payment", "payment": payment} + return self._get_page_view_values( + payment, access_token, values, "my_invoices_history", False, **kwargs + ) + + def _get_payment_domain(self): + return [("is_internal_transfer", "=", False)] + + def _get_account_searchbar_sortings(self): + return { + "date": {"label": _("Date"), "order": "date desc"}, + "name": {"label": _("Reference"), "order": "name desc"}, + "state": {"label": _("Status"), "order": "state"}, + } + + def _get_account_searchbar_filters(self): + # Add filter for payments and credit notes? + return { + "all": {"label": _("All"), "domain": []}, + "sent": { + "label": _("Sent"), + "domain": [("payment_type", "=", "inbound")], + }, + "received": { + "label": _("Received"), + "domain": [("payment_type", "=", "outbound")], + }, + } + + @http.route( + ["/my/payments", "/my/payments/page/"], + type="http", + auth="user", + website=True, + ) + def portal_my_payments( + self, page=1, date_begin=None, date_end=None, sortby=None, filterby=None, **kw + ): + values = self._prepare_my_payments_values( + page, date_begin, date_end, sortby, filterby + ) + + # pager + pager = portal_pager(**values["pager"]) + + # content according to pager and archive selected + payments = values["payments"](pager["offset"]) + request.session["my_payments_history"] = payments.ids[:100] + + values.update({"payments": payments, "pager": pager}) + + return request.render("account_payment_portal.portal_my_payments", values) + + def _prepare_my_payments_values( + self, + page, + date_begin, + date_end, + sortby, + filterby, + domain=None, + url="/my/payments", + ): + values = self._prepare_portal_layout_values() + AccountPayment = request.env["account.payment"] + + domain = expression.AND([domain or [], self._get_payment_domain()]) + + searchbar_sortings = self._get_account_searchbar_sortings() + # default sort by order + if not sortby: + sortby = "date" + order = searchbar_sortings[sortby]["order"] + + searchbar_filters = self._get_account_searchbar_filters() + # default filter by value + if not filterby: + filterby = "all" + domain += searchbar_filters[filterby]["domain"] + + if date_begin and date_end: + domain += [ + ("create_date", ">", date_begin), + ("create_date", "<=", date_end), + ] + + values.update( + { + "date": date_begin, + # content according to pager and archive selected lambda function to + # get the invoices recordset when the pager will be defined in the main + # method of a route + "payments": lambda pager_offset: ( + AccountPayment.search( + domain, + order=order, + limit=self._items_per_page, + offset=pager_offset, + ) + if AccountPayment.check_access_rights("read", raise_exception=False) + else AccountPayment + ), + "page_name": "payment", + "pager": { # vals to define the pager. + "url": url, + "url_args": { + "date_begin": date_begin, + "date_end": date_end, + "sortby": sortby, + }, + "total": AccountPayment.search_count(domain) + if AccountPayment.check_access_rights("read", raise_exception=False) + else 0, + "page": page, + "step": self._items_per_page, + }, + "default_url": url, + "searchbar_sortings": searchbar_sortings, + "sortby": sortby, + "searchbar_filters": OrderedDict(sorted(searchbar_filters.items())), + "filterby": filterby, + } + ) + return values diff --git a/account_payment_portal/i18n/de.po b/account_payment_portal/i18n/de.po new file mode 100644 index 0000000..04500ad --- /dev/null +++ b/account_payment_portal/i18n/de.po @@ -0,0 +1,125 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_portal +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-07-29 10:44+0000\n" +"PO-Revision-Date: 2025-07-29 10:44+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_portal +#: model_terms:ir.ui.view,arch_db:account_payment_portal.portal_my_payments +msgid "" +" Draft" +msgstr "" +" Entwurf" + +#. module: account_payment_portal +#: model_terms:ir.ui.view,arch_db:account_payment_portal.portal_my_payments +msgid "" +" Posted" +msgstr "" +" Registriert" + +#. module: account_payment_portal +#: model_terms:ir.ui.view,arch_db:account_payment_portal.portal_my_payments +msgid "" +" Cancelled" +msgstr "" +" Abgebrochen" + +#. module: account_payment_portal +#. odoo-python +#: code:addons/account_payment_portal/controllers/portal.py:0 +#, python-format +msgid "All" +msgstr "Alle" + +#. module: account_payment_portal +#: model_terms:ir.ui.view,arch_db:account_payment_portal.portal_my_payments +msgid "Amount" +msgstr "Betrag" + +#. module: account_payment_portal +#. odoo-python +#: code:addons/account_payment_portal/controllers/portal.py:0 +#, python-format +msgid "Date" +msgstr "Datum" + +#. module: account_payment_portal +#: model_terms:ir.ui.view,arch_db:account_payment_portal.portal_my_payments +msgid "Payment #" +msgstr "Zahlung #" + +#. module: account_payment_portal +#: model:ir.model.fields,field_description:account_payment_portal.field_account_payment__payment_count +msgid "Payment Count" +msgstr "" + +#. module: account_payment_portal +#: model_terms:ir.ui.view,arch_db:account_payment_portal.portal_my_payments +msgid "Payment Date" +msgstr "Zahldatum" + +#. module: account_payment_portal +#: model:ir.model,name:account_payment_portal.model_account_payment +#: model_terms:ir.ui.view,arch_db:account_payment_portal.portal_my_home_menu_payment +#: model_terms:ir.ui.view,arch_db:account_payment_portal.portal_my_home_payment +#: model_terms:ir.ui.view,arch_db:account_payment_portal.portal_my_payments +msgid "Payments" +msgstr "Zahlungen" + +#. module: account_payment_portal +#. odoo-python +#: code:addons/account_payment_portal/controllers/portal.py:0 +#, python-format +msgid "Received" +msgstr "Empfangen" + +#. module: account_payment_portal +#. odoo-python +#: code:addons/account_payment_portal/controllers/portal.py:0 +#, python-format +msgid "Reference" +msgstr "Referenz" + +#. module: account_payment_portal +#. odoo-python +#: code:addons/account_payment_portal/controllers/portal.py:0 +#, python-format +msgid "Sent" +msgstr "Gesendet" + +#. module: account_payment_portal +#. odoo-python +#: code:addons/account_payment_portal/controllers/portal.py:0 +#: model_terms:ir.ui.view,arch_db:account_payment_portal.portal_my_payments +#, python-format +msgid "Status" +msgstr "" + +#. module: account_payment_portal +#: model_terms:ir.ui.view,arch_db:account_payment_portal.portal_my_payments +msgid "There are currently no payments for your account." +msgstr "Es gibt keine Zahlungen für diesen Account." diff --git a/account_payment_portal/models/__init__.py b/account_payment_portal/models/__init__.py new file mode 100644 index 0000000..ab350b8 --- /dev/null +++ b/account_payment_portal/models/__init__.py @@ -0,0 +1 @@ +from . import account_payment diff --git a/account_payment_portal/models/account_payment.py b/account_payment_portal/models/account_payment.py new file mode 100644 index 0000000..08d40e6 --- /dev/null +++ b/account_payment_portal/models/account_payment.py @@ -0,0 +1,14 @@ +from odoo import api, fields, models + + +class AccountPayment(models.Model): + _inherit = "account.payment" + + payment_count = fields.Integer(compute="_compute_count_payment") + + @api.depends("partner_id") + def _compute_count_payment(self): + for payment in self: + payment.payment_count = self.env["account.payment"].search_count( + [("partner_id", "=", payment.partner_id.id)] + ) diff --git a/account_payment_portal/pyproject.toml b/account_payment_portal/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/account_payment_portal/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_payment_portal/readme/CONTRIBUTORS.rst b/account_payment_portal/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..a4ec453 --- /dev/null +++ b/account_payment_portal/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Niels Göttsch +* Matthias Brück \ No newline at end of file diff --git a/account_payment_portal/readme/DESCRIPTION.rst b/account_payment_portal/readme/DESCRIPTION.rst new file mode 100644 index 0000000..267f175 --- /dev/null +++ b/account_payment_portal/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Add a Portal View for Customer Payments \ No newline at end of file diff --git a/account_payment_portal/readme/HISTORY.rst b/account_payment_portal/readme/HISTORY.rst new file mode 100644 index 0000000..7eb0678 --- /dev/null +++ b/account_payment_portal/readme/HISTORY.rst @@ -0,0 +1,4 @@ +- 16.0.1.0.0: Initial module +- 16.0.1.0.1: Fix security rules +- 16.0.1.0.2: Add tests +- 16.0.1.0.3: Add and use default image field diff --git a/account_payment_portal/security/account_security.xml b/account_payment_portal/security/account_security.xml new file mode 100644 index 0000000..799eb6a --- /dev/null +++ b/account_payment_portal/security/account_security.xml @@ -0,0 +1,16 @@ + + + + + Portal Personal Account Payments + + [('partner_id','=', user.partner_id.id),('move_type','=','entry')] + + + + + + + diff --git a/account_payment_portal/security/ir.model.access.csv b/account_payment_portal/security/ir.model.access.csv new file mode 100644 index 0000000..17cc2c5 --- /dev/null +++ b/account_payment_portal/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_account_payment_portal,account.payment.portal,account.model_account_payment,base.group_portal,1,0,0,0 diff --git a/account_payment_portal/static/description/icon.png b/account_payment_portal/static/description/icon.png new file mode 100644 index 0000000..1267712 Binary files /dev/null and b/account_payment_portal/static/description/icon.png differ diff --git a/account_payment_portal/static/description/index.html b/account_payment_portal/static/description/index.html new file mode 100644 index 0000000..77a2340 --- /dev/null +++ b/account_payment_portal/static/description/index.html @@ -0,0 +1,434 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Account Payment Portal

+ +

Beta License: LGPL-3 madmooose/odooapps

+

Add a Portal View for Customer Payments

+

Table of contents

+ +
+

Changelog

+
    +
  • 16.0.1.0.0: Initial module
  • +
  • 16.0.1.0.1: Fix security rules
  • +
  • 16.0.1.0.2: Add tests
  • +
  • 16.0.1.0.3: Add and use default image field
  • +
+
+
+

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

+
    +
  • BAKEUP
  • +
  • Niels Göttsch
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the madmooose/odooapps project on GitHub.

+

You are welcome to contribute.

+
+
+
+
+ + diff --git a/account_payment_portal/tests/__init__.py b/account_payment_portal/tests/__init__.py new file mode 100644 index 0000000..0c265a1 --- /dev/null +++ b/account_payment_portal/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_payment diff --git a/account_payment_portal/tests/test_account_payment.py b/account_payment_portal/tests/test_account_payment.py new file mode 100644 index 0000000..bc702eb --- /dev/null +++ b/account_payment_portal/tests/test_account_payment.py @@ -0,0 +1,58 @@ +from odoo.tests import tagged +from odoo.tests.common import TransactionCase + + +@tagged("post_install", "-at_install") +class TestAccountPaymentPortal(TransactionCase): + def setUp(self): + super().setUp() + # Create two partners + portal_partner = self.env["res.partner"].create({"name": "Portal User"}) + other_partner = self.env["res.partner"].create({"name": "Other User"}) + + # Create two users, one portal + portal_group = self.env.ref("base.group_portal") + portal_user = self.env["res.users"].create( + { + "name": "Portal User", + "login": "portaluser@example.com", + "partner_id": portal_partner.id, + "groups_id": [(6, 0, [portal_group.id])], + } + ) + other_user = self.env["res.users"].create( + { + "name": "Other User", + "login": "otheruser@example.com", + "partner_id": other_partner.id, + } + ) + + # Create two payments + portal_partner_payment = self.env["account.payment"].create( + { + "partner_id": portal_partner.id, + "amount": 100, + "payment_type": "inbound", + "state": "draft", + } + ) + other_partner_payment = self.env["account.payment"].create( + { + "partner_id": other_partner.id, + "amount": 200, + "payment_type": "inbound", + "state": "draft", + } + ) + + self.portal_user = portal_user + self.other_user = other_user + self.portal_partner_payment = portal_partner_payment + self.other_partner_payment = other_partner_payment + + def test_portal_user_sees_only_own_payment(self): + # Switch to portal user context + payments = self.env["account.payment"].with_user(self.portal_user.id).search([]) + self.assertIn(self.portal_partner_payment, payments) + self.assertNotIn(self.other_partner_payment, payments) diff --git a/account_payment_portal/views/portal_templates.xml b/account_payment_portal/views/portal_templates.xml new file mode 100644 index 0000000..ad4f5df --- /dev/null +++ b/account_payment_portal/views/portal_templates.xml @@ -0,0 +1,104 @@ + + + + + + +