|
@@ -17,23 +17,9 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
},
|
|
|
start: function () {
|
|
|
var self = this;
|
|
|
- this.$el.click(function (e) {
|
|
|
+ this.$el.click(function () {
|
|
|
self.fecthInitial();
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
|
|
|
fecthInitial: function(){
|
|
@@ -50,12 +36,6 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
}).then(function(ProductProduct){
|
|
|
self.ProductProduct = ProductProduct;
|
|
|
self.inicializarBuscador();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
});
|
|
|
return false;
|
|
|
},
|
|
@@ -72,7 +52,6 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
},
|
|
|
|
|
|
fetchProductTemplate: function () {
|
|
|
- var self = this;
|
|
|
var defer = $.Deferred();
|
|
|
var fields=['id','name','curva'];
|
|
|
var domain=[['active','=', true],['product_website_sale_type','=', true]];
|
|
@@ -123,15 +102,12 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
self.$('#productSearch').autocomplete({
|
|
|
source: results,
|
|
|
minLength:3,
|
|
|
- search: function(event, ui) {
|
|
|
+ search: function() {
|
|
|
if (!(self.$('#productSearch').val())){
|
|
|
self.factInsert();
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- select: function(event, ui) {
|
|
|
+ select: function() {
|
|
|
self.factInsert();
|
|
|
}
|
|
|
});
|
|
@@ -139,44 +115,31 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
|
|
|
factInsert:function(){
|
|
|
var self = this;
|
|
|
- var defer = $.Deferred();
|
|
|
- var data = [];
|
|
|
var product = this.$el.find('#productSearch').val().split('-');
|
|
|
- var productproduct = self.ProductProduct;
|
|
|
var template = self.getTemplate(product[0]);
|
|
|
var variant = self.getProduct(product[0]);
|
|
|
template = template[0].curva.split(',');
|
|
|
var qty = 0;
|
|
|
var contador = 0;
|
|
|
- var results;
|
|
|
-
|
|
|
for (var i = 0; i < variant.length; i++) {
|
|
|
qty = template[contador];
|
|
|
contador += 1;
|
|
|
-
|
|
|
-
|
|
|
self.joinSaleLine(variant[i].id, qty).then(function(results) {
|
|
|
return results;
|
|
|
- }).then(function(results){
|
|
|
+ }).then(function(){
|
|
|
self.reloadLine();
|
|
|
-
|
|
|
-
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
- if (contador == template.length) {
|
|
|
+ if (contador === template.length) {
|
|
|
contador = 0;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
|
|
|
-
|
|
|
joinSaleLine: function(product_id, qty) {
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
|
var sale = new openerp.web.Model('sale.order');
|
|
|
- sale.call('join_payslip_faults',[
|
|
|
+ sale.call('join_sale_lines',[
|
|
|
{
|
|
|
id: self.sale[0].id,
|
|
|
product_id: product_id,
|