|
@@ -85,7 +85,7 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
|
|
|
fetchProductProduct: function () {
|
|
|
var defer = $.Deferred();
|
|
|
- var fields=['id','name','product_tmpl_id','attribute_str','default_code','ean13'];
|
|
|
+ var fields=['id','name','product_tmpl_id','attribute_str','default_code','ean13','attribute_value_ids'];
|
|
|
var domain=[['active','=', true],['sale_ok','=', true]];
|
|
|
var ProductProduct = new instance.web.Model('product.product');
|
|
|
ProductProduct.query(fields).filter(domain).order_by('id').all().then(function(results){
|
|
@@ -125,7 +125,6 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
|
|
|
inicializarBuscador: function () {
|
|
|
var self = this;
|
|
|
- // console.log(self.saleLine);
|
|
|
var selectProduct;
|
|
|
var searchType = $('#SearchByCurve').is(":checked");
|
|
|
if(searchType){
|
|
@@ -138,7 +137,7 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
});
|
|
|
self.$('#productSearch').autocomplete({
|
|
|
source: results,
|
|
|
- minLength:4,
|
|
|
+ minLength:3,
|
|
|
response: function (e, ui){
|
|
|
if (ui.content instanceof Array && ui.content.length === 1) {
|
|
|
selectProduct = ui.content[0];
|
|
@@ -164,7 +163,7 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
});
|
|
|
$('#productSearch').autocomplete({
|
|
|
source: results,
|
|
|
- minLength: 4,
|
|
|
+ minLength: 3,
|
|
|
response: function (e, ui){
|
|
|
if (ui.content instanceof Array && ui.content.length === 1) {
|
|
|
selectProduct = ui.content[0];
|
|
@@ -192,10 +191,11 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
template = template[0].curva.split(',');
|
|
|
var qty = 0;
|
|
|
var contador = 0;
|
|
|
+
|
|
|
for (var i = 0; i < variant.length; i++) {
|
|
|
qty = template[contador];
|
|
|
contador += 1;
|
|
|
- self.joinSaleLine(variant[i].id, qty).then(function(results) {
|
|
|
+ self.createSaleLine(variant[i].id, qty).then(function(results) {
|
|
|
return results;
|
|
|
}).then(function(){
|
|
|
self.reloadLine();
|
|
@@ -212,60 +212,23 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
var product = selectProduct.value.split('-');
|
|
|
var variant = self.getProductProduct(product[0]);
|
|
|
var qty = 1;
|
|
|
-
|
|
|
- for (var i = 0; i < line.length; i++) {
|
|
|
- if(variant[0].id == line[i].product_id[0]){
|
|
|
- qty = line[i].product_uom_qty + 1;
|
|
|
- console.log(line[i].product_uom_qty);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- self.updateSaleLine(variant[0].id, qty).then(function(results) {
|
|
|
- return results;
|
|
|
- }).then(function(){
|
|
|
- self.reloadLine();
|
|
|
- });
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // self.createSaleLine(variant[0].id, qty).then(function(results) {
|
|
|
- // return results;
|
|
|
- // }).then(function(){
|
|
|
- // self.reloadLine();
|
|
|
- // });
|
|
|
+ self.createSaleLine(variant[0].id, qty).then(function(results) {
|
|
|
+ return results;
|
|
|
+ }).then(function(){
|
|
|
+ self.reloadLine();
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
createSaleLine: function(product_id, qty) {
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
|
var sale = new openerp.web.Model('sale.order');
|
|
|
- sale.call('join_sale_lines',[
|
|
|
- {
|
|
|
+ sale.call('join_sale_lines',[{
|
|
|
id: self.sale[0].id,
|
|
|
product_id: product_id,
|
|
|
product_uom_qty: qty
|
|
|
- }
|
|
|
- ], {
|
|
|
- context: new openerp.web.CompoundContext()
|
|
|
- }).then(function(results) {
|
|
|
- defer.resolve(results);
|
|
|
- });
|
|
|
- return defer;
|
|
|
- },
|
|
|
-
|
|
|
- updateSaleLine: function(id, qty) {
|
|
|
- var self = this;
|
|
|
- var defer = $.Deferred();
|
|
|
-
|
|
|
- var sale_line = new openerp.web.Model('sale.order');
|
|
|
- sale_line.call('update_sale_order_lines',[
|
|
|
- {
|
|
|
- id: self.sale[0].id,
|
|
|
- product_uom_qty: qty
|
|
|
- }
|
|
|
- ],{
|
|
|
+ }],
|
|
|
+ {
|
|
|
context: new openerp.web.CompoundContext()
|
|
|
}).then(function(results) {
|
|
|
defer.resolve(results);
|