From 6e3818d8273c8ddf9ad4e1d37e96c3b756c3d691 Mon Sep 17 00:00:00 2001 From: Sergio Zanchetta Date: Tue, 12 Mar 2024 11:40:35 +0100 Subject: [PATCH] [ADD] new module account_receipt_portal --- account_receipt_portal/README.rst | 87 ++++ account_receipt_portal/__init__.py | 3 + account_receipt_portal/__manifest__.py | 18 + .../controllers/__init__.py | 3 + account_receipt_portal/controllers/portal.py | 66 +++ .../i18n/account_receipt_portal.pot | 70 +++ account_receipt_portal/i18n/it.po | 70 +++ account_receipt_portal/models/__init__.py | 3 + account_receipt_portal/models/account_move.py | 13 + account_receipt_portal/readme/CONFIGURE.rst | 5 + .../readme/CONTRIBUTORS.rst | 3 + account_receipt_portal/readme/DESCRIPTION.rst | 1 + .../security/account_security.xml | 24 + .../static/description/index.html | 434 ++++++++++++++++++ .../views/account_portal_templates.xml | 48 ++ .../odoo/addons/account_receipt_portal | 1 + setup/account_receipt_portal/setup.py | 6 + test-requirements.txt | 2 + 18 files changed, 857 insertions(+) create mode 100644 account_receipt_portal/README.rst create mode 100644 account_receipt_portal/__init__.py create mode 100644 account_receipt_portal/__manifest__.py create mode 100644 account_receipt_portal/controllers/__init__.py create mode 100644 account_receipt_portal/controllers/portal.py create mode 100644 account_receipt_portal/i18n/account_receipt_portal.pot create mode 100644 account_receipt_portal/i18n/it.po create mode 100644 account_receipt_portal/models/__init__.py create mode 100644 account_receipt_portal/models/account_move.py create mode 100644 account_receipt_portal/readme/CONFIGURE.rst create mode 100644 account_receipt_portal/readme/CONTRIBUTORS.rst create mode 100644 account_receipt_portal/readme/DESCRIPTION.rst create mode 100644 account_receipt_portal/security/account_security.xml create mode 100644 account_receipt_portal/static/description/index.html create mode 100644 account_receipt_portal/views/account_portal_templates.xml create mode 120000 setup/account_receipt_portal/odoo/addons/account_receipt_portal create mode 100644 setup/account_receipt_portal/setup.py create mode 100644 test-requirements.txt diff --git a/account_receipt_portal/README.rst b/account_receipt_portal/README.rst new file mode 100644 index 000000000000..0f1fa65fee4f --- /dev/null +++ b/account_receipt_portal/README.rst @@ -0,0 +1,87 @@ +=========================== +Website Portal for Receipts +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9e02a24ad529193ce3b5e9a529c12284239e1232194e3b59873d48b5c95a53ca + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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--invoicing-lightgray.png?logo=github + :target: https://github.com/OCA/account-invoicing/tree/14.0/account_receipt_portal + :alt: OCA/account-invoicing +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-invoicing-14-0/account-invoicing-14-0-account_receipt_portal + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds sale and purchase receipts in the customer portal. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +In order to use sale and purchase receipts, you need to enable them in the user settings. + +* Activate **Developer mode** +* Go to *Settings → Users & Companies → Users* +* In the user form, select 'Sale Receipt' and 'Purchase Receipt' checkboxes within the *Technical* section of *Access Rights* tab + +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 +~~~~~~~ + +* Pordenone Linux User Group (PNLUG) + +Contributors +~~~~~~~~~~~~ + +* `Pordenone Linux User Group APS `__: + + * Sergio Zanchetta + +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-invoicing `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_receipt_portal/__init__.py b/account_receipt_portal/__init__.py new file mode 100644 index 000000000000..4019be4a2ef9 --- /dev/null +++ b/account_receipt_portal/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models, controllers diff --git a/account_receipt_portal/__manifest__.py b/account_receipt_portal/__manifest__.py new file mode 100644 index 000000000000..8d2f0a93a969 --- /dev/null +++ b/account_receipt_portal/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Website Portal for Receipts", + "version": "14.0.1.0.0", + "category": "Accounting & Finance", + "summary": "Add sale and purchase receipts in the customer portal", + "author": "Pordenone Linux User Group (PNLUG), Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-invoicing", + "license": "AGPL-3", + "depends": ["account", "portal", "account_receipt_base", "account_receipt_print"], + "data": [ + "views/account_portal_templates.xml", + "security/account_security.xml", + ], + "installable": True, +} diff --git a/account_receipt_portal/controllers/__init__.py b/account_receipt_portal/controllers/__init__.py new file mode 100644 index 000000000000..e7fcc3e1db52 --- /dev/null +++ b/account_receipt_portal/controllers/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import portal diff --git a/account_receipt_portal/controllers/portal.py b/account_receipt_portal/controllers/portal.py new file mode 100644 index 000000000000..409333ac6ee3 --- /dev/null +++ b/account_receipt_portal/controllers/portal.py @@ -0,0 +1,66 @@ +# Copyright 2024 Sergio Zanchetta - PNLUG APS +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from collections import OrderedDict + +from odoo import _, http +from odoo.http import request + +from odoo.addons.account.controllers.portal import PortalAccount + + +class PortalAccount(PortalAccount): + @http.route() + def portal_my_invoices( + self, page=1, date_begin=None, date_end=None, sortby=None, filterby=None, **kw + ): + res = super(PortalAccount, self).portal_my_invoices(filterby=None) + values = res.qcontext + + AccountInvoice = request.env["account.move"] + + domain = self._get_invoices_domain() + + searchbar_sortings = values.get("searchbar_sortings", {}) + + # default sort by order + if not sortby: + sortby = "date" + order = searchbar_sortings[sortby]["order"] + + searchbar_filters = values.get("searchbar_filters", {}) + searchbar_filters.update( + { + "sale_receipts": { + "label": _("Sale Receipts"), + "domain": [("move_type", "=", "out_receipt")], + }, + "purchase_receipts": { + "label": _("Purchase Receipts"), + "domain": [("move_type", "=", "in_receipt")], + }, + } + ) + + # default filter by value + if not filterby: + filterby = "all" + domain += searchbar_filters[filterby]["domain"] + + pager = values.get("pager") + + # content according to pager and archive selected + invoices = AccountInvoice.search( + domain, order=order, limit=self._items_per_page, offset=pager["offset"] + ) + request.session["my_invoices_history"] = invoices.ids[:100] + + values.update( + { + "invoices": invoices, + "sortby": sortby, + "searchbar_filters": OrderedDict(sorted(searchbar_filters.items())), + "filterby": filterby, + } + ) + return request.render("account.portal_my_invoices", values) diff --git a/account_receipt_portal/i18n/account_receipt_portal.pot b/account_receipt_portal/i18n/account_receipt_portal.pot new file mode 100644 index 000000000000..3e32bbe8e341 --- /dev/null +++ b/account_receipt_portal/i18n/account_receipt_portal.pot @@ -0,0 +1,70 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_receipt_portal +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-03-15 21:05+0000\n" +"PO-Revision-Date: 2024-03-15 21:05+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_receipt_portal +#: model:ir.model.fields,field_description:account_receipt_portal.field_account_move__display_name +msgid "Display Name" +msgstr "" + +#. module: account_receipt_portal +#: model:ir.model.fields,field_description:account_receipt_portal.field_account_move__id +msgid "ID" +msgstr "" + +#. module: account_receipt_portal +#: model_terms:ir.ui.view,arch_db:account_receipt_portal.portal_my_invoices +msgid "Invoice/Receipt #" +msgstr "" + +#. module: account_receipt_portal +#: model_terms:ir.ui.view,arch_db:account_receipt_portal.portal_my_invoices +msgid "Invoice/Receipt Date" +msgstr "" + +#. module: account_receipt_portal +#: model_terms:ir.ui.view,arch_db:account_receipt_portal.portal_my_home_invoice +#: model_terms:ir.ui.view,arch_db:account_receipt_portal.portal_my_home_menu_invoice +msgid "Invoices, Bills & Receipts" +msgstr "" + +#. module: account_receipt_portal +#: model:ir.model,name:account_receipt_portal.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: account_receipt_portal +#: model:ir.model.fields,field_description:account_receipt_portal.field_account_move____last_update +msgid "Last Modified on" +msgstr "" + +#. module: account_receipt_portal +#: code:addons/account_receipt_portal/controllers/portal.py:0 +#, python-format +msgid "Purchase Receipts" +msgstr "" + +#. module: account_receipt_portal +#: code:addons/account_receipt_portal/controllers/portal.py:0 +#, python-format +msgid "Sale Receipts" +msgstr "" + +#. module: account_receipt_portal +#: model_terms:ir.ui.view,arch_db:account_receipt_portal.portal_my_invoices +msgid "" +"There are currently no invoices/receipts and payments for your account." +msgstr "" diff --git a/account_receipt_portal/i18n/it.po b/account_receipt_portal/i18n/it.po new file mode 100644 index 000000000000..201b5b45f7b0 --- /dev/null +++ b/account_receipt_portal/i18n/it.po @@ -0,0 +1,70 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_receipt_portal +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-03-15 21:06+0000\n" +"PO-Revision-Date: 2024-03-15 21:06+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_receipt_portal +#: model:ir.model.fields,field_description:account_receipt_portal.field_account_move__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: account_receipt_portal +#: model:ir.model.fields,field_description:account_receipt_portal.field_account_move__id +msgid "ID" +msgstr "ID" + +#. module: account_receipt_portal +#: model_terms:ir.ui.view,arch_db:account_receipt_portal.portal_my_invoices +msgid "Invoice/Receipt #" +msgstr "Fattura/Ricevuta n°" + +#. module: account_receipt_portal +#: model_terms:ir.ui.view,arch_db:account_receipt_portal.portal_my_invoices +msgid "Invoice/Receipt Date" +msgstr "Data fattura/ricevuta" + +#. module: account_receipt_portal +#: model_terms:ir.ui.view,arch_db:account_receipt_portal.portal_my_home_invoice +#: model_terms:ir.ui.view,arch_db:account_receipt_portal.portal_my_home_menu_invoice +msgid "Invoices, Bills & Receipts" +msgstr "Fatture e ricevute" + +#. module: account_receipt_portal +#: model:ir.model,name:account_receipt_portal.model_account_move +msgid "Journal Entry" +msgstr "Registrazione contabile" + +#. module: account_receipt_portal +#: model:ir.model.fields,field_description:account_receipt_portal.field_account_move____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: account_receipt_portal +#: code:addons/account_receipt_portal/controllers/portal.py:0 +#, python-format +msgid "Purchase Receipts" +msgstr "Ricevute di acquisto" + +#. module: account_receipt_portal +#: code:addons/account_receipt_portal/controllers/portal.py:0 +#, python-format +msgid "Sale Receipts" +msgstr "Ricevute di vendita" + +#. module: account_receipt_portal +#: model_terms:ir.ui.view,arch_db:account_receipt_portal.portal_my_invoices +msgid "" +"There are currently no invoices/receipts and payments for your account." +msgstr "Al momento nell'account non sono presenti fatture/ricevute e pagamenti." diff --git a/account_receipt_portal/models/__init__.py b/account_receipt_portal/models/__init__.py new file mode 100644 index 000000000000..4951448be4b1 --- /dev/null +++ b/account_receipt_portal/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import account_move diff --git a/account_receipt_portal/models/account_move.py b/account_receipt_portal/models/account_move.py new file mode 100644 index 000000000000..dc27ad0fd68a --- /dev/null +++ b/account_receipt_portal/models/account_move.py @@ -0,0 +1,13 @@ +# Copyright 2024 Sergio Zanchetta - PNLUG APS +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class AccountMove(models.Model): + _inherit = "account.move" + + def _compute_access_url(self): + super(AccountMove, self)._compute_access_url() + for move in self.filtered(lambda move: move.is_receipt()): + move.access_url = "/my/invoices/%s" % (move.id) diff --git a/account_receipt_portal/readme/CONFIGURE.rst b/account_receipt_portal/readme/CONFIGURE.rst new file mode 100644 index 000000000000..7059059efe00 --- /dev/null +++ b/account_receipt_portal/readme/CONFIGURE.rst @@ -0,0 +1,5 @@ +In order to use sale and purchase receipts, you need to enable them in the user settings. + +* Activate **Developer mode** +* Go to *Settings → Users & Companies → Users* +* In the user form, select 'Sale Receipt' and 'Purchase Receipt' checkboxes within the *Technical* section of *Access Rights* tab diff --git a/account_receipt_portal/readme/CONTRIBUTORS.rst b/account_receipt_portal/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..c88352050585 --- /dev/null +++ b/account_receipt_portal/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Pordenone Linux User Group APS `__: + + * Sergio Zanchetta diff --git a/account_receipt_portal/readme/DESCRIPTION.rst b/account_receipt_portal/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..776852b7f71b --- /dev/null +++ b/account_receipt_portal/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds sale and purchase receipts in the customer portal. diff --git a/account_receipt_portal/security/account_security.xml b/account_receipt_portal/security/account_security.xml new file mode 100644 index 000000000000..94909072f721 --- /dev/null +++ b/account_receipt_portal/security/account_security.xml @@ -0,0 +1,24 @@ + + + + + + + + + + [('state', 'not in', ('cancel', 'draft')), ('move_type', 'in', ('out_invoice', 'out_refund', 'out_receipt', 'in_invoice', 'in_refund', 'in_receipt')), ('message_partner_ids','child_of',[user.commercial_partner_id.id])] + + + + + + + + diff --git a/account_receipt_portal/static/description/index.html b/account_receipt_portal/static/description/index.html new file mode 100644 index 000000000000..f7f88fb6b14a --- /dev/null +++ b/account_receipt_portal/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +Website Portal for Receipts + + + +
+

