|
@@ -6,11 +6,12 @@ openerp.eiru_payslip_generator = function(instance, local) {
|
|
local.PayslipGeneratorWidget = instance.Widget.extend({
|
|
local.PayslipGeneratorWidget = instance.Widget.extend({
|
|
template: 'eiru_payslip_generator.PayslipWidget',
|
|
template: 'eiru_payslip_generator.PayslipWidget',
|
|
id: undefined,
|
|
id: undefined,
|
|
-
|
|
|
|
|
|
+ /* Init */
|
|
init: function(parent) {
|
|
init: function(parent) {
|
|
this._super(parent);
|
|
this._super(parent);
|
|
this.buttons = parent.$buttons;
|
|
this.buttons = parent.$buttons;
|
|
},
|
|
},
|
|
|
|
+ /* start */
|
|
start: function() {
|
|
start: function() {
|
|
var self = this;
|
|
var self = this;
|
|
this.$el.click(function() {
|
|
this.$el.click(function() {
|
|
@@ -31,35 +32,34 @@ openerp.eiru_payslip_generator = function(instance, local) {
|
|
self.$el.css('display','flex');
|
|
self.$el.css('display','flex');
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ /* Update ID Hr run*/
|
|
updateId: function(id) {
|
|
updateId: function(id) {
|
|
var self = this;
|
|
var self = this;
|
|
self.id = id;
|
|
self.id = id;
|
|
|
|
+ if (!self.id)
|
|
|
|
+ self.$el.css('display','none');
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+ /* Funtion init*/
|
|
fectchInitial: function() {
|
|
fectchInitial: function() {
|
|
var self = this;
|
|
var self = this;
|
|
|
|
|
|
- self.$el.find('.eiru-generador').attr("disabled", true);
|
|
|
|
|
|
+ self.$el.attr("disabled", true);
|
|
self.fectchGenerateNomina().then(function(payslip) {
|
|
self.fectchGenerateNomina().then(function(payslip) {
|
|
return payslip;
|
|
return payslip;
|
|
}).then(function(payslip) {
|
|
}).then(function(payslip) {
|
|
local.parentInstance.reload();
|
|
local.parentInstance.reload();
|
|
if (!payslip)
|
|
if (!payslip)
|
|
instance.web.notification.do_warn("Atención","No existe nomina para ser generada, en el periodo seleccionado")
|
|
instance.web.notification.do_warn("Atención","No existe nomina para ser generada, en el periodo seleccionado")
|
|
- self.$el.find('.eiru-generador').removeAttr("disabled");
|
|
|
|
|
|
+ self.$el.removeAttr("disabled");
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ /* Generate Payslip */
|
|
fectchGenerateNomina: function() {
|
|
fectchGenerateNomina: function() {
|
|
var self = this;
|
|
var self = this;
|
|
- var defer = $.Deferred();
|
|
|
|
var hr_payslip = new instance.web.Model('hr.payslip');
|
|
var hr_payslip = new instance.web.Model('hr.payslip');
|
|
-
|
|
|
|
- hr_payslip.call('generate_payroll_eiru',[self.id], {
|
|
|
|
|
|
+ return hr_payslip.call('generate_payroll_eiru',[self.id], {
|
|
context: new instance.web.CompoundContext()
|
|
context: new instance.web.CompoundContext()
|
|
- }).then(function(results) {
|
|
|
|
- defer.resolve(results);
|
|
|
|
});
|
|
});
|
|
- return defer;
|
|
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
|
|
@@ -72,18 +72,17 @@ openerp.eiru_payslip_generator = function(instance, local) {
|
|
return;
|
|
return;
|
|
|
|
|
|
local.parentInstance = this;
|
|
local.parentInstance = this;
|
|
-
|
|
|
|
- if (local.widgetInstance) {
|
|
|
|
|
|
+ if (local.widgetInstance){
|
|
local.widgetInstance.updateId(record.id);
|
|
local.widgetInstance.updateId(record.id);
|
|
|
|
+ if (this.$el.find('.eiru-generador').length !== 0 )
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
- if (this.$el.find('.eiru-payslip').length !== 0 )
|
|
|
|
|
|
+ if (this.$el.find('.eiru-generador').length !== 0 )
|
|
return;
|
|
return;
|
|
|
|
|
|
local.widgetInstance = new local.PayslipGeneratorWidget(this);
|
|
local.widgetInstance = new local.PayslipGeneratorWidget(this);
|
|
-
|
|
|
|
- var elemento = this.$el.find('.oe_form_sheet.oe_form_sheet_width');
|
|
|
|
- elemento = elemento.find('.oe_right.oe_button_box.eiru-payslip-generator');
|
|
|
|
|
|
+ var elemento = this.$el.find('.oe_form').find('.eiru-payslip-generator');
|
|
|
|
|
|
local.widgetInstance.appendTo(elemento);
|
|
local.widgetInstance.appendTo(elemento);
|
|
local.widgetInstance.updateId(record.id);
|
|
local.widgetInstance.updateId(record.id);
|