Commit b705e2e6 by François C.

#4665 Clear payment lines if return to POS products screen

parent 3d3c67e2
......@@ -25,7 +25,7 @@
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
# for the full list
'category': 'POS',
'version': '0.0.1',
'version': '0.0.2',
# any module necessary for this one to work correctly
'depends': ['base', 'point_of_sale'],
......
......@@ -40,9 +40,21 @@ odoo.define('lacagette_custom_pos.DB', function(require) {
}
});
/* Custom behavior on barcode error */
/* Custom behavior on barcode error and return to products*/
var popups = require('point_of_sale.popups');
var gui = require('point_of_sale.gui');
let payment_this = null;
let empty_payments_lines = function(self) {
// Every payment line is removed (partially taken from odoo/addons/point_of_sale/static/src/js/screens.js)
// payment_this is initialized during screens.PaymentScreenWidget.start()
var lines = payment_this.pos.get_order().get_paymentlines();
for ( var i = 0; i < lines.length; i++ ) {
payment_this.pos.get_order().remove_paymentline(lines[i]);
payment_this.reset_input();
payment_this.render_paymentlines();
}
}
// Custom popup definition
var CustomErrorBarcodePopupWidget = popups.extend({
......@@ -64,6 +76,18 @@ odoo.define('lacagette_custom_pos.DB', function(require) {
});
gui.define_popup({name:'custom-error-barcode', widget: CustomErrorBarcodePopupWidget});
var CustomReturnToOrderMessageWidget = popups.extend({
template:'CustomReturnToOrderMessageWidget',
show: function(options) {
var self = this;
this._super(options);
this.$('.return-to-order').off('click').click(function(){
empty_payments_lines()
self.gui.show_screen("products");
});
}
});
gui.define_popup({name:'custom-return-to-order', widget: CustomReturnToOrderMessageWidget});
var screens = require('point_of_sale.screens');
......@@ -112,6 +136,19 @@ odoo.define('lacagette_custom_pos.DB', function(require) {
}
}
})
/** Init payment screen **/
screens.PaymentScreenWidget.include({
start: function() {
var self = this;
payment_this = self;
$('.payment-screen .top-content .back').off();
$(document).on('click', '.payment-screen .top-content .back', function(event){
self.gui.show_popup('custom-return-to-order');
});
empty_payments_lines();
}
})
/* Make search input loose focus after 5s without a key press */
screens.ProductCategoriesWidget.include({
......
......@@ -25,4 +25,24 @@
</div>
</div>
</div>
<div t-name="CustomReturnToOrderMessageWidget">
<div class="modal-dialog">
<div class="popup popup-return-warning">
<p class="title">
Attention !
</p>
<p class="body">
Les paiements seront réinitialisés si vous retournez au panier.
</p>
<div class="footer">
<div class="button cancel">
Annuler
</div>
<div class="button return-to-order">
Retour au panier
</div>
</div>
</div>
</div>
</div>
</template>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment