[IMP]: Add optional product scroll to the pricing instead of top
-> Hide History and Edit button when print quotation -> Add signature in customization option and order should not validate if sign is empty -> Add options to the left menu and remove/hide it if no options available -> Add sidenav to template -> Improve Options view(table like pricing) bzr revid: aja@tinyerp.com-20140121125314-1tom0sjcltegi57c
This commit is contained in:
parent
e33c70a318
commit
5b976496e1
|
@ -37,25 +37,35 @@ class sale_quote(http.Controller):
|
|||
values = {
|
||||
'quotation': order,
|
||||
'message': message,
|
||||
'new_post' : request.httprequest.session.get('new_post',False)
|
||||
'new_post' : request.httprequest.session.get('new_post',False),
|
||||
'option': self._check_option_len(order),
|
||||
}
|
||||
return request.website.render('website_quotation.so_quotation', values)
|
||||
|
||||
def _check_option_len(self, order):
|
||||
for option in order.options:
|
||||
if not option.line_id:
|
||||
return True
|
||||
return False
|
||||
@http.route(['/quote/accept'], type='json', auth="public", website=True)
|
||||
def accept(self, order_id=None, token=None, signer=None, sign=None, **post):
|
||||
order_obj = request.registry.get('sale.order')
|
||||
order = order_obj.browse(request.cr, SUPERUSER_ID, order_id)
|
||||
assert token == order.access_token, 'Access denied, wrong token!'
|
||||
attachment = {
|
||||
'name': 'sign.png',
|
||||
'datas':sign,
|
||||
'datas_fname': 'sign.png',
|
||||
'res_model': 'sale.order',
|
||||
'res_id': order_id,
|
||||
}
|
||||
request.registry['ir.attachment'].create(request.cr, request.uid, attachment, context=request.context)
|
||||
order_obj.write(request.cr, request.uid, [order_id], {'signer_name':signer,'state': 'manual'})
|
||||
return []
|
||||
error = {}
|
||||
if not signer: error['signer'] = 'missing'
|
||||
if not sign: error['sign'] = 'missing'
|
||||
if not error:
|
||||
attachment = {
|
||||
'name': 'sign.png',
|
||||
'datas':sign,
|
||||
'datas_fname': 'sign.png',
|
||||
'res_model': 'sale.order',
|
||||
'res_id': order_id,
|
||||
}
|
||||
request.registry['ir.attachment'].create(request.cr, request.uid, attachment, context=request.context)
|
||||
order_obj.write(request.cr, request.uid, [order_id], {'signer_name':signer,'state': 'manual'})
|
||||
return [error]
|
||||
|
||||
@http.route(['/quote/<int:order_id>/<token>/decline'], type='http', auth="public", website=True)
|
||||
def decline(self, order_id, token, **post):
|
||||
|
@ -107,7 +117,7 @@ class sale_quote(http.Controller):
|
|||
order_line_obj.write(request.cr, SUPERUSER_ID, [line_id], {'product_uom_qty': (quantity)}, context=request.context)
|
||||
return quantity
|
||||
|
||||
@http.route(["/template/<model('sale.quote.template'):quote>"], type='http', auth="public", website=True)
|
||||
@http.route(["/template/<model('sale.quote.template'):quote>"], type='http', auth="user", website=True)
|
||||
def template_view(self, quote, **post):
|
||||
values = {
|
||||
'template': quote,
|
||||
|
@ -135,6 +145,6 @@ class sale_quote(http.Controller):
|
|||
})
|
||||
line = request.registry.get('sale.order.line').create(request.cr, SUPERUSER_ID, vals, context=request.context)
|
||||
option_obj.write(request.cr, SUPERUSER_ID, [option.id], {'line_id': line}, context=request.context)
|
||||
return werkzeug.utils.redirect("/quote/%s/%s" % (order.id, token))
|
||||
return werkzeug.utils.redirect("/quote/%s/%s#pricing" % (order.id, token))
|
||||
|
||||
|
||||
|
|
|
@ -37,16 +37,29 @@ $(document).ready(function () {
|
|||
var href = $link.attr("action");
|
||||
var order_id = href.match(/accept\/([0-9]+)/);
|
||||
var token = href.match(/token=(.*)/);
|
||||
var datapair = $("#signature").jSignature("getData",'image')
|
||||
var sign = false;
|
||||
var signer_name = false;
|
||||
if($('#signature').length > 0){
|
||||
var isSignature=$("#signature").jSignature('getData','base30')[1].length>1?true:false;
|
||||
if (isSignature)
|
||||
sign = JSON.stringify($("#signature").jSignature("getData",'image')[1]);
|
||||
signer_name = $("#name").val();
|
||||
}
|
||||
openerp.jsonRpc("/quote/accept/", 'call', {
|
||||
'order_id': parseInt(order_id[1]),
|
||||
'token': token[1],
|
||||
'signer': $("#signer").val(),
|
||||
'sign': JSON.stringify(datapair[1]),
|
||||
'signer': signer_name,
|
||||
'sign': sign,
|
||||
})
|
||||
.then(function (data) {
|
||||
$('#modelaccept').modal('hide');
|
||||
location.reload();
|
||||
if(!_.isEmpty(data)){
|
||||
$('#modelaccept').modal('hide');
|
||||
var url = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port : "")
|
||||
window.location.replace(url +'/quote/'+order_id[1]+'/'+token[1]+'?message=3');
|
||||
} else{
|
||||
if (data[0]['signer']) $('#signer').addClass('has-error'); else $('#signer').removeClass('has-error');
|
||||
if (data[0]['sign']) $('#drawsign').addClass('panel-danger'); else $('#drawsign').removeClass('panel-danger');
|
||||
}
|
||||
});
|
||||
return false
|
||||
});
|
||||
|
@ -54,7 +67,7 @@ $(document).ready(function () {
|
|||
var ul = $('[data-id="quote_sidebar"]');
|
||||
var sub_li = null;
|
||||
var sub_ul = null;
|
||||
|
||||
ul.empty();
|
||||
$("section h1, section h2").each(function() {
|
||||
switch (this.tagName.toLowerCase()) {
|
||||
case "h1":
|
||||
|
|
|
@ -94,8 +94,8 @@
|
|||
</template>
|
||||
|
||||
<template id="chatter">
|
||||
<h1 class="page-header">History</h1>
|
||||
<ul class="media-list" id="comments-list">
|
||||
<h1 class="page-header hidden-print">History</h1>
|
||||
<ul class="media-list hidden-print" id="comments-list">
|
||||
<li t-foreach="quotation.message_ids" t-as="message" class="media">
|
||||
<div class="media-body">
|
||||
<img class="media-object pull-left" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(message.author_id.id)" style="width: 50px; margin-right: 10px;"/>
|
||||
|
@ -167,11 +167,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<hr class="mt0 mb0"/>
|
||||
<div class="hidden-print navspy" role="complementary">
|
||||
<ul class="nav bs-sidenav" data-id="quote_sidebar">
|
||||
<li><a href="#introduction">Introduction</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<t t-call="website_quotation.navigation_menu"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
|
@ -196,7 +192,7 @@
|
|||
<em t-esc="quotation.name"/>
|
||||
<small t-field="quotation.state"/>
|
||||
<div groups="base.group_website_publisher" t-ignore="true" class="pull-right css_editable_mode_hidden">
|
||||
<a class="btn btn-info" t-att-href="'/web#return_label=Website&model=%s&id=%s' % (quotation._name, quotation.id)">Update Quote</a>
|
||||
<a class="btn btn-info hidden-print" t-att-href="'/web#return_label=Website&model=%s&id=%s' % (quotation._name, quotation.id)">Update Quote</a>
|
||||
</div>
|
||||
</h1>
|
||||
|
||||
|
@ -216,19 +212,6 @@
|
|||
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'/>
|
||||
with payment terms: <b t-field="quotation.payment_term"/>.
|
||||
</p>
|
||||
<div>
|
||||
<strong>Your Name:</strong><br/>
|
||||
<input type="text" id="signer" class="form-control"/>
|
||||
</div>
|
||||
<div class="panel panel-default mt16 mb0">
|
||||
<div class="panel-heading">
|
||||
<div class="pull-right">
|
||||
<a id="sign_clean" class="btn btn-xs">Clear</a>
|
||||
</div>
|
||||
<strong>Draw your signature</strong>
|
||||
</div>
|
||||
<div id="signature" class="panel-body" style="padding: 0"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary">Sign Order</button> or
|
||||
|
@ -318,6 +301,8 @@
|
|||
<a t-att-id="line.id"/>
|
||||
<div t-field="line.website_description"/>
|
||||
</t>
|
||||
|
||||
<div class="oe_structure"/>
|
||||
|
||||
<a id="pricing"/>
|
||||
<t t-call="website_quotation.pricing"/>
|
||||
|
@ -334,22 +319,84 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<template id="navigation_menu">
|
||||
<div class="hidden-print navspy" role="complementary">
|
||||
<ul class="nav bs-sidenav" data-id="quote_sidebar">
|
||||
<li><a href="#introduction">Introduction</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Options:Quotation Signature -->
|
||||
<template id="opt_quotation_signature" name="Signature" inherit_option_id="website_quotation.so_quotation" inherit_id="website_quotation.so_quotation">
|
||||
<xpath expr="//div[@class='modal-body']" position="inside">
|
||||
<div id="signer" class="form-group">
|
||||
<label class="control-label" for="name">Your Name:</label>
|
||||
<input type="text" name="signer" id="name" class="form-control"/>
|
||||
</div>
|
||||
<div class="panel panel-default mt16 mb0" id="drawsign">
|
||||
<div class="panel-heading">
|
||||
<div class="pull-right">
|
||||
<a id="sign_clean" class="btn btn-xs">Clear</a>
|
||||
</div>
|
||||
<strong>Draw your signature</strong>
|
||||
</div>
|
||||
<div id="signature" class="panel-body" style="padding: 0"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="optional_products">
|
||||
<div class="container mt32" t-if="quotation.options">
|
||||
<h3>Options:</h3>
|
||||
<div class='row mt16'>
|
||||
<t t-foreach="quotation.options" t-as="option">
|
||||
<div class='col-md-2 thumbnail' style='width: 170px; margin-right: 16px;' t-if="not option.line_id">
|
||||
<div class='mt16 text-center'>
|
||||
<a href="#" t-field="option.product_id.name"/>
|
||||
<span t-field="option.product_id.image_small" t-field-options='{"widget": "image", "class": "img-rounded"}'/>
|
||||
</div>
|
||||
<a t-href="/quote/add_line/#{ option.id }/#{ quotation.id }/#{ quotation.access_token }" class="btn btn-primary btn-xs hidden-print">Add To Quotation
|
||||
</a>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container mt32" t-if="option">
|
||||
<section data-snippet-id="title">
|
||||
<h1 class="page-header">Options</h1>
|
||||
</section>
|
||||
<section id="options">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Products</th>
|
||||
<th>Discription</th>
|
||||
<th>Discount</th>
|
||||
<th class="text-right">Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr t-foreach="quotation.options" t-as="option">
|
||||
<t t-if="not option.line_id">
|
||||
<td>
|
||||
<div t-field="option.product_id.name"/>
|
||||
</td>
|
||||
<td>
|
||||
<div t-field="option.name"/>
|
||||
</td>
|
||||
<td>
|
||||
<div id="quote_discount" t-if="option.discount">
|
||||
<t t-esc="option.discount"/>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<strong class="text-right">
|
||||
<div t-field="option.price_unit"
|
||||
t-field-options='{"widget": "monetary", "display_currency": "quotation.pricelist_id.currency_id"}'
|
||||
t-att-style="option.discount and 'text-decoration: line-through' or ''"
|
||||
t-att-class="option.discount and 'text-danger' or ''"/>
|
||||
<div t-if="option.discount">
|
||||
<t t-esc="'%.2f' % ((1-option.discount) * option.price_unit)"/>
|
||||
</div>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="pull-right">
|
||||
<a t-href="/quote/add_line/#{ option.id }/#{ quotation.id }/#{ quotation.access_token }" class="mb8 hidden-print">
|
||||
<span class="fa fa-shopping-cart"/>
|
||||
</a>
|
||||
</td>
|
||||
</t>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="so_template" name="SO Template">
|
||||
|
|
Loading…
Reference in New Issue