[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;
This commit is contained in:
Thibault Delavallée
2017-09-06 10:40:22 +02:00
parent 071451a884
commit 22734f47d8
2 changed files with 27 additions and 30 deletions
+17 -2
View File
@@ -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)
@@ -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>