Browse Source

[ADD] emc_wsite_portal: Release Capital Requests

Add the access to the release capital request in the personal portal
view.
pull/1/head
Rémy Taymans 7 years ago
parent
commit
bda1cfddea
  1. 1
      easy_my_coop_website_portal/__openerp__.py
  2. 77
      easy_my_coop_website_portal/controllers/main.py
  3. 108
      easy_my_coop_website_portal/views/easy_my_coop_website_portal_templates.xml

1
easy_my_coop_website_portal/__openerp__.py

@ -22,6 +22,7 @@
'depends': [ 'depends': [
'website', 'website',
'website_portal_v10', 'website_portal_v10',
'easy_my_coop',
], ],
'data': [ 'data': [

77
easy_my_coop_website_portal/controllers/main.py

@ -1,7 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2015-2016 Odoo S.A.
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# Copyright 2017-2018 Rémy Taymans <remytaymans@gmail.com> # Copyright 2017-2018 Rémy Taymans <remytaymans@gmail.com>
# Copyright 2018 Odoo SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@ -22,8 +23,8 @@ class CooperatorWebsiteAccount(WebsiteAccount):
# partner itself or to the linked partner. So there is no # partner itself or to the linked partner. So there is no
# need to check if the partner is a "contact" or not. # need to check if the partner is a "contact" or not.
coop = request.env.user.partner_id.commercial_partner_id coop = request.env.user.partner_id.commercial_partner_id
coop_bank = request.env['res.partner.bank'].search(
[('partner_id', '=', coop.id)],
coop_bank = request.env['res.partner.bank'].sudo().search(
[('partner_id', 'in', [coop.id])],
limit=1 limit=1
) )
values.update({ values.update({
@ -32,4 +33,74 @@ class CooperatorWebsiteAccount(WebsiteAccount):
}) })
return values return values
@http.route()
def account(self):
""" Add Release Capital Request to main account page """
response = super(CooperatorWebsiteAccount, self).account()
partner = request.env.user.partner_id
invoice_mgr = request.env['account.invoice']
capital_request_count = invoice_mgr.search_count([
('message_partner_ids', 'in',
[partner.commercial_partner_id.id]),
('state', 'in', ['open', 'paid', 'cancelled']),
# Get only the release capital request
('release_capital_request', '=', True),
])
response.qcontext.update({
'capital_request_count': capital_request_count,
})
return response
@http.route(
['/my/release_capital_request',
'/my/release_capital_request/page/<int:page>'],
type='http', auth="user", website=True)
def portal_my_release_capital_request(self, page=1, date_begin=None,
date_end=None, **kw):
"""Render a page with the list of release capital request.
A release capital request is an invoice with a flag that tell
if it's a capital request or not.
"""
values = self._prepare_portal_layout_values()
partner = request.env.user.partner_id
invoice_mgr = request.env['account.invoice']
domain = [
('message_partner_ids', 'in',
[partner.commercial_partner_id.id]),
('state', 'in', ['open', 'paid', 'cancelled']),
# Get only the release capital request
('release_capital_request', '=', True),
]
archive_groups = self._get_archive_groups('account.invoice', domain)
if date_begin and date_end:
domain += [('create_date', '>=', date_begin),
('create_date', '<', date_end)]
# count for pager
capital_request_count = invoice_mgr.search_count(domain)
# pager
pager = request.website.pager(
url="/my/release_capital_request",
url_args={'date_begin': date_begin, 'date_end': date_end},
total=capital_request_count,
page=page,
step=self._items_per_page
)
# content according to pager and archive selected
invoices = invoice_mgr.search(
domain, limit=self._items_per_page, offset=pager['offset'])
values.update({
'date': date_begin,
'capital_requests': invoices,
'page_name': 'invoice',
'pager': pager,
'archive_groups': archive_groups,
'default_url': '/my/release_capital_request',
})
return request.website.render(
"easy_my_coop_website_portal.portal_my_capital_releases",
values
)

108
easy_my_coop_website_portal/views/easy_my_coop_website_portal_templates.xml

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2015-2016 Odoo S.A.
Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
Copyright 2018 Rémy Taymans <remytaymans@gmail.com> Copyright 2018 Rémy Taymans <remytaymans@gmail.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
--> -->
@ -87,4 +89,110 @@
</xpath> </xpath>
</template> </template>
<!-- Release Capital Requests in the menu -->
<template
id="portal_my_home_menu_capital_release"
name="Portal Menu: Easy My Coop Capital Release"
inherit_id="website_portal_v10.portal_layout"
priority="20">
<xpath expr="//ul[contains(@class,'o_portal_submenu')]"
position="inside">
<li>
<a href="/my/release_capital_request">Capital Releases</a>
</li>
</xpath>
</template>
<!-- Release Capital Requests on the main page -->
<template
id="portal_my_home_capital_release"
name="Portal My Home : Easy My Coop Capital Release Requests"
inherit_id="website_portal_v10.portal_my_home"
priority="20">
<xpath expr="//div[contains(@class,'o_my_home_content')]"
position="inside">
<h3 class="page-header">
<a href="/my/release_capital_request">
Your Release Capital Requests
<small class="ml8">
<t t-if="capital_request_count">
<span class='badge'>
<t t-esc="capital_request_count"/>
</span>
</t>
<t t-if="not capital_request_count">
There are currently no release capital request for your
account.
</t>
</small>
</a>
</h3>
</xpath>
</template>
<!-- Release Capital Request page -->
<template id="portal_my_capital_releases" name="My Capital Releases">
<t t-call="website_portal_v10.portal_layout">
<h3 class="page-header">Your Capital Release Requests</h3>
<t t-if="not capital_requests">
<p>
There are currently no capital release request for your
account.
</p>
</t>
<t t-if="capital_requests">
<table class="table table-hover o_my_status_table">
<thead>
<tr class="active">
<th>Request #</th>
<th>Request Date</th>
<th>Due Date</th>
<th></th>
<th>Amount Due</th>
</tr>
</thead>
<tbody>
<tr t-foreach="capital_requests" t-as="capital_request">
<td>
<a t-att-href="'/report/pdf/easy_my_coop.theme_invoice_G002/%s' %
capital_request.id">
<t t-esc="capital_request.number"/>
</a>
</td>
<td><span t-field="capital_request.date_invoice"/></td>
<td><span t-field="capital_request.date_due"/></td>
<td>
<t t-if="capital_request.state == 'open'">
<span class="label label-info">
<i class="fa fa-fw fa-clock-o"/> Waiting for Payment
</span>
</t>
<t t-if="capital_request.state == 'paid'">
<span class="label label-default">
<i class="fa fa-fw fa-check"/> Paid
</span>
</t>
<t t-if="capital_request.state == 'cancel'">
<span class="label label-default">
<i class="fa fa-fw fa-remove"/> Cancelled
</span>
</t>
</td>
<td>
<span t-field="capital_request.residual"
t-field-options='{
"widget": "monetary",
"display_currency": "capital_request.currency_id"
}'/>
</td>
</tr>
</tbody>
</table>
<div t-if="pager" class="o_portal_pager text-center">
<t t-call="website.pager"/>
</div>
</t>
</t>
</template>
</openerp> </openerp>
Loading…
Cancel
Save