diff --git a/addons/account/controllers/portal.py b/addons/account/controllers/portal.py index 155c38d1a05..c59be47e588 100644 --- a/addons/account/controllers/portal.py +++ b/addons/account/controllers/portal.py @@ -1,8 +1,11 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +import re +from werkzeug.exceptions import NotFound + from odoo import http, _ -from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager +from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager, get_records_pager from odoo.exceptions import AccessError from odoo.http import request from odoo.tools import consteq @@ -46,7 +49,8 @@ class PortalAccount(CustomerPortal): 'invoice': invoice, } if access_token: - values['no_breadcrumbs'] = True + # force breadcrumbs even if access_token to `invite` users to register if they click on it + values['no_breadcrumbs'] = False values['access_token'] = access_token if kwargs.get('error'): @@ -56,6 +60,9 @@ class PortalAccount(CustomerPortal): if kwargs.get('success'): values['success'] = kwargs['success'] + history = request.session.get('my_invoices_history', []) + values.update(get_records_pager(history, invoice)) + return values @http.route(['/my/invoices', '/my/invoices/page/'], type='http', auth="user", website=True) @@ -93,6 +100,8 @@ class PortalAccount(CustomerPortal): ) # content according to pager and archive selected invoices = AccountInvoice.search(domain, order=order, limit=self._items_per_page, offset=pager['offset']) + request.session['my_invoices_history'] = invoices.ids[:100] + values.update({ 'date': date_begin, 'invoices': invoices, @@ -115,7 +124,10 @@ class PortalAccount(CustomerPortal): values = self._invoice_get_page_view_values(invoice_sudo, access_token, **kw) return request.render("account.portal_invoice_page", values) - @http.route(['/my/invoices/pdf/'], type='http', auth="public", website=True) + @http.route([ + '/my/invoices/pdf/', + '/my/invoices/html//' + ], type='http', auth="public", website=True) def portal_my_invoice_report(self, invoice_id, access_token=None, **kw): try: invoice_sudo = self._invoice_check_access(invoice_id, access_token) @@ -124,12 +136,20 @@ class PortalAccount(CustomerPortal): # print report as sudo, since it require access to taxes, payment term, ... and portal # does not have those access rights. - pdf = request.env.ref('account.account_invoices').sudo().render_qweb_pdf([invoice_sudo.id])[0] - pdfhttpheaders = [ - ('Content-Type', 'application/pdf'), - ('Content-Length', len(pdf)), - ] - return request.make_response(pdf, headers=pdfhttpheaders) + accountInvoiceReport = request.env.ref('account.account_invoices').sudo() + report_type = kw.get('report_type', 'pdf') + method_name = 'render_qweb_%s' % (report_type) + if hasattr(accountInvoiceReport, method_name): + invoice_report = getattr(accountInvoiceReport, method_name)([invoice_sudo.id], data={'report_type': report_type})[0] + reporthttpheaders = [ + ('Content-Type', 'application/pdf' if report_type == 'pdf' else 'text/html'), + ('Content-Length', len(invoice_report)), + ] + if report_type == 'pdf' and not kw.get('print'): + filename = "%s.pdf" % (re.sub('\W+', '-', invoice_sudo._get_printed_report_name())) + reporthttpheaders.append(('Content-Disposition', http.content_disposition(filename))) + return request.make_response(invoice_report, headers=reporthttpheaders) + raise NotFound() # ------------------------------------------------------------ # My Home diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 791d0820f63..0282010032e 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -171,3 +171,17 @@ class AccountInvoiceReport(models.Model): )""" % ( self._table, self.env['res.currency']._select_companies_rates(), self._select(), self._sub_select(), self._from(), self._group_by())) + + +class ReportInvoiceWithPayment(models.AbstractModel): + _name = 'report.account.report_invoice_with_payments' + + @api.model + def get_report_values(self, docids, data=None): + report = self.env['ir.actions.report']._get_report_from_name('account.report_invoice_with_payments') + return { + 'doc_ids': docids, + 'doc_model': report.model, + 'docs': self.env[report.model].browse(docids), + 'type_html': data and data.get('report_type') == 'html', + } diff --git a/addons/account/static/src/js/account_portal_sidebar.js b/addons/account/static/src/js/account_portal_sidebar.js new file mode 100644 index 00000000000..5323c09e0f3 --- /dev/null +++ b/addons/account/static/src/js/account_portal_sidebar.js @@ -0,0 +1,68 @@ +odoo.define('account.AccountPortalSidebar.instance', function (require) { +"use strict"; + +require('web.dom_ready'); +var AccountPortalSidebar = require('account.AccountPortalSidebar'); + +if (!$('.o_portal_invoice_sidebar').length) { + return $.Deferred().reject("DOM doesn't contain '.o_portal_invoice_sidebar'"); +} + +var account_portal_sidebar = new AccountPortalSidebar(); +return account_portal_sidebar.attachTo($('.o_portal_invoice_sidebar')).then(function () { + return account_portal_sidebar; +}); +}); + +//============================================================================== + +odoo.define('account.AccountPortalSidebar', function (require) { +"use strict"; + +var PortalSidebar = require('portal.PortalSidebar'); + +var AccountPortalSidebar = PortalSidebar.extend({ + events: { + 'click .o_portal_invoice_print': '_onPrintInvoice', + }, + /** + * @override + */ + start: function () { + var self = this; + this._super.apply(this, arguments); + var $invoiceHtml = this.$el.find('iframe#invoice_html'); + $invoiceHtml.on('load', self._onLoadIframe.bind(self, $invoiceHtml)); + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * Called when the iframe is load on custome portal + * here we set height and width of html preview (iframe) + * + * @private + */ + _onLoadIframe: function ($el) { + var $body = $el.contents().find('body'); + // expand iframe height for display full report on the custome portal (no scrollbar in iframe) + $el.height($body.scrollParent().height()); + // removed extra space in html preview (specially left and right margin) + $body.width('100%'); + }, + /** + * @private + * @param {MouseEvent} ev + */ + _onPrintInvoice: function (ev) { + ev.preventDefault(); + var href = $(ev.currentTarget).attr('href'); + this._printIframeContent(href); + }, +}); + + +return AccountPortalSidebar; +}); diff --git a/addons/account/views/account.xml b/addons/account/views/account.xml index d8153c82871..e7218152387 100644 --- a/addons/account/views/account.xml +++ b/addons/account/views/account.xml @@ -24,6 +24,12 @@ + + - + + diff --git a/addons/project/views/project_portal_templates.xml b/addons/project/views/project_portal_templates.xml index 02f4435e21f..391f46b38a7 100644 --- a/addons/project/views/project_portal_templates.xml +++ b/addons/project/views/project_portal_templates.xml @@ -78,7 +78,6 @@

