|
@@ -1,13 +1,13 @@
|
|
|
function missing_product (widget) {
|
|
|
"use strict";
|
|
|
|
|
|
- var model= openerp;
|
|
|
+ var model = openerp;
|
|
|
|
|
|
widget.MissingProductWidget = widget.Base.extend({
|
|
|
template: 'MissingProduct',
|
|
|
- stockQuant:[],
|
|
|
- productProduct:[],
|
|
|
- modelId:[],
|
|
|
+ stockQuant: [],
|
|
|
+ productProduct: [],
|
|
|
+ modelId: [],
|
|
|
|
|
|
events: {
|
|
|
'click a': 'showCustomers',
|
|
@@ -15,7 +15,7 @@ function missing_product (widget) {
|
|
|
},
|
|
|
init: function (parent) {
|
|
|
this._super(parent, {
|
|
|
- width : 3,
|
|
|
+ width: 3,
|
|
|
height: 2
|
|
|
});
|
|
|
},
|
|
@@ -33,51 +33,55 @@ function missing_product (widget) {
|
|
|
});
|
|
|
self.$el.find('.widget-content.widget-loading').css('display','flex');
|
|
|
// Iniciar Consultas
|
|
|
- self.fetchProductProduct().then(function(productProduct){
|
|
|
+ self.fetchProductProduct().then(function(productProduct) {
|
|
|
return productProduct;
|
|
|
- }).then(function(productProduct){
|
|
|
+ }).then(function(productProduct) {
|
|
|
self.productProduct = productProduct;
|
|
|
return self.fetchGetModelId();
|
|
|
- }).then(function(modelId){
|
|
|
+ }).then(function(modelId) {
|
|
|
self.modelId = modelId;
|
|
|
return self.fetchReduceProduct();
|
|
|
});
|
|
|
},
|
|
|
// getModelId
|
|
|
- fetchGetModelId: function(){
|
|
|
+ fetchGetModelId: function() {
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
|
var irModelData = new model.web.Model('ir.model.data');
|
|
|
var getObtjectReference = irModelData.get_func('get_object_reference');
|
|
|
|
|
|
- this.alive(getObtjectReference('product', 'product_normal_form_view')).then(function(results){
|
|
|
+ this.alive(getObtjectReference('product', 'product_normal_form_view')).then(function(results) {
|
|
|
defer.resolve(results);
|
|
|
});
|
|
|
+
|
|
|
return defer;
|
|
|
},
|
|
|
- fetchProductProduct : function(stockQaunt){
|
|
|
+ fetchProductProduct : function(stockQaunt) {
|
|
|
var self = this;
|
|
|
- var defer =$.Deferred();
|
|
|
- var product_id = _.map(stockQaunt,function(map){return map.product_id[0]});
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var product_id = _.map(stockQaunt,function(map) {
|
|
|
+ return map.product_id[0];
|
|
|
+ });
|
|
|
var fields = ['id', 'name_template', 'qty_available'];
|
|
|
- var domain =[['qty_available', '<=', 0],['type', '=', 'product'],['active','=',true]];
|
|
|
+ var domain = [['qty_available', '<=', 0],['type', '=', 'product'],['active','=',true]];
|
|
|
var productProduct = new model.web.Model('product.product');
|
|
|
- productProduct.query(fields).filter(domain).all().then(function(results){
|
|
|
+ productProduct.query(fields).filter(domain).all().then(function(results) {
|
|
|
defer.resolve(results);
|
|
|
});
|
|
|
+
|
|
|
return defer;
|
|
|
},
|
|
|
// // Reduce Move line
|
|
|
fetchReduceProduct: function () {
|
|
|
var self = this;
|
|
|
var cantidad;
|
|
|
- cantidad= _.countBy(_.map(self.productProduct,function(map){
|
|
|
- return map.id;
|
|
|
- }),function(num){
|
|
|
- return num ? 'even': 'odd';
|
|
|
- });
|
|
|
+ cantidad = _.countBy(_.map(self.productProduct,function(map) {
|
|
|
+ return map.id;
|
|
|
+ }),function(num) {
|
|
|
+ return num ? 'even': 'odd';
|
|
|
+ });
|
|
|
|
|
|
- if (!cantidad.even){
|
|
|
+ if (!cantidad.even) {
|
|
|
cantidad = {};
|
|
|
cantidad.even = 0;
|
|
|
}
|
|
@@ -93,7 +97,7 @@ function missing_product (widget) {
|
|
|
return
|
|
|
}
|
|
|
this.do_action({
|
|
|
- name:"Listado de productos faltan-tes",
|
|
|
+ name: "Listado de productos faltan-tes",
|
|
|
type: 'ir.actions.act_window',
|
|
|
res_model: "product.product",
|
|
|
views: [[false, 'list'],[self.modelId[1],'form']],
|