diff --git a/portal_multicurrency_totals/README.rst b/portal_multicurrency_totals/README.rst new file mode 100644 index 00000000000..f55f1a2e62f --- /dev/null +++ b/portal_multicurrency_totals/README.rst @@ -0,0 +1,56 @@ +Multi-Currency Totals in Portal +=============================== + +This module adds te feature to display total amounts by currency when accessing +documents through the portal: + +- Quotations +- Sale orders +- Invoices + +Usage +===== + +To use this module, just go to the portal and open a document list; you will see an extra footer with totals by currency. + +When accessing quotations or sale orders, a total will be displayed per +currency: + + .. image:: portal_multicurrency_totals/static/description/totals_in_so.png + :width: 400pt + :alt: Totals in sale orders + +When accessing invoices, paid and unpaid amounts will also be available: + + .. image:: portal_multicurrency_totals/static/description/totals_in_invoices.png + :width: 400pt + :alt: Totals in invoices + +**Note**: +Even though records in state draft or cancelled may be displayed if they were +validated in some point, they're not considered when computing totals. + +Credits +======= + +Contributors +------------ + +* Luis González + + +Maintainer +========== + +.. image:: https://www.vauxoo.com/logo.png + :alt: Vauxoo + :target: https://vauxoo.com + +This module is maintained by Vauxoo. + +a latinamerican company that provides training, coaching, +development and implementation of enterprise management +systems and bases its entire operation strategy in the use +of Open Source Software and its main product is Odoo. + +To contribute to this module, please visit https://www.vauxoo.com. diff --git a/portal_multicurrency_totals/__init__.py b/portal_multicurrency_totals/__init__.py new file mode 100644 index 00000000000..e046e49fbe2 --- /dev/null +++ b/portal_multicurrency_totals/__init__.py @@ -0,0 +1 @@ +from . import controllers diff --git a/portal_multicurrency_totals/__manifest__.py b/portal_multicurrency_totals/__manifest__.py new file mode 100644 index 00000000000..c501a054d77 --- /dev/null +++ b/portal_multicurrency_totals/__manifest__.py @@ -0,0 +1,21 @@ +{ + "name": "Multi-Currency Totals in Portal", + "author": "Vauxoo", + "website": "https://www.vauxoo.com", + "license": "LGPL-3", + "category": "Sales/Sales", + "version": "14.0.1.0.0", + "depends": [ + "sale", + ], + "data": [ + "views/portal_templates.xml", + ], + "demo": [ + "demo/product_pricelist_demo.xml", + "demo/res_partner_demo.xml", + "demo/sale_order_demo.xml", + ], + "installable": True, + "auto_install": False, +} diff --git a/portal_multicurrency_totals/controllers/__init__.py b/portal_multicurrency_totals/controllers/__init__.py new file mode 100644 index 00000000000..12a7e529b67 --- /dev/null +++ b/portal_multicurrency_totals/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/portal_multicurrency_totals/controllers/main.py b/portal_multicurrency_totals/controllers/main.py new file mode 100644 index 00000000000..cad46444e45 --- /dev/null +++ b/portal_multicurrency_totals/controllers/main.py @@ -0,0 +1,53 @@ +from odoo import http + +from odoo.addons.account.controllers.portal import PortalAccount as PA +from odoo.addons.sale.controllers.portal import CustomerPortal as CP + + +class CustomerPortal(CP): + def _totals_by_currency(self, records): + """Compute total amounts for invoices and sale orders, grouped by currency""" + if not records: + return {} + currencies = records.currency_id + totals_by_currency = { + currency: { + "amount": 0.0, + } + for currency in currencies + } + for record in records.filtered(lambda inv: inv.state not in ("draft", "cancel")): + totals_this_currency = totals_by_currency[record.currency_id] + totals_this_currency["amount"] += record.amount_total + if "amount_residual" in record: + totals_this_currency.setdefault("unpaid", 0.0) + totals_this_currency.setdefault("paid", 0.0) + totals_this_currency["unpaid"] += record.amount_residual + totals_this_currency["paid"] += record.amount_total - record.amount_residual + + return totals_by_currency + + @http.route(["/my/quotes", "/my/quotes/page/"], type="http", auth="user", website=True) + def portal_my_quotes(self, page=1, date_begin=None, date_end=None, sortby=None, **kw): + response = super().portal_my_quotes(page=page, date_begin=date_begin, date_end=date_end, sortby=sortby, **kw) + quotations = response.qcontext.get("quotations") + response.qcontext["totals_by_currency"] = self._totals_by_currency(quotations) + return response + + @http.route(["/my/orders", "/my/orders/page/"], type="http", auth="user", website=True) + def portal_my_orders(self, page=1, date_begin=None, date_end=None, sortby=None, **kw): + response = super().portal_my_orders(page=page, date_begin=date_begin, date_end=date_end, sortby=sortby, **kw) + orders = response.qcontext.get("orders") + response.qcontext["totals_by_currency"] = self._totals_by_currency(orders) + return response + + +class PortalAccount(PA): + @http.route(["/my/invoices", "/my/invoices/page/"], type="http", auth="user", website=True) + def portal_my_invoices(self, page=1, date_begin=None, date_end=None, sortby=None, filterby=None, **kw): + response = super().portal_my_invoices( + page=page, date_begin=date_begin, date_end=date_end, sortby=sortby, filterby=filterby, **kw + ) + invoices = response.qcontext.get("invoices") + response.qcontext["totals_by_currency"] = self._totals_by_currency(invoices) + return response diff --git a/portal_multicurrency_totals/demo/product_pricelist_demo.xml b/portal_multicurrency_totals/demo/product_pricelist_demo.xml new file mode 100644 index 00000000000..9cd405243e2 --- /dev/null +++ b/portal_multicurrency_totals/demo/product_pricelist_demo.xml @@ -0,0 +1,10 @@ + + + + + Pricelist in USD + + + + + diff --git a/portal_multicurrency_totals/demo/res_partner_demo.xml b/portal_multicurrency_totals/demo/res_partner_demo.xml new file mode 100644 index 00000000000..a6adb97ae01 --- /dev/null +++ b/portal_multicurrency_totals/demo/res_partner_demo.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + diff --git a/portal_multicurrency_totals/demo/sale_order_demo.xml b/portal_multicurrency_totals/demo/sale_order_demo.xml new file mode 100644 index 00000000000..59ff814d1a6 --- /dev/null +++ b/portal_multicurrency_totals/demo/sale_order_demo.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/portal_multicurrency_totals/i18n/es.po b/portal_multicurrency_totals/i18n/es.po new file mode 100644 index 00000000000..143dd9c9d52 --- /dev/null +++ b/portal_multicurrency_totals/i18n/es.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * portal_multicurrency_totals +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-12-28 22:52+0000\n" +"PO-Revision-Date: 2021-12-28 22:52+0000\n" +"Last-Translator: Luis González \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: portal_multicurrency_totals +#: model_terms:ir.ui.view,arch_db:portal_multicurrency_totals.totals_footer +msgid "Currency" +msgstr "Moneda" + +#. module: portal_multicurrency_totals +#: model_terms:ir.ui.view,arch_db:portal_multicurrency_totals.totals_footer +msgid "Paid" +msgstr "Pagado" + +#. module: portal_multicurrency_totals +#: model:product.pricelist,name:portal_multicurrency_totals.pricelist_usd +msgid "Pricelist in USD" +msgstr "Tarifa en USD" + +#. module: portal_multicurrency_totals +#: model_terms:ir.ui.view,arch_db:portal_multicurrency_totals.totals_footer +msgid "Total" +msgstr "" + +#. module: portal_multicurrency_totals +#: model_terms:ir.ui.view,arch_db:portal_multicurrency_totals.totals_footer +msgid "Totals by Currency" +msgstr "Totales por Moneda" + +#. module: portal_multicurrency_totals +#: model_terms:ir.ui.view,arch_db:portal_multicurrency_totals.totals_footer +msgid "Unpaid" +msgstr "Sin Pagar" diff --git a/portal_multicurrency_totals/static/description/totals_in_invoices.png b/portal_multicurrency_totals/static/description/totals_in_invoices.png new file mode 100644 index 00000000000..ec11dc6ce75 Binary files /dev/null and b/portal_multicurrency_totals/static/description/totals_in_invoices.png differ diff --git a/portal_multicurrency_totals/static/description/totals_in_so.png b/portal_multicurrency_totals/static/description/totals_in_so.png new file mode 100644 index 00000000000..d615638ce12 Binary files /dev/null and b/portal_multicurrency_totals/static/description/totals_in_so.png differ diff --git a/portal_multicurrency_totals/views/portal_templates.xml b/portal_multicurrency_totals/views/portal_templates.xml new file mode 100644 index 00000000000..5ff1954d20a --- /dev/null +++ b/portal_multicurrency_totals/views/portal_templates.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + +