[IMP]: quotation view

bzr revid: aja@tinyerp.com-20131209131015-8k6z3g1jit5npg6y
This commit is contained in:
ajay javiya (OpenERP) 2013-12-09 18:40:15 +05:30
parent 6fffcd42bd
commit 5b23738b1b
4 changed files with 118 additions and 119 deletions

View File

@ -54,4 +54,16 @@ class sale_quote(http.Controller):
request.session.body = False
return request.redirect("/quote/%s" % token)
@website.route(['/quote/update_line'], type='json', auth="public")
def update(self, line_id=None, qty=None, remove=False,unlink=False,**post):
if unlink:
request.registry.get('sale.order.line').unlink(request.cr, SUPERUSER_ID,[int(line_id)], context=request.context)
else:
val = self._update_order_line(line_id=int(line_id), number=(remove and -1 or 1), qty=int(qty))
# order = request.registry['website'].get_current_order(request.cr, request.uid, context=request.context)
return {}
def _update_order_line(self,line_id, number,qty):
qty += number
request.registry.get('sale.order.line').write(request.cr, SUPERUSER_ID, [int(line_id)], {'product_uom_qty':(qty)}, context=request.context)
return qty

View File

@ -41,7 +41,7 @@ class sale_order_line(osv.osv):
class sale_order(osv.osv):
_inherit = 'sale.order'
_columns = {
'quote_url': fields.char('URL'),
'quote_url': fields.char('URL', readonly=True),
'access_token':fields.char('Quotation Token', size=256),
'template_id': fields.many2one('sale.order','Quote Template'),
'website_description': fields.html('Description'),
@ -78,6 +78,7 @@ class sale_order(osv.osv):
'product_id': line.product_id.id,
'tax_id': [(6, 0, [x.id for x in line.tax_id])],
'website_description':line.website_description,
'state':'draft',
}))
return {'order_line':lines,'website_description': order_template.website_description}

View File

@ -1,32 +1,23 @@
openerp.base_calendar = function(instance) {
var _t = instance.web._t;
var QWeb = instance.web.qweb;
instance.base_calendar = {}
instance.sale_quote.quotation = instance.web.Widget.extend({
init: function(parent, db, action, id, view, quotation) {
this._super();
this.db = db;
this.action = action;
this.id = id;
this.view = view;
this.quotation = quotation;
},
start: function() {
var self = this;
self.open_invitation_form(self.quotation);
},
open_quotation : function(quotation){
alert('aaa');
this.$el.html(QWeb.render('quotation_view', {'quotation': JSON.parse(quotation)}));
},
$(document).ready(function () {
$('a.js_update_line_json').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
var href = $link.attr("href");
var qty = $link.attr("href").match(/qty=([0-9]+)/);
var line_id = href.match(/update_line\/([0-9]+)/);
console.log(line_id);
openerp.jsonRpc("/quote/update_line/", 'call', {
'line_id': line_id[1],
'qty': qty[1],
'remove': $link.is('[href*="remove"]'),
'unlink': $link.is('[href*="unlink"]'),
})
.then(function (data) {
location.reload();
// $link.parent('.input-group:first').find('.js_line_qty').val(data[0]);
// $('[data-oe-model="sale.order"][data-oe-field="amount_total"]').replaceWith(data[1]);
});
return false;
});
instance.sale_quote.view = function (db, action, id, view, quotation) {
instance.session.session_bind(instance.session.origin).done(function () {
new instance.sale_quote.quotation(null,db,action,id,view,quotation).appendTo($("body").addClass('openerp'));
});
}
};
});
//vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:

View File

