|
@@ -67,7 +67,7 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
|
|
|
fetchProductProduct: function () {
|
|
|
var defer = $.Deferred();
|
|
|
- var fields=['id','name','product_tmpl_id','attribute_str'];
|
|
|
+ var fields=['id','name','product_tmpl_id','attribute_str','default_code','ean13'];
|
|
|
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){
|
|
@@ -76,6 +76,14 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
return defer;
|
|
|
},
|
|
|
|
|
|
+ valorNull:function(dato){
|
|
|
+ var valor ="";
|
|
|
+ if (dato){
|
|
|
+ valor=dato;
|
|
|
+ }
|
|
|
+ return valor;
|
|
|
+ },
|
|
|
+
|
|
|
getTemplate : function(id){
|
|
|
var self = this;
|
|
|
return _.filter(self.ProductTemplate, function(item){
|
|
@@ -111,15 +119,15 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
});
|
|
|
self.$('#productSearch').autocomplete({
|
|
|
source: results,
|
|
|
- minLength:3,
|
|
|
- // response: function (e, ui){
|
|
|
- // if (ui.content instanceof Array && ui.content.length === 1) {
|
|
|
- // selectProduct = ui.content[0];
|
|
|
- // $(this).autocomplete("close");
|
|
|
- // $(this).val('');
|
|
|
- // self.factInsert(selectProduct);
|
|
|
- // }
|
|
|
- // },
|
|
|
+ minLength:4,
|
|
|
+ response: function (e, ui){
|
|
|
+ if (ui.content instanceof Array && ui.content.length === 1) {
|
|
|
+ selectProduct = ui.content[0];
|
|
|
+ $(this).autocomplete("close");
|
|
|
+ $(this).val('');
|
|
|
+ self.factInsert(selectProduct);
|
|
|
+ }
|
|
|
+ },
|
|
|
select: function (e, ui) {
|
|
|
$(this).val('');
|
|
|
selectProduct = ui.item;
|
|
@@ -131,13 +139,22 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
var results = self.ProductProduct;
|
|
|
results = _.map(results, function (item) {
|
|
|
return {
|
|
|
- label: item.name + ' (' + item.attribute_str + ')',
|
|
|
- value: item.id + ' - '+ item.name + '-' + item.attribute_str
|
|
|
- }
|
|
|
+ label: '[ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' (' + self.valorNull(item.attribute_str) + ')',
|
|
|
+ value: item.id + ' - '+ item.name + ' (' + item.attribute_str + ')'
|
|
|
+ }
|
|
|
});
|
|
|
- self.$('#productSearch').autocomplete({
|
|
|
+ $('#productSearch').autocomplete({
|
|
|
source: results,
|
|
|
minLength: 3,
|
|
|
+ response: function (e, ui){
|
|
|
+ if (ui.content instanceof Array && ui.content.length === 1) {
|
|
|
+ selectProduct = ui.content[0];
|
|
|
+ $(this).autocomplete("close");
|
|
|
+ $(this).val('');
|
|
|
+ self.factInsertProduct(selectProduct);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
select: function (e, ui) {
|
|
|
$(this).val('');
|
|
|
selectProduct = ui.item;
|
|
@@ -172,6 +189,7 @@ openerp.eiru_sale_order = function (instance, local) {
|
|
|
|
|
|
factInsertProduct:function(selectProduct){
|
|
|
var self = this;
|
|
|
+ console.log(selectProduct);
|
|
|
var product = selectProduct.value.split('-');
|
|
|
var variant = self.getProductProduct(product[0]);
|
|
|
var qty = 1;
|