|
@@ -1,12 +1,12 @@
|
|
|
function invoice_today_counters (widget) {
|
|
|
"use strict";
|
|
|
|
|
|
- var model= openerp;
|
|
|
+ var model = openerp;
|
|
|
|
|
|
widget.InvoiceTodayCountersWidget = widget.Base.extend({
|
|
|
template: 'InvoiceTodayCounters',
|
|
|
- irModelData:[],
|
|
|
- accountInvoice:[],
|
|
|
+ irModelData: [],
|
|
|
+ accountInvoice: [],
|
|
|
|
|
|
events: {
|
|
|
'click a': 'showCustomers',
|
|
@@ -22,7 +22,7 @@ function invoice_today_counters (widget) {
|
|
|
var self = this;
|
|
|
self.fetchInitial();
|
|
|
},
|
|
|
- fetchInitial: function(){
|
|
|
+ fetchInitial: function() {
|
|
|
var self = this;
|
|
|
self.$el.find('#morosidad').block({
|
|
|
message: null,
|
|
@@ -31,38 +31,40 @@ function invoice_today_counters (widget) {
|
|
|
}
|
|
|
});
|
|
|
self.$el.find('.widget-content.widget-loading').css('display','flex');
|
|
|
+
|
|
|
self.fetchAccountInvoice().then(function (accountInvoice) {
|
|
|
return accountInvoice;
|
|
|
}).then(function (accountInvoice) {
|
|
|
self.accountInvoice=accountInvoice;
|
|
|
return self.fetchGetModelId();
|
|
|
- }).then(function(irModelData){
|
|
|
+ }).then(function(irModelData) {
|
|
|
self.irModelData=irModelData;
|
|
|
return self.fetchReduceInvoice(self.accountInvoice);
|
|
|
});
|
|
|
},
|
|
|
// 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');
|
|
|
|
|
|
- getObtjectReference('account', 'invoice_form').then(function(results){
|
|
|
+ getObtjectReference('account', 'invoice_form').then(function(results) {
|
|
|
defer.resolve(results);
|
|
|
});
|
|
|
+
|
|
|
return defer;
|
|
|
},
|
|
|
// Invoice
|
|
|
fetchAccountInvoice: function() {
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
|
- var hoy =moment().format('YYYY-MM-DD');
|
|
|
+ var hoy = moment().format('YYYY-MM-DD');
|
|
|
var fields = ['id', 'residual'];
|
|
|
var domain = [['type', '=', 'out_invoice'], ['state', 'in', ['open','paid']], ['date_invoice', '=', hoy]];
|
|
|
var accountInvoice = new model.web.Model('account.invoice');
|
|
|
|
|
|
- accountInvoice.query(fields).filter(domain).all().then(function (results){
|
|
|
+ accountInvoice.query(fields).filter(domain).all().then(function (results) {
|
|
|
defer.resolve(results);
|
|
|
});
|
|
|
|
|
@@ -73,26 +75,24 @@ function invoice_today_counters (widget) {
|
|
|
var fecha = new Date();
|
|
|
var cat = 0;
|
|
|
|
|
|
- if (accountInvoice.length > 0){
|
|
|
+ if (accountInvoice.length > 0) {
|
|
|
cat = accountInvoice.length;
|
|
|
}
|
|
|
|
|
|
self.$el.find('.widget-content.widget-loading').css('display','none');
|
|
|
self.$el.find('.widget-content').find('a').text(accounting.formatNumber(cat, ".", ","));
|
|
|
- // self.$el.find('.widget-footer').find('span').text("Facturas Creadas en "+ fecha.getDate() + "/" + (fecha.getMonth() + 1) + "/" + fecha.getFullYear());
|
|
|
self.$el.find('#morosidad').unblock();
|
|
|
},
|
|
|
showCustomers: function (e) {
|
|
|
- var self= this;
|
|
|
+ var self = this;
|
|
|
if (self.accountInvoice.length === 0) {
|
|
|
model.web.notification.do_warn("Atención","Sin datos");
|
|
|
return
|
|
|
}
|
|
|
- var hoy =moment().format('YYYY-MM-DD');
|
|
|
-
|
|
|
+ var hoy = moment().format('YYYY-MM-DD');
|
|
|
|
|
|
this.do_action({
|
|
|
- name:"Facturas realizadas hoy",
|
|
|
+ name: "Facturas realizadas hoy",
|
|
|
type: 'ir.actions.act_window',
|
|
|
res_model: "account.invoice",
|
|
|
views: [[false, 'list'],[self.irModelData[1],'form']],
|