Skip to content

Commit

Permalink
Merge pull request #177 from beescoop/12.0-posorder_amount_by_year
Browse files Browse the repository at this point in the history
[12.0][ADD] beesdoo_posorder_amount: by year
  • Loading branch information
vvrossem authored Oct 26, 2020
2 parents a8714f8 + df29f3f commit d6cb5bc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions beesdoo_website_posorder_amount/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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": 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"] = (
request.env["res.company"]._company_default_get().currency_id
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@
t-esc-options='{"widget": "monetary", "display_currency": "company_currency"}'/>
.
</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>
</xpath>
</template>
Expand Down

0 comments on commit d6cb5bc

Please sign in to comment.