Browse Source

[ADD] b_w_portal: Total pos order amount for a user

pull/131/head
Rémy Taymans 5 years ago
committed by Cyrille Bollu
parent
commit
308397571d
  1. 2
      beesdoo_website_posorder_amount/__init__.py
  2. 19
      beesdoo_website_posorder_amount/__openerp__.py
  3. 2
      beesdoo_website_posorder_amount/controllers/__init__.py
  4. 30
      beesdoo_website_posorder_amount/controllers/main.py
  5. 26
      beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml

2
beesdoo_website_posorder_amount/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf8 -*-
import controllers

19
beesdoo_website_posorder_amount/__openerp__.py

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Coop IT Easy SCRLfs
# Rémy Taymans <remy@coopiteasy.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Portal Website POS order amount",
"summary": """
Show the total amount of pos order in the website portal.
""",
"description": """
""",
"author": "Coop IT Easy SCRLfs",
"license": "AGPL-3",
"version": "9.0.1.0",
"website": "https://github.com/beescoop/Obeesdoo",
"category": "Website",
"depends": ["website_portal_v10"],
"data": ["templates/portal_posorder_amount.xml"],
}

2
beesdoo_website_posorder_amount/controllers/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import main

30
beesdoo_website_posorder_amount/controllers/main.py

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Rémy Taymans <remytaymans@gmail.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.addons.website_portal_v10.controllers.main import WebsiteAccount
from openerp.http import request
class PortalPosOrderAmount(WebsiteAccount):
def _prepare_portal_layout_values(self):
values = super(
PortalPosOrderAmount, self
)._prepare_portal_layout_values()
user = request.env.user
owned_posorder = request.env["pos.order"].sudo().search(
[
("partner_id", "=", user.partner_id.commercial_partner_id.id),
("state", "!=", "cancel"),
]
)
values["posorder_amount"] = sum(
po.amount_total for po in owned_posorder
)
values["company_currency"] = (
request.env["res.company"]._company_default_get().currency_id
)
return values

26
beesdoo_website_posorder_amount/templates/portal_posorder_amount.xml

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Rémy Taymans <remytaymans@gmail.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<!-- Add pos.order total amount -->
<template
id="total_pos_order_amount"
name="Portal total POS order amount"
priority="40"
inherit_id="website_portal_v10.portal_layout">
<xpath expr="//div[@class='o_my_details']" position="after">
<div class="o_my_details_eater">
<h3 class="page-header">Purchases</h3>
<p>
You have purchased a total amount of
<span t-esc="posorder_amount"
t-esc-options='{"widget": "monetary", "display_currency": "company_currency"}'/>.
</p>
</div>
</xpath>
</template>
</openerp>
Loading…
Cancel
Save