summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2017-08-28 13:54:52 +0200
committerThibault Delavallée <tde@odoo.com>2017-09-06 10:40:22 +0200
commit22734f47d8a84d08c7f62ff2ca0f4241134bc9b6 (patch)
tree127eed747d9e9c5d66c18ae5954fe3c6d589af90
parent071451a884e0f0dbe1e7199c31c51df8b24bd6d8 (diff)
[IMP] website_quote: improve quote url management in customer portal
* website_quote should not override all sale links from the customer portal to replace them by website_quote specific view. Indeed the quote view should be used only if the order has an active template defined on it; * do not override existing columns of the order page view on portal with same content; * implement redirection at route level by overriding the controller order route;
-rw-r--r--addons/website_quote/controllers/main.py19
-rw-r--r--addons/website_quote/views/website_quote_templates.xml38
2 files changed, 27 insertions, 30 deletions
diff --git a/addons/website_quote/controllers/main.py b/addons/website_quote/controllers/main.py
index 859eb5f715c..f8c67177304 100644
--- a/addons/website_quote/controllers/main.py
+++ b/addons/website_quote/controllers/main.py
@@ -4,13 +4,28 @@ import base64
import werkzeug
-from odoo import fields, http, _
+from odoo import exceptions, fields, http, _
from odoo.http import request
-from odoo.addons.portal.controllers.portal import get_records_pager
+from odoo.addons.portal.controllers.portal import CustomerPortal, get_records_pager
from odoo.addons.portal.controllers.mail import _message_post_helper
+class CustomerPortal(CustomerPortal):
+
+ @http.route()
+ def portal_order_page(self, order=None, access_token=None, **kw):
+ try:
+ order_sudo = self._order_check_access(order, access_token=access_token)
+ except exceptions.AccessError:
+ pass
+ else:
+ if order_sudo.template_id and order_sudo.template_id.active:
+ return request.redirect('/quote/%s/%s' % (order, access_token or ''))
+ return super(CustomerPortal, self).portal_order_page(order=order, access_token=access_token, **kw)
+
+
class sale_quote(http.Controller):
+
@http.route("/quote/<int:order_id>", type='http', auth="user", website=True)
def view_user(self, *args, **kwargs):
return self.view(*args, **kwargs)
diff --git a/addons/website_quote/views/website_quote_templates.xml b/addons/website_quote/views/website_quote_templates.xml
index f7c9ef5a58b..d1b546bbc81 100644
--- a/addons/website_quote/views/website_quote_templates.xml
+++ b/addons/website_quote/views/website_quote_templates.xml
@@ -675,32 +675,14 @@
</xpath>
</template>
- <template id="quotations" inherit_id="sale.portal_my_quotations">
- <xpath expr="//t[@t-foreach='quotations']" position="replace">
- <t t-foreach="quotations" t-as="quotation">
- <tr>
- <td>
- <t t-if="quotation.sudo().partner_id.commercial_partner_id != request.env.user.partner_id.commercial_partner_id and request.env.user.share">
- <a t-attf-href="/quote/#{quotation.id}/#{quotation.access_token}?#{keep_query()}"><t t-esc="quotation.name"/></a>
- </t>
- <t t-if="not (quotation.sudo().partner_id.commercial_partner_id != request.env.user.partner_id.commercial_partner_id and request.env.user.share)">
- <a t-attf-href="/quote/#{quotation.id}?#{keep_query()}"><t t-esc="quotation.name"/></a>
- </t>
- </td>
- <td><span t-field="quotation.date_order"/></td>
- <td><span t-field="quotation.validity_date"/></td>
- <td>
- <t t-if="quotation.state == 'cancel'">
- <span class="label label-default"><i class="fa fa-fw fa-remove"/> Cancelled</span>
- </t>
- <t t-if="quotation.validity_date and quotation.validity_date &lt; date">
- <span class="label label-default"><i class="fa fa-fw fa-clock-o"/> Expired</span>
- </t>
- </td>
- <td><span t-field="quotation.amount_total" t-options='{"widget": "monetary", "display_currency": quotation.pricelist_id.currency_id}'/>
- </td>
- </tr>
- </t>
- </xpath>
- </template>
+ <template id="portal_my_quotations_inherit_quote" inherit_id="sale.portal_my_quotations">
+ <xpath expr="//t[@t-foreach='quotations']/tr/td/a" position="replace">
+ <t t-if="quotation.template_id and quotation.template_id.active">
+ <a t-attf-href="/quote/#{quotation.id}?#{keep_query()}"><t t-esc="quotation.name"/></a>
+ </t>
+ <t t-else="">
+ <a t-attf-href="/my/orders/#{quotation.id}?#{keep_query()}"><t t-esc="quotation.name"/></a>
+ </t>
+ </xpath>
+ </template>
</odoo>