diff options
| author | Vipul Bhatt <vbh@odoo.com> | 2016-04-12 10:22:19 +0200 |
|---|---|---|
| committer | Jérome Maes <jem@openerp.com> | 2016-05-27 10:50:34 +0200 |
| commit | 4dfbcecfdb59c12eaf4b3b435a626f07574d5ce3 (patch) | |
| tree | 7a4dd35f9217c52dbfdf9caa0e51a11f5bc309ad /addons/website_project_issue | |
| parent | a999969f81f67d38cf17c29e208e954b72560de9 (diff) | |
[IMP] website_{portal,portal_sale,project_issue,quote} : add pager for customer documents
This commit adds controller to list documents of customer, with pager and archive
widget to sort documents. Impacted documents are : quotations, sale order,
invoices, and issues.
Portal breadcrumd is improved too : add the home icon, and keep the query
params when using archive widget.
Some editable zones were added to templates, allowing people to customize
their frontend portal.
Diffstat (limited to 'addons/website_project_issue')
| -rw-r--r-- | addons/website_project_issue/controllers/main.py | 41 | ||||
| -rw-r--r-- | addons/website_project_issue/views/project_issue_templates.xml | 50 |
2 files changed, 74 insertions, 17 deletions
diff --git a/addons/website_project_issue/controllers/main.py b/addons/website_project_issue/controllers/main.py index 98f06c0c281..64b006e2f42 100644 --- a/addons/website_project_issue/controllers/main.py +++ b/addons/website_project_issue/controllers/main.py @@ -6,17 +6,46 @@ from openerp.http import request class WebsiteAccount(website_account): - @http.route(['/my', '/my/home'], type='http', auth="user", website=True) + + @http.route() def account(self): response = super(WebsiteAccount, self).account() - user = request.env.user - project_issues = request.env['project.issue'].search([]) - response.qcontext.update({'issues': project_issues}) + issue_count = request.env['project.issue'].search_count([]) + response.qcontext.update({'issue_count': issue_count}) return response + @http.route(['/my/issues', '/my/issues/page/<int:page>'], type='http', auth="user", website=True) + def portal_my_issues(self, page=1, date_begin=None, date_end=None, **kw): + values = self._prepare_portal_layout_values() + ProjectIssue = request.env['project.issue'] + domain = [] + # archive groups - Default Group By 'create_date' + archive_groups = self._get_archive_groups('project.issue', domain) + if date_begin and date_end: + domain += [('create_date', '>=', date_begin), ('create_date', '<', date_end)] + # pager + issue_count = ProjectIssue.search_count(domain) + pager = request.website.pager( + url="/my/issues", + url_args={'date_begin': date_begin, 'date_end': date_end}, + total=issue_count, + page=page, + step=self._items_per_page + ) + # content according to pager and archive selected + project_issues = ProjectIssue.search(domain, order="stage_id", limit=self._items_per_page, offset=pager['offset']) + + values.update({ + 'date': date_begin, + 'issues': project_issues, + 'page_name': 'issue', + 'archive_groups': archive_groups, + 'default_url': '/my/issues', + 'pager': pager + }) + return request.website.render("website_project_issue.portal_my_issues", values) -class WebsiteProjectIssue(http.Controller): @http.route(['/my/issues/<int:issue_id>'], type='http', auth="user", website=True) - def issues_followup(self, issue_id=None): + def issues_followup(self, issue_id=None, **kw): issue = request.env['project.issue'].browse(issue_id) return request.website.render("website_project_issue.issues_followup", {'issue': issue}) diff --git a/addons/website_project_issue/views/project_issue_templates.xml b/addons/website_project_issue/views/project_issue_templates.xml index a19fa256366..27a120cd84c 100644 --- a/addons/website_project_issue/views/project_issue_templates.xml +++ b/addons/website_project_issue/views/project_issue_templates.xml @@ -1,7 +1,33 @@ <?xml version="1.0" encoding="utf-8"?> <odoo> - <template id="portal_project_issue" name="Portal Project Issues" inherit_id="website_portal.account"> - <xpath expr="//div[contains(@class,'o_my_documents')]/*[last()]" position="after"> + + <template id="portal_my_home_menu_issue" name="Portal layout : issues menu entry" inherit_id="website_portal.portal_layout" priority="30"> + <xpath expr="//ul[contains(@class,'o_portal_submenu')]" position="inside"> + <li t-att-class="page_name == 'issue' and 'active' or ''"> + <a href="/my/issues">Issues</a> + </li> + </xpath> + </template> + + <template id="portal_my_home_issue" name="Portal My Home : issue entries" inherit_id="website_portal.portal_my_home" priority="30"> + <xpath expr="//div[contains(@class,'o_my_home_content')]" position="inside"> + <h3 class="page-header"> + <a href="/my/issues">Your Issues + <small class="ml8"> + <t t-if="issue_count"> + <span class='badge'><t t-esc="issue_count"/></span> + </t> + <t t-if="not issue_count"> + There are currently no issues for your account. + </t> + </small> + </a> + </h3> + </xpath> + </template> + + <template id="portal_my_issues" name="My Issues" priority="30"> + <t t-call="website_portal.portal_layout"> <h3 class="page-header">Your Issues</h3> <t t-if="not issues"> <p>There are currently no issues for your account.</p> @@ -16,20 +42,21 @@ </tr> </thead> <t t-foreach="issues" t-as="issue"> - <tr t-att-class="'hidden to_hide' if issue_index > 4 else ''"> - <td><a t-attf-href="/my/issues/#{issue.id}">Issue <t t-esc="issue.id"/></a></td> + <tr> + + <td> + <a t-attf-href="/my/issues/#{issue.id}?{{ keep_query() }}">Issue <t t-esc="issue.id"/></a> + </td> <td><span t-field="issue.name"/></td><td/> <td><span t-field="issue.stage_id.name"/></td> </tr> </t> - <tr t-att-class="'hidden' if len(issues) < 6 else ''"> - <td colspan="4"> - <a href="" class="o_my_show_more btn btn-xs btn-default"><span>Show more</span><span class="hidden">Show less</span></a> - </td> - </tr> </table> + <div t-if="pager" class="o_portal_pager text-center"> + <t t-call="website.pager"/> + </div> </t> - </xpath> + </t> </template> <template id="issues_followup" name="Project Issues"> @@ -40,7 +67,8 @@ <div class="row"> <div class="col-sm-4"> <ol class="breadcrumb mt8"> - <li><a href="/my/home">My Account</a></li> + <li><a href="/my/home"><i class="fa fa-home"/></a></li> + <li><a t-attf-href="/my/issues?#{keep_query()}">My Issues</a></li> <li>Issue <span t-field="issue.id"/></li> </ol> </div> |
