|
@@ -0,0 +1,94 @@
|
|
|
|
+openerp.eiru_payslip_utility = function(instance, local) {
|
|
|
|
+
|
|
|
|
+ local.widgetInstance = null;
|
|
|
|
+ local.parentInstance = null;
|
|
|
|
+
|
|
|
|
+ local.PayslipUtilityWidget = instance.Widget.extend({
|
|
|
|
+ template: 'eiru_payslip_utility.PayslipWidget',
|
|
|
|
+ id: undefined,
|
|
|
|
+ //
|
|
|
|
+ init: function(parent) {
|
|
|
|
+ this._super(parent);
|
|
|
|
+ this.buttons = parent.$buttons;
|
|
|
|
+ },
|
|
|
|
+ start: function() {
|
|
|
|
+ var self = this;
|
|
|
|
+ this.$el.click(function() {
|
|
|
|
+ // console.log(instance.web.num2word(1000000));
|
|
|
|
+ // self.fectchInitial()
|
|
|
|
+ });
|
|
|
|
+ // self.buttons.click(function(e) {
|
|
|
|
+ // /* E (Editar) */
|
|
|
|
+ // if (e.target.accessKey === 'E')
|
|
|
|
+ // self.$el.css('display','none');
|
|
|
|
+ // /* C (Crear) */
|
|
|
|
+ // if (e.target.accessKey === 'C')
|
|
|
|
+ // self.$el.css('display','none');
|
|
|
|
+ // /* S (Guarrdar) */
|
|
|
|
+ // if (e.target.accessKey === 'S')
|
|
|
|
+ // self.$el.css('display','flex');
|
|
|
|
+ // /* D (Cancelar) */
|
|
|
|
+ // if (e.target.accessKey === 'D')
|
|
|
|
+ // self.$el.css('display','flex');
|
|
|
|
+ // });
|
|
|
|
+ },
|
|
|
|
+ updateId: function(id) {
|
|
|
|
+ var self = this;
|
|
|
|
+ self.id = id;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // fectchInitial: function() {
|
|
|
|
+ // var self = this;
|
|
|
|
+ // self.fectchGenerateNomina().then(function(payslip) {
|
|
|
|
+ // return payslip;
|
|
|
|
+ // }).then(function(payslip) {
|
|
|
|
+ // local.parentInstance.reload();
|
|
|
|
+ // if (!payslip)
|
|
|
|
+ // instance.web.notification.do_warn("Atención","No existe nomina para ser generada, en el periodo seleccionado");
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
+ // fectchGenerateNomina: function() {
|
|
|
|
+ // var self = this;
|
|
|
|
+ // var defer = $.Deferred();
|
|
|
|
+ // var hr_payslip = new instance.web.Model('hr.payslip');
|
|
|
|
+ //
|
|
|
|
+ // hr_payslip.call('generate_payroll_eiru',[self.id], {
|
|
|
|
+ // context: new instance.web.CompoundContext()
|
|
|
|
+ // }).then(function(results) {
|
|
|
|
+ // defer.resolve(results);
|
|
|
|
+ // });
|
|
|
|
+ // return defer;
|
|
|
|
+ // },
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (instance.web && instance.web.FormView) {
|
|
|
|
+ instance.web.FormView.include({
|
|
|
|
+ load_record: function(record) {
|
|
|
|
+ this._super.apply(this, arguments);
|
|
|
|
+
|
|
|
|
+ if (this.model !== 'hr.payslip')
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ local.parentInstance = this;
|
|
|
|
+
|
|
|
|
+ if (local.widgetInstance) {
|
|
|
|
+ local.widgetInstance.updateId(record.id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.$el.find('.payslip-utility').length !== 0 )
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ local.widgetInstance = new local.PayslipUtilityWidget(this);
|
|
|
|
+
|
|
|
|
+ var elemento = this.$el.find('.oe_form_sheet.oe_form_sheet_width');
|
|
|
|
+
|
|
|
|
+ elemento.find('.oe_right.oe_button_box').css('width','auto !important');
|
|
|
|
+ elemento = elemento.find('.oe_right.oe_button_box.eiru-payslip-utility');
|
|
|
|
+
|
|
|
|
+ local.widgetInstance.appendTo(elemento);
|
|
|
|
+ local.widgetInstance.updateId(record.id);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+}
|