[IMP] Small improvements: messages

bzr revid: fp@tinyerp.com-20140120222228-pj7xhlui2cwmnrxw
This commit is contained in:
Fabien Pinckaers
2014-01-20 23:22:28 +01:00
parent cd3be26606
commit e33c70a318
3 changed files with 39 additions and 23 deletions
+4 -3
View File
@@ -29,13 +29,14 @@ import werkzeug
class sale_quote(http.Controller):
@http.route(["/quote/<int:order_id>/<token>"], type='http', auth="public", website=True)
def view(self, order_id, token, **post):
def view(self, order_id, token, message=False, **post):
# use SUPERUSER_ID allow to access/view order for public user
order = request.registry.get('sale.order').browse(request.cr, SUPERUSER_ID, order_id)
assert token == order.access_token, 'Access denied, wrong token!'
# TODO: if not order.template_id: return to the URL of the portal view of SO
values = {
'quotation': order,
'message': message,
'new_post' : request.httprequest.session.get('new_post',False)
}
return request.website.render('website_quotation.so_quotation', values)
@@ -62,7 +63,7 @@ class sale_quote(http.Controller):
request.registry.get('sale.order').write(request.cr, request.uid, [order_id], {'state': 'cancel'})
if message:
self.message_post(message, order_id)
return werkzeug.utils.redirect("/quote/%s/%s" % (order_id, token))
return werkzeug.utils.redirect("/quote/%s/%s?message=2" % (order_id, token))
@http.route(['/quote/<int:order_id>/<token>/post'], type='http', auth="public", website=True)
def post(self, order_id, token, **post):
@@ -74,7 +75,7 @@ class sale_quote(http.Controller):
if message:
self.message_post(message, order_id)
request.httprequest.session['new_post'] = True
return werkzeug.utils.redirect("/quote/%s/%s" % (order_id, token))
return werkzeug.utils.redirect("/quote/%s/%s?message=1" % (order_id, token))
def message_post(self , message, order_id):
request.session.body = message
+1
View File
@@ -141,6 +141,7 @@ class sale_order(osv.osv):
products += line.product_id.product_tmpl_id.recommended_products(context=context)
return products
class sale_option_line(osv.osv):
_name = "sale.option.line"
_description = "Sale Options"
@@ -117,8 +117,8 @@
<form id="comment" t-attf-action="/quote/#{quotation.id}/#{quotation.access_token}/post" method="POST">
<img class="img pull-left img-rounded" t-att-src="'/website/image?model=res.partner&amp;field=image_small&amp;id='+str(user_id.partner_id.id)" style="width: 50px; margin-right: 10px;"/>
<div class="pull-left mb32" style="width: 75%%">
<textarea rows="3" name="comment" class="form-control" placeholder="Write a comment..."></textarea>
<button type="submit" class="btn btn-primary mt8">Post</button>
<textarea rows="4" name="comment" class="form-control" placeholder="Send us a note..."></textarea>
<button type="submit" class="btn btn-primary mt8">Send</button>
</div>
</form>
</section>
@@ -127,18 +127,16 @@
</template>
<template id="quotation_toolbar">
<div class="text-center hidden-print">
<div class="btn-group btn-group-lg" t-if="quotation.state in ('draft', 'sent', 'waiting_date')">
<a class="btn btn-success fa fa-check" data-toggle="modal" data-target="#modelaccept">
Accept
</a>
<a class="btn btn-info fa fa-comment" type="submit" href="#discussion">
Feedback
</a>
<a class="btn btn-danger fa fa-times" data-toggle="modal" data-target="#modeldecline">
Reject
</a>
</div>
<div class="text-center hidden-print" t-if="quotation.state in ('draft', 'sent', 'waiting_date')">
<a class="btn btn-success fa fa-check" data-toggle="modal" data-target="#modelaccept">
Accept
</a>
<a class="btn btn-info fa fa-comment" type="submit" href="#discussion">
Feedback
</a>
<a class="btn btn-danger fa fa-times" data-toggle="modal" data-target="#modeldecline">
Reject
</a>
</div>
</template>
@@ -159,12 +157,14 @@
<a class="btn btn-primary btn-block fa fa-check" data-toggle="modal" data-target="#modelaccept">
Accept Order
</a>
<a class="btn btn-link" type="submit" href="#discussion">
Ask Changes
</a> or
<a class="btn btn-link" data-toggle="modal" data-target="#modeldecline">
Reject
</a>
<div class="mt8">
<a type="submit" href="#discussion">
Ask Changes
</a> or
<a data-toggle="modal" data-target="#modeldecline">
Reject
</a>
</div>
</div>
<hr class="mt0 mb0"/>
<div class="hidden-print navspy" role="complementary">
@@ -175,6 +175,20 @@
</div>
</div>
<div class="col-md-9">
<div class="alert alert-success alert-dismissable" t-if="message==1">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&amp;times;</button>
Your message has been successfully sent!
</div>
<div class="alert alert-warning alert-dismissable" t-if="message==2">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&amp;times;</button>
This quotation has been rejected. <a href="#discussion">Contact us</a> if you want a new one.
</div>
<div class="alert alert-warning alert-dismissable" t-if="message==3">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&amp;times;</button>
This order has been validated. Thanks for your trust
and do not hesitate to <a href="#discussion">contact us</a> for
any question.
</div>
<a id="introduction"/>
<h1 class="page-header mt16">
<span t-if="quotation.state in ('draft','sent','cancel')">Your Quotation</span>