From 1eae15308161e61243173191115ec32ca9d03558 Mon Sep 17 00:00:00 2001
From: Manuel Claeys Bouuaert
Date: Tue, 8 Sep 2020 10:32:44 +0200
Subject: [PATCH 1/2] [ADD] beesdoo_posorder_amount: by year
---
.../controllers/main.py | 11 +++++++++++
.../templates/portal_posorder_amount.xml | 18 ++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/beesdoo_website_posorder_amount/controllers/main.py b/beesdoo_website_posorder_amount/controllers/main.py
index 9e2654d5b..f4f943907 100644
--- a/beesdoo_website_posorder_amount/controllers/main.py
+++ b/beesdoo_website_posorder_amount/controllers/main.py
@@ -2,6 +2,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+from itertools import groupby
+
from odoo.http import request
from odoo.addons.portal.controllers.portal import CustomerPortal
@@ -30,6 +32,15 @@ def _prepare_portal_layout_values(self):
values["posorder_amount"] = sum(
po.amount_total for po in owned_posorder
)
+ values["posorder_amount_by_year"] = [
+ {
+ "year": key,
+ "amount": sum(element.amount_total for element in group),
+ }
+ for key, group in groupby(
+ owned_posorder, key=lambda element: element.date_order.year
+ )
+ ]
values["company_currency"] = (
request.env["res.company"]._company_default_get().currency_id
)
diff --git a/beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml b/beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml
index 89f8fb701..702ff0066 100644
--- a/beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml
+++ b/beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml
@@ -21,6 +21,24 @@
t-esc-options='{"widget": "monetary", "display_currency": "company_currency"}'/>
.
+
+
+
+ Year
+ |
+
+ Amount
+ |
+
+
+
+
+ |
+
+
+ |
+
+
From df29f3ff7cad18dd2300aa565e20a121dd1d091a Mon Sep 17 00:00:00 2001
From: Manuel Claeys Bouuaert
Date: Thu, 17 Sep 2020 16:28:32 +0200
Subject: [PATCH 2/2] fixup! [ADD] beesdoo_posorder_amount: by year
---
beesdoo_website_posorder_amount/controllers/main.py | 8 ++++----
.../templates/portal_posorder_amount.xml | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/beesdoo_website_posorder_amount/controllers/main.py b/beesdoo_website_posorder_amount/controllers/main.py
index f4f943907..607c05f9d 100644
--- a/beesdoo_website_posorder_amount/controllers/main.py
+++ b/beesdoo_website_posorder_amount/controllers/main.py
@@ -34,11 +34,11 @@ def _prepare_portal_layout_values(self):
)
values["posorder_amount_by_year"] = [
{
- "year": key,
- "amount": sum(element.amount_total for element in group),
+ "year": year,
+ "amount": sum(pos_order.amount_total for pos_order in grouped_pos_orders),
}
- for key, group in groupby(
- owned_posorder, key=lambda element: element.date_order.year
+ for year, grouped_pos_orders in groupby(
+ owned_posorder, key=lambda pos_order: pos_order.date_order.year
)
]
values["company_currency"] = (
diff --git a/beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml b/beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml
index 702ff0066..b3c63d657 100644
--- a/beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml
+++ b/beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml
@@ -21,7 +21,7 @@
t-esc-options='{"widget": "monetary", "display_currency": "company_currency"}'/>
.
-