- Project -

@@ -169,7 +168,6 @@

- Task - (#) Edit Task diff --git a/addons/purchase/views/portal_templates.xml b/addons/purchase/views/portal_templates.xml index ee6190304ce..7e23f335940 100644 --- a/addons/purchase/views/portal_templates.xml +++ b/addons/purchase/views/portal_templates.xml @@ -73,7 +73,6 @@

- Purchase Order

diff --git a/addons/sale/report/invoice_report_templates.xml b/addons/sale/report/invoice_report_templates.xml index e7a3598ce0d..9fbc3ab8b66 100644 --- a/addons/sale/report/invoice_report_templates.xml +++ b/addons/sale/report/invoice_report_templates.xml @@ -9,12 +9,75 @@ - + !sale.group_sale_layout - + + !sale.group_sale_layout + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DescriptionQuantityPrice
• + +
+ + +
+ With a % discount +
+
+
+ + + + +
+ Subtotal: + + +
+
+
+
+ - +
diff --git a/addons/sale/views/sale_portal_templates.xml b/addons/sale/views/sale_portal_templates.xml index 27a3da7516f..08441e9d6c5 100644 --- a/addons/sale/views/sale_portal_templates.xml +++ b/addons/sale/views/sale_portal_templates.xml @@ -134,7 +134,6 @@

- Quotation Order diff --git a/addons/sale_stock/views/account_invoice_views.xml b/addons/sale_stock/views/account_invoice_views.xml index b04ec1bf759..ed8e07b1a54 100644 --- a/addons/sale_stock/views/account_invoice_views.xml +++ b/addons/sale_stock/views/account_invoice_views.xml @@ -14,8 +14,9 @@

Description