Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1313 Zobrazení

Js file  it dose not display the button in  pos 

 odoo.define('point_of_sale.pos_create_bo_2', function (require) {
var _t = instance.web._t;
var QWeb = instance.web.qweb;

var round_di = instance.web.round_decimals;
var round_pr = instance.web.round_precision;

instance.point_of_sale.ProductScreenWidget = instance.point_of_sale.ProductScreenWidget.extend({
init: function() {
this._super.apply(this, arguments);
},
start:function(){
var self = this;
this._super();
// on récupère le pos
pos = self.pos;
picking_type_id = pos.config.picking_type_id[0];
console.log(picking_type_id);

selectedOrder = self.pos.get('selectedOrder');
console.log('selectedOrder: '+selectedOrder);
function DO_Stuff(customer_id, orderLines, mylocation_id, picking_type_id, commentaire, montanttaxes) {
(new instance.web.Model('stock.picking')).get_func('create_back_order')(orderLines, customer_id, mylocation_id, picking_type_id, commentaire, montanttaxes)
.pipe(_.bind(function(res) {
if (res) {
for (i = 0; i <= currentOrderLines.length + 1; i++) {
currentOrderLines.each(_.bind(function(item) {
selectedOrder.removeOrderline(item);
}, this));
}
for (i = 0; i <= currentOrderLines.length + 1; i++) {
currentOrderLines.each(_.bind(function(item) {
selectedOrder.removeOrderline(item);
}, this));
}
selectedOrder.set_client();
var res_mess = _t('Bon de retour créé: ' + res[0] + '');

var error_dialog = new instance.web.Dialog(this, {
size: 'medium',
buttons: [{text: _t("Close"), click: function() { error_dialog.$el.modal('hide'); }}],
}).open();
error_dialog.$el.append('' + res_mess + '');
return;
}
else {
return alert('Une erreur est survenue pendant la création du bon de retour !');
}
}, self));
}
$("#create_bo").click(function() {
selectedOrder = pos.get('selectedOrder');
console.log('total taxes'+ selectedOrder.getTax());
totaltaxes = selectedOrder.getTax();
currentOrderLines = selectedOrder.get('orderLines');
orderLines = [];
currentOrderLines.each(_.bind(function(item) {
return orderLines.push(item.export_as_JSON());
}, this));

var customer_id = selectedOrder.get_client() && selectedOrder.get_client().id || '';
// on récupère du stock de destination
mylocation_id = 19;

if (orderLines.length === 0) {
return alert('Veuillez choisir un produit !');
}
if (!customer_id) {
return alert('Veuillez choisir un client !');
}
var error_dialog = new instance.web.Dialog(this, {
size: 'medium',
buttons: [{text: _t("Valider"), click: function() { var commentaire = document.getElementById('txtcom').value; DO_Stuff(customer_id, orderLines, mylocation_id, picking_type_id, commentaire, totaltaxes); error_dialog.$el.modal('hide'); }}],
}).open();
error_dialog.$el.append('

Commentaire:
');
return;
});
},
});
});

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
srp 23
2041
0
lis 23
1844
1
zář 23
1621
1
čvc 23
2353
1
čvc 23
1712