[FIX] point_of_sale: payment screen widget now works ok

bzr revid: fva@openerp.com-20120522103225-n4r03smsocyv0rrn
This commit is contained in:
Frédéric van der Essen
2012-05-22 12:32:25 +02:00
parent 785100c74c
commit a06edf236d
3 changed files with 13 additions and 14 deletions
@@ -696,9 +696,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.pos_widget.order_widget.set_numpad_state(null);
this.pos_widget.payment_screen.set_numpad_state(null);
},
paymentLineList: function() {
return this.$element.find('#paymentlines');
},
back: function() {
this.pos_widget.screen_selector.set_current_screen('products');
},
@@ -724,6 +721,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.currentOrderLines.bind('all', this.updatePaymentSummary, this);
},
change_selected_order: function() {
console.log('change_selected_order');
this.currentPaymentLines.unbind();
this.bindPaymentLineEvents();
this.currentOrderLines.unbind();
@@ -731,15 +729,16 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.renderElement();
},
addPaymentLine: function(newPaymentLine) {
console.log('addPaymentLine:',newPaymentLine);
var x = new module.PaymentlineWidget(null, {
model: newPaymentLine
payment_line: newPaymentLine
});
x.on_delete.add(_.bind(this.deleteLine, this, x));
x.appendTo(this.paymentLineList());
x.appendTo(this.$('#paymentlines'));
},
renderElement: function() {
this._super();
this.paymentLineList().empty();
this.$('#paymentlines').empty();
this.currentPaymentLines.each(_.bind( function(paymentLine) {
this.addPaymentLine(paymentLine);
}, this));
@@ -247,8 +247,8 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
template: 'PaymentlineWidget',
init: function(parent, options) {
this._super(parent,options);
this.model = options.model;
this.model.bind('change', this.changedAmount, this);
this.payment_line = options.payment_line;
this.payment_line.bind('change', this.changedAmount, this);
},
on_delete: function() {},
changeAmount: function(event) {
@@ -256,18 +256,18 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
newAmount = event.currentTarget.value;
if (newAmount && !isNaN(newAmount)) {
this.amount = parseFloat(newAmount);
this.model.set({
this.payment_line.set({
amount: this.amount,
});
}
},
changedAmount: function() {
if (this.amount !== this.model.get('amount'))
if (this.amount !== this.payment_line.get('amount'))
this.renderElement();
},
renderElement: function() {
this.amount = this.model.get('amount');
this.name = this.model.get('journal_id')[1];
this.name = this.payment_line.get('journal_id')[1];
this._super();
$('input', this.$element).keyup(_.bind(this.changeAmount, this));
$('.delete-payment-line', this.$element).click(this.on_delete);
},
+2 -2
View File
@@ -382,10 +382,10 @@
<t t-name="PaymentlineWidget">
<tr class="paymentline">
<td class="paymentline-type">
<t t-esc="name"/>
<t t-esc="widget.name"/>
</td>
<td class="paymentline-amount pos-right-align">
<input type="text" t-att-value="amount.toFixed(2)" />
<input type="text" t-att-value="widget.payment_line.get('amount').toFixed(2)" />
<a href='javascript:void(0)' class='delete-payment-line'><img src="/point_of_sale/static/src/img/search_reset.gif" /></a>
</td>
</tr>