Nómina - Borrar en lote
This commit is contained in:
parent
f9f80a52e7
commit
f28ab95b50
|
@ -6398,27 +6398,30 @@ class CfdiNomina(BaseModel):
|
|||
return cls._stamp(cls)
|
||||
|
||||
@classmethod
|
||||
def remove(cls, id):
|
||||
obj = CfdiNomina.get(CfdiNomina.id==id)
|
||||
if obj.uuid:
|
||||
return False
|
||||
def remove(cls, ids):
|
||||
ids = util.loads(ids)
|
||||
for id in ids:
|
||||
obj = CfdiNomina.get(CfdiNomina.id==id)
|
||||
if obj.uuid:
|
||||
continue
|
||||
with database_proxy.transaction():
|
||||
q = CfdiNominaDetalle.delete().where(CfdiNominaDetalle.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaTotales.delete().where(CfdiNominaTotales.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaPercepciones.delete().where(CfdiNominaPercepciones.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaDeducciones.delete().where(CfdiNominaDeducciones.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaOtroPago.delete().where(CfdiNominaOtroPago.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaHorasExtra.delete().where(CfdiNominaHorasExtra.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaIncapacidad.delete().where(CfdiNominaIncapacidad.cfdi==obj)
|
||||
q.execute()
|
||||
obj.delete_instance()
|
||||
|
||||
q = CfdiNominaDetalle.delete().where(CfdiNominaDetalle.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaTotales.delete().where(CfdiNominaTotales.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaPercepciones.delete().where(CfdiNominaPercepciones.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaDeducciones.delete().where(CfdiNominaDeducciones.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaOtroPago.delete().where(CfdiNominaOtroPago.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaHorasExtra.delete().where(CfdiNominaHorasExtra.cfdi==obj)
|
||||
q.execute()
|
||||
q = CfdiNominaIncapacidad.delete().where(CfdiNominaIncapacidad.cfdi==obj)
|
||||
q.execute()
|
||||
|
||||
return bool(obj.delete_instance())
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def get_xml(cls, id):
|
||||
|
|
|
@ -296,17 +296,25 @@ function cmd_nomina_without_stamp_click(){
|
|||
|
||||
|
||||
function cmd_nomina_delete_click(){
|
||||
var row = $$('grid_nomina').getSelectedItem()
|
||||
var rows = $$('grid_nomina').getSelectedItem()
|
||||
|
||||
if (row == undefined){
|
||||
msg = 'Selecciona un registro'
|
||||
if (rows == undefined){
|
||||
msg = 'Selecciona al menos un registro'
|
||||
msg_error(msg)
|
||||
return
|
||||
}
|
||||
var ids = []
|
||||
if(Array.isArray(rows)){
|
||||
for(var i in rows){
|
||||
ids.push(rows[i].id)
|
||||
}
|
||||
}else{
|
||||
ids.push(rows.id)
|
||||
}
|
||||
|
||||
msg = '¿Estás seguro de eliminar el registro?<BR><BR>'
|
||||
msg += row['empleado'] + ' (' + row['fecha_pago'] + ')'
|
||||
msg += '<BR><BR>ESTA ACCIÓN NO SE PUEDE DESHACER<BR><BR>'
|
||||
msg = '¿Estás seguro de eliminar los recibos seleccionado?<BR><BR>'
|
||||
msg += 'ESTA ACCIÓN NO SE PUEDE DESHACER<BR><BR>'
|
||||
msg += 'Solo se eliminan recibos no timbrados'
|
||||
webix.confirm({
|
||||
title: 'Eliminar Nomina',
|
||||
ok: 'Si',
|
||||
|
@ -315,18 +323,18 @@ function cmd_nomina_delete_click(){
|
|||
text: msg,
|
||||
callback:function(result){
|
||||
if (result){
|
||||
delete_nomina(row['id'])
|
||||
delete_nomina(ids)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function delete_nomina(id){
|
||||
webix.ajax().del('/nomina', {id: id}, function(text, xml, xhr){
|
||||
var msg = 'Registro eliminado correctamente'
|
||||
function delete_nomina(ids){
|
||||
webix.ajax().del('/nomina', {id: ids}, function(text, xml, xhr){
|
||||
var msg = 'Registros eliminados correctamente'
|
||||
if (xhr.status == 200){
|
||||
$$('grid_nomina').remove(id);
|
||||
get_nomina()
|
||||
msg_ok(msg)
|
||||
} else {
|
||||
msg = 'No se pudo eliminar.'
|
||||
|
|
Loading…
Reference in New Issue