Browse Source

[ADD] beesdoo_posorder_amount: by year

pull/177/head
Manuel Claeys Bouuaert 4 years ago
parent
commit
1eae153081
  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": 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"] = ( 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 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