Compare commits

...

2 Commits

Author SHA1 Message Date
Manuel Claeys Bouuaert df29f3ff7c fixup! [ADD] beesdoo_posorder_amount: by year 4 years ago
Manuel Claeys Bouuaert 1eae153081 [ADD] beesdoo_posorder_amount: by year 4 years ago
  1. 11
      beesdoo_website_posorder_amount/controllers/main.py
  2. 18
      beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml

11
beesdoo_website_posorder_amount/controllers/main.py

@ -2,6 +2,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from itertools import groupby
from odoo.http import request from odoo.http import request
from odoo.addons.portal.controllers.portal import CustomerPortal from odoo.addons.portal.controllers.portal import CustomerPortal
@ -30,6 +32,15 @@ class PortalPosOrderAmount(CustomerPortal):
values["posorder_amount"] = sum( values["posorder_amount"] = sum(
po.amount_total for po in owned_posorder po.amount_total for po in owned_posorder
) )
values["posorder_amount_by_year"] = [
{
"year": year,
"amount": sum(pos_order.amount_total for pos_order in grouped_pos_orders),
}
for year, grouped_pos_orders in groupby(
owned_posorder, key=lambda pos_order: pos_order.date_order.year
)
]
values["company_currency"] = ( values["company_currency"] = (
request.env["res.company"]._company_default_get().currency_id request.env["res.company"]._company_default_get().currency_id
) )

18
beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml

@ -21,6 +21,24 @@
t-esc-options='{"widget": "monetary", "display_currency": "company_currency"}'/> t-esc-options='{"widget": "monetary", "display_currency": "company_currency"}'/>
. .
</p> </p>
<table name="posorder_amount_by_year" class="table table-striped">
<tr>
<th>
Year
</th>
<th>
Amount
</th>
</tr>
<tr t-foreach="posorder_amount_by_year" t-as="row">
<td>
<t t-esc="row['year']"/>
</td>
<td>
<t t-esc="row['amount']" t-esc-options='{"widget": "monetary", "display_currency": "company_currency"}'/>
</td>
</tr>
</table>
</div> </div>
</xpath> </xpath>
</template> </template>

Loading…
Cancel
Save