|
@@ -2,6 +2,7 @@ function expired_account_counters_now (widget) {
|
|
|
"use strict";
|
|
|
|
|
|
var model = openerp;
|
|
|
+ var Qweb = openerp.web.qweb;
|
|
|
|
|
|
widget.ExpiredAccountCountersNowWidget = widget.Base.extend({
|
|
|
template: 'ExpiredAccountCountersNow',
|
|
@@ -9,6 +10,8 @@ function expired_account_counters_now (widget) {
|
|
|
moveLine : [],
|
|
|
resCompany : [],
|
|
|
resCompany :[],
|
|
|
+ modelId:[],
|
|
|
+
|
|
|
events: {
|
|
|
'click a': 'showCustomers',
|
|
|
'click h2': 'showCustomers',
|
|
@@ -45,10 +48,25 @@ function expired_account_counters_now (widget) {
|
|
|
self.resCompany=resCompany;
|
|
|
return self.fetchResCurrecy(resCompany);
|
|
|
}).then(function(resCurrecy){
|
|
|
- self.resCompany= resCurrecy;
|
|
|
+ self.resCurrecy= resCurrecy;
|
|
|
+ return self.fetchGetModelId();
|
|
|
+ }).then(function(modelId){
|
|
|
+ self.modelId = modelId;
|
|
|
return self.fetchReduceMoveLine();
|
|
|
});
|
|
|
},
|
|
|
+ // getModelId
|
|
|
+ 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('account', 'invoice_form')).then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
// Partner
|
|
|
fetchPartner: function () {
|
|
|
var self = this;
|
|
@@ -71,7 +89,7 @@ function expired_account_counters_now (widget) {
|
|
|
var move_id = _.flatten(_.map(partner, function (map) {
|
|
|
return map.unreconciled_aml_ids
|
|
|
}));
|
|
|
- var field = ['id', 'partner_id', 'amount_residual', 'credit', 'debit', 'date_maturity'];
|
|
|
+ var field = ['id', 'partner_id', 'amount_residual', 'credit', 'debit', 'date_maturity', 'invoice','ref'];
|
|
|
var domain = [['credit', '<=', 0], ['id', 'in', move_id], ['date_maturity', '=', hoy]];
|
|
|
var moveLine = new model.web.Model('account.move.line');
|
|
|
|
|
@@ -115,7 +133,7 @@ function expired_account_counters_now (widget) {
|
|
|
fetchReduceMoveLine: function () {
|
|
|
var self = this;
|
|
|
var residual =0;
|
|
|
- var moneda =self.resCompany.shift();
|
|
|
+ var moneda =self.resCurrecy.shift();
|
|
|
var company = _.map(self.resCompany, function(map){
|
|
|
return map.currency_id[1];
|
|
|
});
|
|
@@ -141,18 +159,76 @@ function expired_account_counters_now (widget) {
|
|
|
},
|
|
|
showCustomers: function (e) {
|
|
|
var self = this;
|
|
|
- var hoy =moment().format('YYYY-MM-DD');
|
|
|
- var move_id = _.flatten(_.map(self.moveLine, function (map) {
|
|
|
- return map.id;
|
|
|
- }));
|
|
|
+ if (self.moveLine.length <= 0)
|
|
|
+ return
|
|
|
+
|
|
|
+ var moneda = self.resCurrecy.shift();
|
|
|
+ var newmoveLine=[];
|
|
|
+ newmoveLine = self.moveLine;
|
|
|
+ var titleData=[
|
|
|
+ {
|
|
|
+ title:"Deudas con vencimiento en el día de hoy"
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ var headerModal=[
|
|
|
+ {
|
|
|
+ title:"Cliente"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title:"Numero de Factura"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title:"Vencimiento"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title:"Monto "
|
|
|
+ }
|
|
|
+ ];
|
|
|
+
|
|
|
+ var modal = Qweb.render('ExpiredAccountCountersModal', {
|
|
|
+ data : newmoveLine,
|
|
|
+ dataThead : headerModal,
|
|
|
+ modalTitle :titleData
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.openerp_webclient_container').after(modal);
|
|
|
+ $('.expired-account-modal').modal()
|
|
|
+ $('.expired-account-modal').on('hidden.bs.modal', function (e) {
|
|
|
+ self.removeModal(e);
|
|
|
+ })
|
|
|
+
|
|
|
+ var contenido = $('.expired-account-modal').find('.table-tbody');
|
|
|
+ contenido.click(function (e) {
|
|
|
+ $(contenido).find('tr').removeClass('table-row-select');
|
|
|
+ $(e.target).closest('tr').addClass('table-row-select');
|
|
|
+ var chirdren_id =$(e.target).closest('tr').children()[0].textContent;
|
|
|
+ self.renderForm(chirdren_id);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // Remover <Modal></Modal>
|
|
|
+ removeModal: function (e) {
|
|
|
+ $('.expired-account-modal').remove()
|
|
|
+ $('.modal-backdrop').remove()
|
|
|
+ },
|
|
|
+ // Llamar form
|
|
|
+ renderForm: function(id){
|
|
|
+ var self= this;
|
|
|
+
|
|
|
+ id = parseInt(id)
|
|
|
+
|
|
|
+ // if (!id) return
|
|
|
+
|
|
|
this.do_action({
|
|
|
- name:"Listado de clientes por cobrar hoy",
|
|
|
- type: 'ir.actions.act_window',
|
|
|
- res_model: "res.partner",
|
|
|
- views: [[false, 'list']],
|
|
|
- target: 'new',
|
|
|
- domain: [['unreconciled_aml_ids', 'in', move_id]],
|
|
|
- context: {},
|
|
|
+ // name : "factura",
|
|
|
+ type : "ir.actions.act_window",
|
|
|
+ res_model : "account.invoice",
|
|
|
+ views : [[self.modelId[1], 'form']],
|
|
|
+ target : 'current',
|
|
|
+ domain : [['id', '=', id]],
|
|
|
+ context : {},
|
|
|
+ res_id : id,
|
|
|
+ }).then(function(){
|
|
|
+ self.removeModal();
|
|
|
});
|
|
|
}
|
|
|
});
|