[imp] added delete payment line
authorniv-openerp <nicolas.vanhoren@openerp.com>
Mon, 19 Dec 2011 13:17:50 +0000 (14:17 +0100)
committerniv-openerp <nicolas.vanhoren@openerp.com>
Mon, 19 Dec 2011 13:17:50 +0000 (14:17 +0100)
bzr revid: nicolas.vanhoren@openerp.com-20111219131750-ts70x8ng44grf63g

addons/point_of_sale/static/src/css/pos.css
addons/point_of_sale/static/src/js/pos.js
addons/point_of_sale/static/src/xml/pos.xml

index 4b2ecf5..56f0e44 100644 (file)
@@ -16,7 +16,7 @@
     border-spacing: 0;
     border-collapse: collapse;
 }
-.point-of-sale td { 
+.point-of-sale td {
     border: 1px solid #e9eaec;
 }
 .point-of-sale input {
index 32924ce..bb859ad 100644 (file)
@@ -882,7 +882,9 @@ openerp.point_of_sale = function(db) {
         start: function () {
             this.$element.addClass('paymentline');
             $('input', this.$element).keyup(_.bind(this.changeAmount, this));
+            $('.delete-payment-line', this.$element).click(this.on_delete);
         },
+        on_delete: function() {},
         changeAmount: function(event) {
             var newAmount;
             newAmount = event.currentTarget.value;
@@ -929,6 +931,7 @@ openerp.point_of_sale = function(db) {
         bindPaymentLineEvents: function() {
             this.currentPaymentLines = (this.shop.get('selectedOrder')).get('paymentLines');
             this.currentPaymentLines.bind('add', this.addPaymentLine, this);
+            this.currentPaymentLines.bind('remove', this.render_element, this);
             this.currentPaymentLines.bind('all', this.updatePaymentSummary, this);
         },
         bindOrderLineEvents: function() {
@@ -946,18 +949,19 @@ openerp.point_of_sale = function(db) {
             var x = new PaymentlineWidget(null, {
                     model: newPaymentLine
                 });
+            x.on_delete.add(_.bind(this.deleteLine, this, x));
             x.appendTo(this.paymentLineList());
         },
         render_element: function() {
             this.paymentLineList().empty();
             this.currentPaymentLines.each(_.bind( function(paymentLine) {
-                var x = new PaymentlineWidget(null, {
-                    model: paymentLine
-                });
-                this.paymentLineList().append(x);
+                this.addPaymentLine(paymentLine);
             }, this));
             this.updatePaymentSummary();
         },
+        deleteLine: function(lineWidget) {
+               this.currentPaymentLines.remove([lineWidget.model]);
+        },
         updatePaymentSummary: function() {
             var currentOrder, dueTotal, paidTotal, remaining, remainingAmount;
             currentOrder = this.shop.get('selectedOrder');
index 424506f..c040855 100644 (file)
         </td>
         <td class="paymentline-amount pos-rigth-align">
             <input type="text" t-att-value="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>
     </t>
     <t t-name="pos-payment-button-template">