Skip to content

Commit

Permalink
[ADD] new module account_receipt_portal
Browse files Browse the repository at this point in the history
  • Loading branch information
primes2h committed Mar 15, 2024
1 parent 74f9074 commit 4e134dd
Show file tree
Hide file tree
Showing 18 changed files with 857 additions and 0 deletions.
87 changes: 87 additions & 0 deletions account_receipt_portal/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/account-invoicing/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 <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_receipt_portal%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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 <https://www.pnlug.it>`__:

* Sergio Zanchetta <https://github.com/primes2h>

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 <https://github.com/OCA/account-invoicing/tree/14.0/account_receipt_portal>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions account_receipt_portal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models, controllers
18 changes: 18 additions & 0 deletions account_receipt_portal/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
3 changes: 3 additions & 0 deletions account_receipt_portal/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import portal
66 changes: 66 additions & 0 deletions account_receipt_portal/controllers/portal.py
Original file line number Diff line number Diff line change
@@ -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)
70 changes: 70 additions & 0 deletions account_receipt_portal/i18n/account_receipt_portal.pot
Original file line number Diff line number Diff line change
@@ -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 &amp; 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 ""
70 changes: 70 additions & 0 deletions account_receipt_portal/i18n/it.po
Original file line number Diff line number Diff line change
@@ -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 &amp; 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."
3 changes: 3 additions & 0 deletions account_receipt_portal/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import account_move
13 changes: 13 additions & 0 deletions account_receipt_portal/models/account_move.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions account_receipt_portal/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions account_receipt_portal/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Pordenone Linux User Group APS <https://www.pnlug.it>`__:

* Sergio Zanchetta <https://github.com/primes2h>
1 change: 1 addition & 0 deletions account_receipt_portal/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module adds sale and purchase receipts in the customer portal.
24 changes: 24 additions & 0 deletions account_receipt_portal/security/account_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value
eval="[('module', '=', 'account'), ('name', '=', 'account_invoice_rule_portal')]"
/>
</function>
<value eval="{'noupdate': False}" />
</function>
<record id="account.account_invoice_rule_portal" model="ir.rule">
<field
name="domain_force"
>[('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])]</field>
</record>
<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value
eval="[('module', '=', 'account'), ('name', '=', 'account_invoice_rule_portal')]"
/>
</function>
<value eval="{'noupdate': True}" />
</function>
</odoo>
Loading

0 comments on commit 4e134dd

Please sign in to comment.