@ -83,6 +83,7 @@
<script t-if="not translatable" type="text/javascript" src="/website/static/src/js/website.ace.js"></script>
<script t-if="translatable" type="text/javascript" src="/website/static/src/js/website.translator.js"></script>
</t>
<script type="text/javascript" src="/website_sale_quote/static/src/js/sale_quote.js"></script>
</head>
<body>
<div id="wrapwrap">
@ -93,93 +94,87 @@
</template>
<template id="pricing" name="Quotation Pricing">
<section id="quote" class="tab-pane oe_section">
<div class="well">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<address>
<strong t-field="quotation.partner_id.name"/>
<br/>
<t t-esc="quotation.partner_id.street"/>
<br/>
<t t-esc="quotation.partner_id.city"/>, <t t-esc="quotation.partner_id.state_id.name"/> <t t-esc="quotation.partner_id.zip"/>
<br/>
<abbr title="Phone">P:</abbr> <t t-esc="quotation.partner_id.phone"/>
</address>
</div>
<div class="col-xs-6 col-sm-6 col-md-6 text-right">
<p>
<em>Date: <t t-esc="quotation.date_order"/></em>
</p>
<p>
<em>Quotation #: <t t-esc="quotation.name"/></em>
</p>
</div>
</div>
<div class="row">
<div class="text-center">
<h1>Quotation</h1>
</div>
<table class="table table-hover">
<thead>
<tr>
<th>Product</th>
<th>Description</th>
<th>#</th>
<th class="text-center">Unit Price</th>
<th class="text-center">Subtotal</th>
</tr>
</thead>
<tbody>
<t t-foreach="quotation.order_line" t-as="line">
<tr>
<td class="col-md-9"><em><t t-esc="line.product_id.name"/></em></td>
<td class="col-md-9"><em><t t-esc="line.name"/></em></td>
<td class="col-md-1" style="text-align: center"><t t-esc="line.product_uom_qty"/></td>
<td class="col-md-1 text-center"><t t-esc="line.price_unit"/></td>
<td class="col-md-1 text-center"><t t-esc="line.price_subtotal"/></td>
</tr>
</t>
<tr>
<td></td>
<td></td>
<td></td>
<td class="text-right">
<p>
<strong>Untaxed Amount: </strong>
</p>
<p>
<strong>Tax: </strong>
</p></td>
<td class="text-center">
<p>
<strong t-field="quotation.amount_untaxed"
t-field-options='{
"widget": "monetary",
"display_currency": "website.pricelist_id.currency_id"
}'></strong>
</p>
<p>
<!-- <strong><t t-esc="quotation.amount_taxed"/></strong>-->
</p>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td class="text-right"><strong>Total: </strong></td>
<td class="text-center text-success">
<strong
t-field="quotation.amount_total"
t-field-options='{"widget": "monetary",
"display_currency":"website.pricelist_id.currency_id"
}'></strong>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<table class="table table-hover">
<thead>
<tr>
<th>Product</th>
<th>#</th>
<th class="text-center">Unit Price</th>
</tr>
</thead>
<tbody>
<t t-foreach="quotation.order_line" t-as="line">
<tr>
<td class="col-sm-8 col-md-6">
<div class="media">
<span class="thumbnail pull-left media-object" t-field="line.product_id.image" style="width: 72px; height: 72px;" t-field-options='{"widget": "image", "class": "img img-responsive"}'/>
<div class="media-body">
<h4 class="media-heading"><a href="#"><b t-field="line.product_id.name"/></a></h4>
<h5 class="media-heading" t-field="line.name"></h5>
</div>
</div>
</td>
<td class="col-sm-1 col-md-1" style="text-align: center">
<div class="input-group">
<span class="input-group-addon">
<a t-href="./update_line/#{ line.id }/?qty=#{line.product_uom_qty}&amp;remove=True" class="mb8 js_update_line_json">
<span class="fa fa-minus"/>
</a>
</span>
<input type="text" class="form-control js_line_qty" t-att-data-id="line.id" t-att-value="line.product_uom_qty"/>
<span class="input-group-addon">
<a t-href="./update_line/#{ line.id }/?qty=#{line.product_uom_qty}" class="mb8 js_update_line_json">
<span class="fa fa-plus"/>
</a>
</span>
</div>
</td>
<td class="col-sm-1 col-md-1 text-center">
<strong t-field="line.price_unit" t-field-options='{"widget": "monetary","display_currency": "website.pricelist_id.currency_id"}'></strong>
</td>
<td class="col-sm-1 col-md-1">
<a t-href="./update_line/#{ line.id }/??qty=#{line.product_uom_qty}&amp;unlink=True" class="mb8 js_update_line_json pull-right">
<span class="fa fa-trash-o"></span>
</a>
</td>
</tr>
</t>
<tr>
<td>   </td>
<td><h5>Subtotal</h5></td>
<td class="text-right">
<h5>
<strong t-field="quotation.amount_untaxed" t-field-options='{"widget": "monetary","display_currency": "website.pricelist_id.currency_id"}'></strong>
</h5>
</td>
<td>   </td>
</tr>
<tr>
<td>   </td>
<td><h5>Tax</h5></td>
<td class="text-right">
<h5>
<!-- <strong t-field="quotation.amount_taxed"-->
<!-- t-field-options='{-->
<!-- "widget": "monetary",-->
<!-- "display_currency": "website.pricelist_id.currency_id"}'>-->
<!-- </strong>-->
</h5>
</td>
<td>   </td>
</tr>
<tr>
<td>   </td>
<td><h3>Total</h3></td>
<td class="text-right">
<h3>
<strong t-field="quotation.amount_total" t-field-options='{"widget": "monetary","display_currency": "website.pricelist_id.currency_id"}'></strong>
</h3>
</td>
<td>   </td>
</tr>
</tbody>
</table>
</section>
</template>
<template id="quote_status">