Website Portal for Receipts

+ + +

Beta License: AGPL-3 OCA/account-invoicing Translate me on Weblate Try me on Runboat

+

This module adds sale and purchase receipts in the customer portal.

+

Table of contents

+ +
+

Configuration

+

In order to use sale and purchase receipts, you need to enable them in the user settings.

+
    +
  • Activate Developer mode
  • +
  • Go to Settings → Users & Companies → Users
  • +
  • In the user form, select ‘Sale Receipt’ and ‘Purchase Receipt’ checkboxes within the Technical section of Access Rights tab
  • +
+
+
+

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

+
    +
  • Pordenone Linux User Group (PNLUG)
  • +
+
+ +
+

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

+

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

+
+
+
+ + diff --git a/account_receipt_portal/views/account_portal_templates.xml b/account_receipt_portal/views/account_portal_templates.xml new file mode 100644 index 000000000000..d26daaeaab77 --- /dev/null +++ b/account_receipt_portal/views/account_portal_templates.xml @@ -0,0 +1,48 @@ + + + + + + diff --git a/setup/account_receipt_portal/odoo/addons/account_receipt_portal b/setup/account_receipt_portal/odoo/addons/account_receipt_portal new file mode 120000 index 000000000000..82d786d36dc8 --- /dev/null +++ b/setup/account_receipt_portal/odoo/addons/account_receipt_portal @@ -0,0 +1 @@ +../../../../account_receipt_portal \ No newline at end of file diff --git a/setup/account_receipt_portal/setup.py b/setup/account_receipt_portal/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/account_receipt_portal/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000000..3189aa235ec4 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +# https://github.com/OCA/account-invoicing/pull/1684 +odoo14-addon-account_receipt_print @ git+https://github.com/OCA/account-invoicing.git@refs/pull/1684/head#subdirectory=setup/account_receipt_print