Merge lp:~inddiana/diana-addons/imp_he_biostar into lp:diana-addons/6.0
- imp_he_biostar
- Merge into trunk-2
Proposed by
Mauricio Jose Sanchez Puerta
Status: | Merged |
---|---|
Merged at revision: | 21 |
Proposed branch: | lp:~inddiana/diana-addons/imp_he_biostar |
Merge into: | lp:diana-addons/6.0 |
Diff against target: |
988 lines (+281/-173) 8 files modified
diana_integracion_biostar/model/horas_extras.py (+130/-69) diana_integracion_biostar/view/horas_extras_view.xml (+4/-0) diana_integracion_biostar/wizard/consultar_retardos_view.xml (+8/-0) diana_integracion_biostar/wizard/consultar_retardos_wizard.py (+47/-30) diana_integracion_biostar/wizard/export_biostar.py (+1/-8) diana_integracion_biostar/wizard/horas_extras_execpcion_wizard.py (+7/-4) diana_integracion_biostar/wizard/horas_marcaje_wizard.py (+14/-9) diana_integracion_biostar/wizard/horas_retardo_wizard.py (+70/-53) |
To merge this branch: | bzr merge lp:~inddiana/diana-addons/imp_he_biostar |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Aristóbulo Meneses | Pending | ||
Review via email: mp+183699@code.launchpad.net |
Commit message
Description of the change
cambiado todos los read por browse en los archivos horas_marcaje_
para evitar errores en memoria
To post a comment you must log in.
- 76. By Mauricio Sanchez <email address hidden>
-
eliminado todos los print
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'diana_integracion_biostar/model/horas_extras.py' |
2 | --- diana_integracion_biostar/model/horas_extras.py 2013-05-13 11:40:26 +0000 |
3 | +++ diana_integracion_biostar/model/horas_extras.py 2013-09-03 16:22:03 +0000 |
4 | @@ -145,13 +145,15 @@ |
5 | _description = 'horas_extra' |
6 | _columns = { |
7 | 'empleado_id': fields.many2one('hr.employee', 'Trabajador', required=True), |
8 | - 'fecha': fields.date('Fecha', required=True,), |
9 | + #~ 'fecha': fields.date('Fecha', required=True,), |
10 | 'state': fields.selection([('draft','Borrardor'), ('confirmed','Confirmado'),('revised','Revisado'), ('exception','Excepcion'), ('done','Listo'), ('cancel','Cancelado')],'Estado', readonly=True), |
11 | - 'hora_desde': fields.time('Hora desde', required=False, readonly=True, states={'draft':[('readonly',False)]}), |
12 | - 'hora_hasta': fields.time('Hora hasta', required=True, readonly=True, states={'draft':[('readonly',False)]}), |
13 | + #~ 'hora_desde': fields.time('Hora desde', required=False, readonly=True, states={'draft':[('readonly',False)]}), |
14 | + 'hora_desde': fields.datetime('Hora desde', required=False, readonly=True, states={'draft':[('readonly',False)]}), |
15 | + #~ 'hora_hasta': fields.time('Hora hasta', required=True, readonly=True, states={'draft':[('readonly',False)]}), |
16 | + 'hora_hasta': fields.datetime('Hora hasta', required=True, readonly=True, states={'draft':[('readonly',False)]}), |
17 | 'horas_extras_id': fields.many2one('horas.extras', 'Horas extra',readonly=True, required=True), |
18 | - 'hora_marcaje_entrada': fields.time('Hora de marcaje entrada', readonly=True), |
19 | - 'hora_marcaje': fields.time('Hora de marcaje', readonly=True), |
20 | + 'hora_marcaje_entrada': fields.datetime('Hora de marcaje entrada', readonly=True), |
21 | + 'hora_marcaje': fields.datetime('Hora de marcaje salida', readonly=True), |
22 | 'create_uid': fields.integer('create uid'), |
23 | 'observacion': fields.text('Observacion', readonly=True), |
24 | } |
25 | @@ -162,8 +164,8 @@ |
26 | } |
27 | |
28 | |
29 | - |
30 | def _check_fecha(self, cr, uid, ids, context=None): |
31 | + formato = '%Y-%m-%d %H:%M:%S' |
32 | hel_brw = self.browse(cr, uid, ids)[0] |
33 | periodos_brw = hel_brw.horas_extras_id.concepto_id.hr_process_id.hr_period_ids |
34 | payment_calendar_id = hel_brw.empleado_id.hr_payroll_id.hr_payment_calendar_id.id |
35 | @@ -171,8 +173,10 @@ |
36 | for i in periodos: |
37 | perid_obj = self.pool.get('hr.period') |
38 | brw = perid_obj.browse(cr, uid, i.id-1) |
39 | - if hel_brw.fecha <= brw.date_end and hel_brw.fecha >= brw.date_start: |
40 | - return True |
41 | + date = datetime.datetime.strptime(hel_brw.hora_desde, formato) |
42 | + fecha = date.strftime(formato[0:8]) |
43 | + if fecha <= brw.date_end and fecha >= brw.date_start: |
44 | + return True |
45 | |
46 | return False |
47 | |
48 | @@ -180,12 +184,26 @@ |
49 | hel_brw = self.browse(cr, uid, ids) |
50 | for i in hel_brw: |
51 | if i.hora_desde: |
52 | - if datetime.datetime.strptime(i.hora_hasta, "%H:%M:%S") <= datetime.datetime.strptime(i.hora_desde, "%H:%M:%S"): |
53 | + if datetime.datetime.strptime(i.hora_hasta, "%Y-%m-%d %H:%M:%S") <= datetime.datetime.strptime(i.hora_desde, "%Y-%m-%d %H:%M:%S"): |
54 | return False |
55 | - return True |
56 | + return True |
57 | + |
58 | + def _check_sobretiempo(self, cr, uid, ids, conetxt=None): |
59 | + formato = '%Y-%m-%d %H:%M:%S' |
60 | + hel_brw = self.browse(cr, uid, ids) |
61 | + for i in hel_brw: |
62 | + dif = abs(datetime.datetime.strptime(i.hora_hasta, formato) - datetime.datetime.strptime(i.hora_desde, formato)) |
63 | + hours = dif.days * 24 |
64 | + if hours > 24 : |
65 | + return False |
66 | + return True |
67 | + |
68 | + |
69 | |
70 | - _constraints = [(_check_fecha,'La fecha no pertenece al anterior periodo', ['fecha'])] |
71 | + _constraints = [(_check_fecha,'La fecha no pertenece al periodo anterior', ['hora_hasta'])] |
72 | _constraints = [(_check_hora,'La hora desde no puede ser mayor que la hora hasta', ['hora_desde'])] |
73 | + _constraints = [(_check_sobretiempo,'La difencia entre las horas no puede ser mayor de 24 horas', ['hora_desde'])] |
74 | + |
75 | |
76 | |
77 | |
78 | @@ -234,16 +252,18 @@ |
79 | ih = ids |
80 | |
81 | for i in t_brw: |
82 | - fh = i.fecha |
83 | ha = i.hora_hasta |
84 | hd = i.hora_desde |
85 | cod = i.empleado_id.cod_number |
86 | + fh_hasta = self.format_date(i.hora_hasta ) |
87 | + |
88 | |
89 | if hd: |
90 | - self.query2(cr, uid, i.id, cod, fh, hd, ha, t, ih, context = None) |
91 | + fh_desde = self.format_date(hd) |
92 | + self.query2(cr, uid, i.id, cod, fh_desde[0], fh_desde[1], fh_hasta[1], t, ih, fh_hasta[0],context = None) |
93 | |
94 | else: |
95 | - self.query(cr, uid, i.id, cod, fh, ha, t, ih, context = None) |
96 | + self.query(cr, uid, i.id, cod, fh_hasta[0], fh_hasta[1], t, ih, context = None) |
97 | |
98 | self.review(cr, uid, ids, context = None) |
99 | |
100 | @@ -275,7 +295,16 @@ |
101 | raise osv.except_osv('ERROR', "Fallo de conexión") |
102 | |
103 | |
104 | - |
105 | + def format_date(self, fecha): |
106 | + formato = '%Y-%m-%d %H:%M:%S' |
107 | + date = datetime.datetime.strptime(fecha, formato) |
108 | + hora = date.strftime(formato[9:]) |
109 | + fecha = date.strftime(formato[0:8]) |
110 | + return [fecha, hora] |
111 | + |
112 | + |
113 | + |
114 | + |
115 | def query(self, cr, uid, ids, cod, fh, hora_hasta, t, ids_horas_extras, context = None): |
116 | |
117 | """ |
118 | @@ -315,7 +344,7 @@ |
119 | raise osv.except_osv('ERROR',err) |
120 | |
121 | for row in rows: |
122 | - over = self.add_overtime(cr, uid, ids, row[0], hora_hasta, context = None) |
123 | + over = self.add_overtime(cr, uid, ids, row[0], hora_hasta, fh, context = None) |
124 | |
125 | self.write(cr, uid, ids_horas_extras, {'state': 'revised', }) |
126 | return True |
127 | @@ -324,7 +353,7 @@ |
128 | # sql nueva Funcion fue agregada para poder hacer validaciones |
129 | # contra el biometrico cuando existe informacion del campo hora_desde |
130 | |
131 | - def query2(self, cr, uid, ids, cod, fecha, hora_desde, hora_hasta, t, ih, context = None): |
132 | + def query2(self, cr, uid, ids, cod, fecha_inicio, hora_desde, hora_hasta, t, ih, fecha_fin, context = None): |
133 | |
134 | """ |
135 | Funcion para ejecutar la consulta en el BioStar si ahi una hora desde |
136 | @@ -346,10 +375,10 @@ |
137 | JOIN TB_READER AS READER ON EVENT.nReaderIdn = READER.nReaderIdn JOIN TB_EVENT_DATA AS E_DATA ON EVENT.nEventIdn = E_DATA.nEventIdn |
138 | JOIN TB_USER_CUSTOMINFO As C ON C.nUserIdn = U.nUserIdn |
139 | WHERE E_DATA.nEventIdn = 55 |
140 | - AND CONVERT(nVarchar(10), DATEADD(s, EVENT.nDateTime, '1970-01-01'), 20) = '%s' |
141 | + AND CONVERT(nVarchar(10), DATEADD(s, EVENT.nDateTime, '1970-01-01'), 20) BETWEEN '%s' and '%s' |
142 | AND READER.nReaderIdn IN %s |
143 | AND C.sFieldValue5 = %s |
144 | - """ %(fecha, t, cod) |
145 | + """ %(fecha_inicio, fecha_fin, t, cod) |
146 | |
147 | |
148 | cnx = self.conexion(cr, uid, ids, context = None) |
149 | @@ -365,7 +394,7 @@ |
150 | raise osv.except_osv('ERROR',err) |
151 | |
152 | for row in rows: |
153 | - validar = self.validar_horas(cr, uid, ids, row, hora_desde, hora_hasta, context=None) |
154 | + validar = self.validar_horas(cr, uid, ids, row, hora_desde, hora_hasta, fecha_inicio, fecha_fin, context=None) |
155 | |
156 | self.write(cr, uid, ih, {'state': 'revised', }) |
157 | |
158 | @@ -373,7 +402,7 @@ |
159 | #Esta funcion fue agregada el 09/05/2013 para hacer comparacion de horas |
160 | #si el campo hora_hasta posee datos |
161 | |
162 | - def validar_horas(self, cr, uid, ids, h_sql, h_desde, h_hasta, context = None): |
163 | + def validar_horas(self, cr, uid, ids, h_sql, h_desde, h_hasta, fecha_inicio, fecha_fin, context = None): |
164 | |
165 | """ |
166 | Función que valida si las horas del biostar son nulas, si la |
167 | @@ -391,6 +420,8 @@ |
168 | obhl_read = objhl.read(cr, uid, ids) |
169 | sts_now = obhl_read.get('state') |
170 | |
171 | + entrada = "%s %s"%(fecha_inicio, h_sql[0]) |
172 | + salida = "%s %s"%(fecha_fin, h_sql[1]) |
173 | |
174 | if sts_now != 'cancel' and sts_now != 'done': |
175 | |
176 | @@ -400,15 +431,15 @@ |
177 | return False |
178 | |
179 | elif self.unlike_hours(cr, uid, h_sql[0], h_desde) == False: |
180 | - objhl.write(cr, uid, ids, {'hora_marcaje_entrada': h_sql[0], 'hora_marcaje': h_sql[1], 'state': 'exception',}) |
181 | + objhl.write(cr, uid, ids, {'hora_marcaje_entrada': entrada, 'hora_marcaje': salida, 'state': 'exception',}) |
182 | return False |
183 | |
184 | elif self.unlike_hours(cr, uid, h_sql[1], h_hasta) == False: |
185 | - objhl.write(cr, uid, ids, {'hora_marcaje_entrada': h_sql[0], 'hora_marcaje': h_sql[1], 'state': 'exception',}) |
186 | + objhl.write(cr, uid, ids, {'hora_marcaje_entrada': entrada, 'hora_marcaje': salida, 'state': 'exception',}) |
187 | return False |
188 | |
189 | else: |
190 | - objhl.write(cr, uid, ids, {'hora_marcaje_entrada': h_sql[0], 'hora_marcaje': h_sql[1], 'state': 'done',}) |
191 | + objhl.write(cr, uid, ids, {'hora_marcaje_entrada': entrada, 'hora_marcaje': salida, 'state': 'done',}) |
192 | return True |
193 | |
194 | return True |
195 | @@ -416,7 +447,7 @@ |
196 | |
197 | |
198 | |
199 | - def add_overtime(self, cr, uid, ids, hr, ha, context = None): |
200 | + def add_overtime(self, cr, uid, ids, hr, ha, fecha, context = None): |
201 | """ |
202 | Función que valida si las horas del biostar son nulas, si la |
203 | diferencia de horas no sale del rango y cambio los estados |
204 | @@ -431,6 +462,7 @@ |
205 | obhl_read = objhl.read(cr, uid, ids) |
206 | sts_now = obhl_read.get('state') |
207 | |
208 | + formato = '%s %s' |
209 | if sts_now != 'cancel' and sts_now != 'done': |
210 | |
211 | if hr == None: |
212 | @@ -438,11 +470,11 @@ |
213 | return False |
214 | |
215 | elif self.unlike_hours(cr, uid, hr, ha) == False: |
216 | - objhl.write(cr, uid, ids, {'hora_marcaje': hr, 'state': 'exception',}) |
217 | + objhl.write(cr, uid, ids, {'hora_marcaje': formato%(fecha, hr), 'state': 'exception',}) |
218 | return False |
219 | |
220 | else: |
221 | - objhl.write(cr, uid, ids, {'hora_marcaje': hr, 'state': 'done',}) |
222 | + objhl.write(cr, uid, ids, {'hora_marcaje': formato%(fecha, hr), 'state': 'done',}) |
223 | return True |
224 | |
225 | def unlike_hours(self, cr, uid, hr, ha): |
226 | @@ -493,6 +525,9 @@ |
227 | def convert_hours(self, hours): |
228 | return datetime.datetime.strptime(hours, '%H:%M:%S') |
229 | |
230 | + def convert_datetime(self, date): |
231 | + return datetime.datetime.strptime(date, '%Y-%m-%d %H:%M:%S') |
232 | + |
233 | def turn_validate(self, date, h): |
234 | """ |
235 | Funcion que valida si estas dentro de tu horario |
236 | @@ -502,15 +537,15 @@ |
237 | @return False: si estas Fuera de tu turno |
238 | """ |
239 | hr = self.convert_hours(h) |
240 | - hr0 = self.convert_hours(date[0]) |
241 | - hr1 = self.convert_hours(date[1]) |
242 | - if hr1 > hr0: |
243 | - if hr >= hr0 and hr <= hr1: |
244 | + hr_entrada = self.convert_hours(date[0]) |
245 | + hr_salida = self.convert_hours(date[1]) |
246 | + if hr_salida > hr_entrada: |
247 | + if hr >= hr_entrada and hr <= hr_salida: |
248 | return True |
249 | else: |
250 | - if hr >= hr1 and hr >= hr0: |
251 | + if hr >= hr_salida and hr >= hr_entrada: |
252 | return True |
253 | - if hr <= hr0 and hr <= hr1: |
254 | + if hr <= hr_entrada and hr <= hr_salida: |
255 | return True |
256 | return False |
257 | |
258 | @@ -530,8 +565,7 @@ |
259 | return total |
260 | |
261 | |
262 | - |
263 | - |
264 | + |
265 | |
266 | def review(self, cr, uid, ids, context = None): |
267 | horas_extras = self.browse(cr, uid, ids) |
268 | @@ -540,10 +574,10 @@ |
269 | horas_extras_lineas = horas_extras[0].lineas_ids |
270 | |
271 | for i in horas_extras_lineas: |
272 | - fh = i.fecha |
273 | - ha = i.hora_hasta |
274 | + fh = self.format_date(i.hora_hasta ) |
275 | + ha = fh[1] |
276 | cod = i.empleado_id.cod_number |
277 | - date = self.get_date_year(fh, i.empleado_id.shift_id) |
278 | + date = self.get_date_year(fh[0], i.empleado_id.shift_id) |
279 | |
280 | |
281 | if self.turn_validate(date, ha): |
282 | @@ -555,6 +589,13 @@ |
283 | return False |
284 | |
285 | |
286 | + |
287 | + def search_schedule_concept(self, cr, uid, ids, objeto, hora): |
288 | + tur_id = objeto.search(cr, uid, ['&', ('hour_start','<=', hora) , ('hour_end','>=', hora)]) |
289 | + tur_brw = objeto.browse(cr, uid, tur_id)[0].concepto_id.id |
290 | + #~ tur_brw = objeto.browse(cr, uid, tur_id)[0].concepto_id.id |
291 | + return tur_brw |
292 | + |
293 | |
294 | |
295 | def ready(self, cr, uid, ids, context = None): |
296 | @@ -565,60 +606,75 @@ |
297 | |
298 | horas_extras_lineas = horas_extras[0].lineas_ids |
299 | variable_id = horas_extras[0].concepto_id.id |
300 | - |
301 | + args = "{'employee_id': employee_id, 'value': '', 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': ''}" |
302 | |
303 | |
304 | for i in horas_extras_lineas: |
305 | - fh = i.fecha |
306 | - ha = i.hora_hasta |
307 | + datos = self.format_date(i.hora_hasta) |
308 | + fh = datos[0] |
309 | + ha = datos[1] |
310 | hd = i.hora_desde |
311 | + |
312 | cod = i.empleado_id.cod_number |
313 | employee_id = i.empleado_id.id |
314 | date = self.get_date_year(fh, i.empleado_id.shift_id) |
315 | - |
316 | - |
317 | - if i.state == 'exception': |
318 | - raise osv.except_osv('ERROR', "No puedes insertar la linea si tienes lineas en execepcion") |
319 | - |
320 | - |
321 | - hora_markaje = self.convert_hours(ha) |
322 | + hora_turno_entrada = self.convert_hours(date[0]) # variable que tiene la hora real de entrada del trabajador en formato datetime.datetime |
323 | + hora_turno_salida = self.convert_hours(date[1]) # variable que tiene la hora de salida real del trabajador en formato datetime.datetime |
324 | tur_id = turn_obj.search(cr, uid, ['&', ('hour_start','<=', date[1]) , ('hour_end','>=', date[1])]) |
325 | - tur_brw = turn_obj.browse(cr, uid, tur_id) |
326 | + tur_brw = turn_obj.browse(cr, uid, tur_id)[0] |
327 | hora_ext_id = turn_obj.search(cr, uid, ['&', ('hour_start','<=', ha) , ('hour_end','>=', ha)]) |
328 | hora_ext_brw = turn_obj.browse(cr, uid, hora_ext_id) |
329 | + args = eval(args) |
330 | + |
331 | + if i.state == 'exception': |
332 | + raise osv.except_osv('ERROR', "No puedes insertar la linea si tienes lineas en execepcion") |
333 | |
334 | if hd: |
335 | + datos = self.format_date(hd) |
336 | + fd = datos[0] |
337 | + hd = datos[1] |
338 | hora_markaje_entrada = self.convert_hours(hd) |
339 | + hora_markaje_salida = self.convert_hours(ha) |
340 | hora_entrada_antes_id = turn_obj.search(cr, uid, ['&', ('hour_start','<=', hd) , ('hour_end','>=', hd)]) |
341 | - hora_entrada_antes_brw = turn_obj.browse(cr, uid, hora_entrada_antes_id) |
342 | - if hora_markaje_entrada < self.convert_hours(date[0]): |
343 | - dif = self.subtract_hours(hd, date[0], 3600) |
344 | + hora_entrada_antes_brw = turn_obj.browse(cr, uid, hora_entrada_antes_id)[0] |
345 | + |
346 | + dif = self.subtract_hours(hd, date[0], 3600) |
347 | + args['value'] = dif |
348 | + args['concept_id'] = hora_entrada_antes_brw.concepto_id.id |
349 | + |
350 | + if hora_markaje_entrada < hora_turno_entrada and fd == fh and hora_markaje_salida == hora_turno_salida: |
351 | + |
352 | if dif > 0: |
353 | - concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': hora_entrada_antes_brw[0].concepto_id.id} , context=None) |
354 | - |
355 | + concept_obj.create(cr, uid, args, context=None) |
356 | + self.write(cr, uid, ids, {'state': 'done', }) |
357 | + return True |
358 | + else: |
359 | + if dif > 0: |
360 | + concept_obj.create(cr, uid, args, context=None) |
361 | + |
362 | if not self.turn_validate(date, ha): #Valida que estes fuera de tu horario de trabajo |
363 | |
364 | - if hora_markaje > self.convert_hours(tur_brw[0].hour_end): |
365 | - dif1 = self.subtract_hours(tur_brw[0].hour_end, date[1], 3600) |
366 | - dif2 = self.subtract_hours(ha, tur_brw[0].hour_end, 3600) |
367 | + if hora_markaje_salida > self.convert_hours(tur_brw.hour_end): |
368 | + dif1 = self.subtract_hours(tur_brw.hour_end, date[1], 3600) |
369 | + dif2 = self.subtract_hours(ha, tur_brw.hour_end, 3600) |
370 | if dif1 > 0: |
371 | - concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif1, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': tur_brw[0].concepto_id.id} , context=None) |
372 | + concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif1, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': tur_brw.concepto_id.id} , context=None) |
373 | if dif2 > 0: |
374 | concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif2, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': hora_ext_brw[0].concepto_id.id} , context=None) |
375 | #~ return True |
376 | |
377 | - elif hora_markaje > self.convert_hours(date[1]) and hora_markaje < self.convert_hours(tur_brw[0].hour_end): |
378 | + elif hora_markaje_salida > self.convert_hours(date[1]) and hora_markaje_salida < self.convert_hours(tur_brw.hour_end): |
379 | dif = self.subtract_hours(ha, date[1], 3600) |
380 | if dif > 0: |
381 | concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': hora_ext_brw[0].concepto_id.id} , context=None) |
382 | #~ return True |
383 | |
384 | - elif hora_markaje < self.convert_hours(date[0]) : |
385 | - dif1 = self.subtract_hours(tur_brw[0].hour_end, date[1], 3600) |
386 | - dif2 = self.subtract_hours(tur_brw[0].hour_end, '23:59:59', 3600) |
387 | + elif hora_markaje_salida < self.convert_hours(date[0]) : |
388 | + dif1 = self.subtract_hours(tur_brw.hour_end, date[1], 3600) |
389 | + dif2 = self.subtract_hours(tur_brw.hour_end, '23:59:59', 3600) |
390 | dif3 = self.subtract_hours(ha, '00:00:00', 3600) |
391 | if dif1 > 0: |
392 | - concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif1, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': tur_brw[0].concepto_id.id} , context=None) |
393 | + concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif1, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': tur_brw.concepto_id.id} , context=None) |
394 | if dif2 > 0: |
395 | concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif2, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': hora_ext_brw[0].concepto_id.id} , context=None) |
396 | if dif3 > 0: |
397 | @@ -629,15 +685,18 @@ |
398 | |
399 | else: |
400 | if self.convert_hours(date[1]) > self.convert_hours(date[0]): |
401 | - dif1 = self.subtract_hours(tur_brw[0].hour_end, date[1], 3600) |
402 | - dif2 = self.subtract_hours(tur_brw[0].hour_end, '23:59:59', 3600) |
403 | + dif1 = self.subtract_hours(tur_brw.hour_end, date[1], 3600) |
404 | + dif2 = self.subtract_hours(tur_brw.hour_end, '23:59:59', 3600) |
405 | + conced1 = self.search_schedule_concept(cr, uid, ids, turn_obj, '23:59:59') |
406 | dif3 = self.subtract_hours(date[0], '00:00:00', 3600) |
407 | + conced2 = self.search_schedule_concept(cr, uid, ids, turn_obj, '00:00:00') |
408 | + |
409 | if dif1 > 0: |
410 | - concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif1, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': tur_brw[0].concepto_id.id} , context=None) |
411 | + concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif1, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': tur_brw.concepto_id.id} , context=None) |
412 | if dif2 > 0: |
413 | - concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif2, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': hora_ext_brw[0].concepto_id.id} , context=None) |
414 | + concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif2, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': conced1} , context=None) |
415 | if dif3 > 0: |
416 | - concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif3, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': hora_ext_brw[0].concepto_id.id} , context=None) |
417 | + concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif3, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': conced2} , context=None) |
418 | #~ return True |
419 | else: |
420 | tur_hourn_id = turn_obj.search(cr, uid, ['&', ('hour_start','>=', date[1]) , ('hour_end','<=', date[0])]) |
421 | @@ -648,7 +707,9 @@ |
422 | concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif1, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': tur_hourn_brw[0].concepto_id.id} , context=None) |
423 | if dif2 > 0: |
424 | concept_obj.create(cr, uid, {'employee_id': employee_id, 'value': dif2, 'payroll_id': False, 'variable_concept_id': variable_id , 'type': 'qty', 'concept_id': hora_ext_brw[0].concepto_id.id} , context=None) |
425 | - #~ return True |
426 | + #~ return True |
427 | + |
428 | + |
429 | |
430 | self.write(cr, uid, ids, {'state': 'done', }) |
431 | return True |
432 | |
433 | === modified file 'diana_integracion_biostar/view/horas_extras_view.xml' |
434 | --- diana_integracion_biostar/view/horas_extras_view.xml 2013-05-09 19:03:07 +0000 |
435 | +++ diana_integracion_biostar/view/horas_extras_view.xml 2013-09-03 16:22:03 +0000 |
436 | @@ -15,7 +15,9 @@ |
437 | <field name="lineas_ids" nolabel="1" colspan='4' attrs= "{'readonly':[('state','!=', 'draft')]}" > |
438 | <tree editable='top'> |
439 | <field name='empleado_id' domain="[('state', 'not in', ['borrador', 'egresado'])]" /> |
440 | +<!-- |
441 | <field name='fecha' /> |
442 | +--> |
443 | <field name='hora_desde'/> |
444 | <field name='hora_hasta'/> |
445 | <field name='hora_marcaje_entrada' /> |
446 | @@ -76,7 +78,9 @@ |
447 | <field name="arch" type="xml"> |
448 | <tree string="Lineas del las horas extra"> |
449 | <field name="empleado_id" select="1" /> |
450 | +<!-- |
451 | <field name="fecha" select="2" /> |
452 | +--> |
453 | <field name="hora_hasta" /> |
454 | <field name='state' /> |
455 | </tree> |
456 | |
457 | === modified file 'diana_integracion_biostar/wizard/consultar_retardos_view.xml' |
458 | --- diana_integracion_biostar/wizard/consultar_retardos_view.xml 2013-06-06 19:34:49 +0000 |
459 | +++ diana_integracion_biostar/wizard/consultar_retardos_view.xml 2013-09-03 16:22:03 +0000 |
460 | @@ -23,8 +23,16 @@ |
461 | <field name="view_mode">form</field> |
462 | <field name="target">new</field> |
463 | </record> |
464 | +<!-- |
465 | <menuitem name="PCP" id="consultar_marcaje" parent="hr.menu_hr_root" sequence="18" /> |
466 | +--> |
467 | +<!-- |
468 | <menuitem name="Consultar retardos" id="Consultar_marcaje_pcp" action="consultar_marcaje_next_action" parent="consultar_marcaje" sequence="18" /> |
469 | +--> |
470 | +<!-- |
471 | + <menuitem name="Consultar retardos" id="Consultar_marcaje_pcp" action="consultar_marcaje_next_action" parent="hr_holidays.menu_open_ask_holidays" sequence="25" /> |
472 | +--> |
473 | + <menuitem name="Consultar retardos" id="Consultar_marcaje_pcp" action="consultar_marcaje_next_action" parent="hr_holidays.menu_open_ask_holidays" sequence="25" /> |
474 | <record id="view_revisar_entrada_lineas_wizard" model="ir.ui.view"> |
475 | <field name="name">revisar.entrada.lineas.wizard.form</field> |
476 | <field name="model">revisar.entrada.lineas.wizard</field> |
477 | |
478 | === modified file 'diana_integracion_biostar/wizard/consultar_retardos_wizard.py' |
479 | --- diana_integracion_biostar/wizard/consultar_retardos_wizard.py 2013-07-01 19:17:55 +0000 |
480 | +++ diana_integracion_biostar/wizard/consultar_retardos_wizard.py 2013-09-03 16:22:03 +0000 |
481 | @@ -5,6 +5,7 @@ |
482 | import datetime |
483 | from datetime import timedelta |
484 | import time |
485 | +import calendar |
486 | |
487 | class revisar_entrada_wizard(osv.osv_memory): |
488 | _name = 'revisar.entrada.wizard' |
489 | @@ -33,7 +34,6 @@ |
490 | if context != None: |
491 | res = {'fecha_desde':context['fecha_desde'], 'fecha_hasta': context['fecha_hasta'], 'state':context['state'], 'mensaje':context['mensaje'],'revisar_line_ids':context['revisar_line_ids']} |
492 | else: |
493 | - #~ context = {} |
494 | res = {} |
495 | return res |
496 | |
497 | @@ -75,7 +75,10 @@ |
498 | |
499 | def consultar(self, cr, uid, ids, context=None): |
500 | data = self.read(cr, 1, ids)[0] |
501 | - con = self.conexion(cr, uid, ids, context=None) |
502 | + try: |
503 | + con = self.conexion(cr, uid, ids, context=None) |
504 | + except: |
505 | + raise osv.except_osv('ERROR', 'Conexion fallida' ) |
506 | cod = data['codigo'] |
507 | driver = self.reader_id(cr, uid, ids) |
508 | if driver: |
509 | @@ -83,7 +86,7 @@ |
510 | else: |
511 | raise osv.except_osv('ERROR', 'No existen capta huellas o no a seleccionado ninguno en la configuracion') |
512 | |
513 | - cod_id = self.pool.get('hr.employee').search(cr, uid, [('cod_number', '=', cod)]) |
514 | + cod_id = self.pool.get('hr.employee').search(cr, uid, [('cod_number', 'like', cod)]) |
515 | cod_obj = self.pool.get('hr.employee').browse(cr, uid, cod_id) |
516 | |
517 | try: |
518 | @@ -94,58 +97,72 @@ |
519 | |
520 | dia = datetime.datetime.now() |
521 | |
522 | - #~ dia = datetime.datetime(2013, 04, 30) |
523 | - |
524 | periodo = self.create_period(dia) |
525 | - |
526 | - |
527 | - periodo = [i for i in periodo if self.discount_case(cod_obj[0].shift_id, i)[0] != '00:00:00' and self.discount_case(cod_obj[0].shift_id, i)[1] != '00:00:00'] |
528 | - |
529 | - |
530 | - |
531 | fd = periodo[0] |
532 | fh = periodo[-1] |
533 | hmw_id = self.pool.get('revisar.entrada.wizard').create(cr, uid, {'fecha_desde': fd, 'fecha_hasta':fh}) |
534 | + date_end = "%s-%s-%s" %(dia.year, dia.month, calendar.monthrange(dia.year, dia.month)[1]) |
535 | + date_end = datetime.datetime.strptime(date_end, '%Y-%m-%d') |
536 | + periodo2 = self.create_period(date_end) |
537 | + |
538 | + |
539 | + periodo = [i for i in periodo if self.discount_case(cod_obj[0].shift_id, i)[0] != '00:00:00' and self.discount_case(cod_obj[0].shift_id, i)[1] != '00:00:00'] |
540 | + if not periodo: |
541 | + periodo2 = [i for i in periodo2 if self.discount_case(cod_obj[0].shift_id, i)[0] == '00:00:00' and self.discount_case(cod_obj[0].shift_id, i)[1] == '00:00:00'] |
542 | + periodo2 = str(periodo2) |
543 | + periodo2 = periodo2.replace('[', '') |
544 | + periodo2 = periodo2.replace(']', '') |
545 | + raise osv.except_osv('ERROR', 'El trabajador %s con codigo %s no labora en estas fechas del mes %s'%(cod, nombre, periodo2) ) |
546 | + |
547 | + |
548 | + #~ fd = periodo[0] |
549 | + #~ fh = periodo[-1] |
550 | + |
551 | |
552 | conex = con.cursor() |
553 | tol = 0 |
554 | |
555 | dia = dia.strptime(dia.strftime( '%H:%M:%S'), '%H:%M:%S') |
556 | date = self.discount_case(cod_obj[0].shift_id, dia.strftime("%Y-%m-%d")) |
557 | - #~ print date |
558 | - if dia < self.convert_hours(date[0]) + timedelta(minutes=15): |
559 | - |
560 | - h1 = self.convert_hours(date[0])+ timedelta(minutes=5) #esta es la hora normal de entrada a la que se adiciona 15 minutos |
561 | + if dia <= self.convert_hours(date[0]) + timedelta(minutes=15): |
562 | + h1 = self.convert_hours(date[0])+ timedelta(minutes=5) #esta es la hora normal de entrada a la que se adiciona 5 minutos |
563 | h2 = self.convert_hours(date[0])+ timedelta(minutes=15) #esta es la hora normal de entrada a la que se adiciona 15 minutos |
564 | sql = self.query(cod, fd, fh, driver) |
565 | - conex.execute(sql) |
566 | + try: |
567 | + conex.execute(sql) |
568 | + except: |
569 | + raise osv.except_osv('ERROR', 'Conexion fallida' ) |
570 | + |
571 | rows = conex.fetchall() |
572 | - if not rows: |
573 | - raise osv.except_osv('ERROR', 'El codigo %s perteneciente al trabajador no existe en el BioStar'%cod ) |
574 | for row in rows: |
575 | retardos = self.search_delays(row, h1, h2) |
576 | if retardos: |
577 | tol = tol +1 |
578 | crl = self.pool.get('revisar.entrada.lineas.wizard').create(cr, uid, {'hora':retardos[2], 'fecha':retardos[4],'codigo':cod,'nombre':nombre, 'capta_huella':retardos[0], 'tolerancia': tol,'horas_marcaje_id':hmw_id}) |
579 | - |
580 | - brw = self.pool.get('revisar.entrada.wizard').read(cr, 1, ids) |
581 | - brw_line = self.pool.get('revisar.entrada.lineas.wizard').read(cr, 1, ids) |
582 | - |
583 | + |
584 | + |
585 | + brw = self.pool.get('revisar.entrada.wizard').browse(cr, 1, ids)[0] |
586 | + brw_line = self.pool.get('revisar.entrada.lineas.wizard').browse(cr, 1, ids) |
587 | + |
588 | + cabecera = {'fecha_desde':brw.fecha_desde , 'revisar_line_ids': [i.id for i in brw.revisar_line_ids], 'fecha_hasta': brw.fecha_hasta, 'state': False, 'mensaje': False, 'id': brw.id} |
589 | |
590 | context.update({'active_id': hmw_id, 'active_model':'revisar.entrada.wizard'}) |
591 | context.update({'active_model':'revisar.entrada.wizard'}) |
592 | - context.update(brw[0]) |
593 | + context.update(cabecera) |
594 | + |
595 | |
596 | if tol >= 3: |
597 | context.update({'state':'denied'}) |
598 | context.update({'mensaje':'Acceso denegado por exceder su limite de tolerancias mensual'}) |
599 | else: |
600 | context.update({'state':'accepted'}) |
601 | - context.update({'mensaje':'usted ya posee %s tolerancia el maximo aceptado son 3 mensuales' %tol}) |
602 | + context.update({'mensaje':'usted posee %s tolerancia el maximo aceptado son 3 mensuales' %tol}) |
603 | |
604 | |
605 | - try: |
606 | - context.update(brw_line[0]) |
607 | + try: |
608 | + line = brw_line[0] |
609 | + lineas = {'hora':line.hora , 'tolerancia':line.tolerancia , 'fecha': line.fecha, 'capta_huella':line.capta_huella , 'horas_marcaje_id': line.horas_marcaje_id.id, 'nombre': line.nombre, 'codigo': line.codigo, 'id': line.id} |
610 | + context.update(lineas) |
611 | except: |
612 | pass |
613 | |
614 | @@ -154,8 +171,8 @@ |
615 | |
616 | |
617 | else: |
618 | - context.update({'fecha_desde': fd, 'fecha_hasta': fh, 'state':'denied' , 'mensaje': 'Acceso denegado a excedido la hora limite de entrada', 'revisar_line_ids':[]}) |
619 | - |
620 | + context.update({'fecha_desde': fd, 'fecha_hasta': fh, 'state':'denied' , 'mensaje': 'Acceso denegado ha excedido la hora limite de entrada', 'revisar_line_ids':[]}) |
621 | + #~ |
622 | |
623 | conex.close() |
624 | return { |
625 | @@ -170,7 +187,7 @@ |
626 | 'context': context, |
627 | #~ |
628 | } |
629 | - |
630 | + #~ |
631 | |
632 | |
633 | def reader_id(self, cr, uid, ids): |
634 | @@ -203,7 +220,6 @@ |
635 | def conexion(self, cr, uid, ids, context=None): |
636 | bio_obj = self.pool.get('horas.extras') |
637 | bio_conect = bio_obj.conexion(cr, uid, ids, context = None) |
638 | - #~ cursor = bio_conect.cursor() |
639 | return bio_conect |
640 | |
641 | def query(self, codigo, fecha_inicio, fecha_fin, captahuellas): |
642 | @@ -227,6 +243,7 @@ |
643 | def search_delays(self, row, h1, h2): |
644 | #~ consulta = [i for i in row if self.convert_hours(row[2]) >= self.convert_hours(h1) and self.convert_hours(row[2]) < self.convert_hours(h2)] |
645 | consulta = [i for i in row if self.convert_hours(row[2]) >= h1 and self.convert_hours(row[2]) < h2] |
646 | + |
647 | if consulta: |
648 | return consulta |
649 | |
650 | |
651 | === modified file 'diana_integracion_biostar/wizard/export_biostar.py' |
652 | --- diana_integracion_biostar/wizard/export_biostar.py 2013-06-21 19:07:53 +0000 |
653 | +++ diana_integracion_biostar/wizard/export_biostar.py 2013-09-03 16:22:03 +0000 |
654 | @@ -26,13 +26,11 @@ |
655 | idsw = [context['active_id']] |
656 | if len(context['active_ids']) > 1: |
657 | idsw = context['active_ids'] |
658 | - #~ print idsw |
659 | cod_obj = self.pool.get('hr.employee').browse(cr, uid, idsw) |
660 | for idt in cod_obj: |
661 | cod = idt.cod_number |
662 | nombre = idt.name |
663 | cedula = idt.identification_id |
664 | - #~ print cod, nombre, cedula |
665 | chk = self.user_check(cr, uid, ids, cod, context=None) |
666 | if chk == None: |
667 | pass |
668 | @@ -45,16 +43,13 @@ |
669 | raise osv.except_osv('ERROR', 'Conexion fallida') |
670 | |
671 | for row in rows: |
672 | - #~ print "consulata 1", row |
673 | id = int(row[0]) + 1 |
674 | - #~ print "id de sUserID",id |
675 | sql2 = sql2 %(nombre, id) |
676 | - #~ print sql2 |
677 | try: |
678 | conex.execute(sql2) |
679 | except: |
680 | raise osv.except_osv('ERROR', 'Conexion fallida') |
681 | - |
682 | + |
683 | conex.execute(sql3) |
684 | rows2 = conex.fetchall() |
685 | for row in rows2: |
686 | @@ -68,7 +63,6 @@ |
687 | raise osv.except_osv('ERROR', 'Conexion fallida') |
688 | |
689 | sql5 = sql5%id2 |
690 | - #~ print sql5 |
691 | try: |
692 | conex.execute(sql5) |
693 | except: |
694 | @@ -87,7 +81,6 @@ |
695 | def conexion(self, cr, uid, ids, context=None): |
696 | bio_obj = self.pool.get('horas.extras') |
697 | bio_conect = bio_obj.conexion(cr, uid, ids, context = None) |
698 | - #~ cursor = bio_conect.cursor() |
699 | return bio_conect |
700 | |
701 | def user_check(self, cr, uid, ids, codigo, context=None): |
702 | |
703 | === modified file 'diana_integracion_biostar/wizard/horas_extras_execpcion_wizard.py' |
704 | --- diana_integracion_biostar/wizard/horas_extras_execpcion_wizard.py 2013-05-13 11:40:26 +0000 |
705 | +++ diana_integracion_biostar/wizard/horas_extras_execpcion_wizard.py 2013-09-03 16:22:03 +0000 |
706 | @@ -9,8 +9,8 @@ |
707 | _name = 'horas.extras.execepcion.wizard' |
708 | _description = 'excepcion de horas extras lineas' |
709 | _columns = { |
710 | - 'hora_desde': fields.time('hora desde'), |
711 | - 'hora_hasta': fields.time('hora hasta'), |
712 | + 'hora_desde': fields.datetime('hora desde'), |
713 | + 'hora_hasta': fields.datetime('hora hasta'), |
714 | 'confirmar': fields.boolean('Modificar hora'), |
715 | 'observacion': fields.text('Observacion', required=True), |
716 | } |
717 | @@ -22,12 +22,15 @@ |
718 | |
719 | if data['confirmar'] == True: |
720 | |
721 | - if data['hora_desde']: |
722 | + if data['hora_desde'] and not data['hora_hasta']: |
723 | self.pool.get('horas.extras.lineas').write(cr, uid, idsw, {'hora_desde':data['hora_desde']}) |
724 | |
725 | - elif data['hora_hasta']: |
726 | + elif data['hora_hasta'] and not data['hora_desde']: |
727 | self.pool.get('horas.extras.lineas').write(cr, uid, idsw, {'hora_hasta':data['hora_hasta']}) |
728 | |
729 | + elif data['hora_desde'] and data['hora_hasta']: |
730 | + self.pool.get('horas.extras.lineas').write(cr, uid, idsw, {'hora_hasta':data['hora_hasta'], 'hora_desde':data['hora_desde']}) |
731 | + |
732 | else: |
733 | raise osv.except_osv('ERROR', "Debe especificar una hora ") |
734 | |
735 | |
736 | === modified file 'diana_integracion_biostar/wizard/horas_marcaje_wizard.py' |
737 | --- diana_integracion_biostar/wizard/horas_marcaje_wizard.py 2013-07-01 19:17:55 +0000 |
738 | +++ diana_integracion_biostar/wizard/horas_marcaje_wizard.py 2013-09-03 16:22:03 +0000 |
739 | @@ -51,8 +51,7 @@ |
740 | 'active_id': ids |
741 | } |
742 | |
743 | - |
744 | - |
745 | + |
746 | def search_hour(self, cr, uid, ids, context=None): |
747 | data = self.read(cr, 1, ids)[0] |
748 | idsw = [context['active_id']] |
749 | @@ -81,15 +80,21 @@ |
750 | rows = conex.execute(sql) |
751 | for row in rows: |
752 | crl = self.pool.get('horas.marcaje.lineas.wizard').create(cr, uid, {'hora':row[0], 'fecha':row[1],'codigo':row[3],'nombre':nombre, 'capta_huella':row[2], 'horas_marcaje_id':hmw_id}) |
753 | - brw = self.pool.get('horas.marcaje.wizard').read(cr, 1, ids) |
754 | - brw_line = self.pool.get('horas.marcaje.lineas.wizard').read(cr, 1, ids) |
755 | - |
756 | + brw = self.pool.get('horas.marcaje.wizard').browse(cr, 1, ids)[0] |
757 | + line = self.pool.get('horas.marcaje.lineas.wizard').browse(cr, 1, ids)[0] |
758 | + |
759 | + cabecera = {'fecha_desde':brw.fecha_desde , 'fecha_hasta': brw.fecha_hasta, 'h_line_ids':[i.id for i in brw.h_line_ids] , 'id': brw.id} |
760 | + |
761 | context.update({'active_id': hmw_id, 'active_model':'horas.marcaje.wizard'}) |
762 | context.update({'active_model':'horas.marcaje.wizard'}) |
763 | - context.update(brw[0]) |
764 | - |
765 | + context.update(cabecera) |
766 | + |
767 | + lineas = {'hora':line.hora , 'fecha':line.fecha , 'capta_huella':line.capta_huella, 'horas_marcaje_id':line.horas_marcaje_id.id , 'nombre': line.nombre, 'codigo': line.codigo, 'id': line.id} |
768 | + |
769 | + |
770 | + |
771 | try: |
772 | - context.update(brw_line[0]) |
773 | + context.update(lineas) |
774 | except: |
775 | raise osv.except_osv('ERROR', 'No existen marcajes en el perido desde %s hasta %s' %(fd, fh)) |
776 | |
777 | @@ -184,7 +189,7 @@ |
778 | 'model': 'horas.marcaje.wizard', |
779 | } |
780 | |
781 | - data = self.read(cr, uid, ids) |
782 | + data = self.read(cr, 1, ids) |
783 | data = data[0] |
784 | data.update(d) |
785 | |
786 | |
787 | === modified file 'diana_integracion_biostar/wizard/horas_retardo_wizard.py' |
788 | --- diana_integracion_biostar/wizard/horas_retardo_wizard.py 2013-06-21 19:07:53 +0000 |
789 | +++ diana_integracion_biostar/wizard/horas_retardo_wizard.py 2013-09-03 16:22:03 +0000 |
790 | @@ -37,7 +37,6 @@ |
791 | concepto_jornada_no_trabajda_id = data.get('concepto_no_trabjada') |
792 | concepto_horas_no_trabajadas_id = data.get('concepto_tiempo_no_trabajda') |
793 | |
794 | - #~ print concepto_id, jornada_no_trabajda, tiempo_no_trabajado |
795 | idsw = [context['active_id']] |
796 | |
797 | hrvc_linea_obj = self.pool.get('hr.variable.concept.line') |
798 | @@ -55,7 +54,7 @@ |
799 | raise osv.except_osv('ERROR', 'Error al crear Cursor') |
800 | |
801 | # PERIODO A BUSCAR PARA EL SQL |
802 | - hrvc_brw = hrvc_obj.browse(cr, uid, idsw) |
803 | + hrvc_brw = hrvc_obj.browse(cr, uid, idsw) |
804 | period_id = hrvc_brw[0].hr_process_id.hr_period_ids[0].id |
805 | fhp = self.pool.get('hr.period').browse(cr, uid, int(period_id -1)) |
806 | fh = [fhp.date_start, fhp.date_end] |
807 | @@ -76,48 +75,52 @@ |
808 | inicio = period2[0][0:8]+'01' |
809 | fin = datetime.datetime.strptime(period2[0], '%Y-%m-%d') - timedelta(days=1) |
810 | period1 = self.generate_period([inicio, fin.strftime('%Y-%m-%d')]) |
811 | - |
812 | - fecha_inicio = period1[0][0:8]+'01' |
813 | + |
814 | + fecha_inicio = period1[0] |
815 | fecha_fin = period2[-1] |
816 | periodo = period2 |
817 | - |
818 | - j = [] |
819 | - n = [] |
820 | + tolerancia = [] |
821 | + dias_trabajados = [] |
822 | retardos = [] |
823 | tiempo_no_laborado = [] |
824 | - asusencia = [] |
825 | + ausencia = [] |
826 | |
827 | |
828 | |
829 | for i in cod: |
830 | periodo = self.generate_valid_period(cr, uid, ids, i, periodo, hr_holidays_calendar) |
831 | - #~ print periodo, i |
832 | sql = self.query(i, fecha_inicio, fecha_fin, t) |
833 | cursor.execute(sql) |
834 | rows = cursor.fetchall() |
835 | - if not rows: |
836 | - raise osv.except_osv('ERROR', 'El codigo %s perteneciente al trabajador %s no existe en el BioStar'%(i, self.name_for_codnumber(cr, uid, ids, i)) ) |
837 | - for row in rows: |
838 | - n.append(row[-1]) |
839 | - d = self.descuento(cr, uid, ids, context, row, j, concepto_id, idsw, periodo, retardos, tiempo_no_laborado, concepto_horas_no_trabajadas_id, asusencia, concepto_jornada_no_trabajda_id) |
840 | - asu = self.absence(cr, uid, ids, context, n, periodo, concepto_jornada_no_trabajda_id, idsw, i, asusencia) |
841 | - j = [] |
842 | - n = [] |
843 | - retardos = [] |
844 | - tiempo_no_laborado = [] |
845 | - asusencia = [] |
846 | - |
847 | - |
848 | - if d[0]['value'] != 0: |
849 | - hrvc_linea_obj.create(cr, uid, d[0] , context=None) |
850 | - |
851 | - if d[1]['value'] != 0: |
852 | - hrvc_linea_obj.create(cr, uid, d[1] , context=None) |
853 | - |
854 | - |
855 | - if asu['value'] != 0: |
856 | - hrvc_linea_obj.create(cr, uid, asu , context=None) |
857 | - |
858 | + |
859 | + if rows: |
860 | + for row in rows: |
861 | + dias_trabajados.append(row[-1]) |
862 | + d = self.descuento(cr, uid, ids, context, row, tolerancia, concepto_id, idsw, periodo, retardos, tiempo_no_laborado, concepto_horas_no_trabajadas_id, ausencia, concepto_jornada_no_trabajda_id) |
863 | + aus = self.absence(cr, uid, ids, context, dias_trabajados, periodo, concepto_jornada_no_trabajda_id, idsw, i, ausencia) |
864 | + |
865 | + tolerancia = [] |
866 | + dias_trabajados = [] |
867 | + retardos = [] |
868 | + tiempo_no_laborado = [] |
869 | + ausencia = [] |
870 | + periodo = period2 |
871 | + |
872 | + if d[0]['value'] != 0: |
873 | + hrvc_linea_obj.create(cr, uid, d[0] , context=None) |
874 | + |
875 | + if d[1]['value'] != 0: |
876 | + hrvc_linea_obj.create(cr, uid, d[1] , context=None) |
877 | + |
878 | + |
879 | + if aus['value'] != 0: |
880 | + hrvc_linea_obj.create(cr, uid, aus , context=None) |
881 | + |
882 | + else: |
883 | + aus2 = self.absence(cr, uid, ids, context, dias_trabajados, periodo, concepto_jornada_no_trabajda_id, idsw, i, ausencia) |
884 | + hrvc_linea_obj.create(cr, uid, aus2 , context=None) |
885 | + ausencia = [] |
886 | + periodo = period2 |
887 | |
888 | return { |
889 | 'type': 'ir.actions.act_window_close', |
890 | @@ -176,7 +179,7 @@ |
891 | l.append(fh[1]) |
892 | return l |
893 | |
894 | - def descuento(self, cr, uid, ids, context, row, j, concepto, variable_id, periodo, retardos, tiempo_no_laborado, concepto_horas_no_trabajadas_id, asusencia, concepto_jornada_no_trabajda_id): |
895 | + def descuento(self, cr, uid, ids, context, row, tolerancia, concepto, variable_id, periodo, retardos, tiempo_no_laborado, concepto_horas_no_trabajadas_id, ausencia, concepto_jornada_no_trabajda_id): |
896 | |
897 | empleado_obj = self.pool.get('hr.employee') |
898 | empleado_id = empleado_obj.search(cr, uid, [('cod_number', '=', row[0])]) |
899 | @@ -184,39 +187,54 @@ |
900 | period = empleado_brw[0].shift_id |
901 | dif_total = self.total_discount('mensual') |
902 | d = self.discount_case(period, row[-1]) |
903 | - des1 = [i for i in row if row[1] < 2 if row[-1] in periodo] |
904 | - des2 = [i for i in row if row[1] >= 2 if self.cvr_hr(row[2]) >= self.cvr_hr(d[0]) + timedelta(minutes=15) if row[-1] in periodo] |
905 | - des3 = [i for i in row if row[1] >= 2 if self.cvr_hr(row[2]) >= self.cvr_hr(d[0]) + timedelta(minutes=5) and self.cvr_hr(row[2]) < self.cvr_hr(d[0]) + timedelta(minutes=15) ] |
906 | - des4 = [i for i in row if row[1] >= 2 if self.cvr_hr(row[3]) < self.cvr_hr(d[1]) if row[-1] in periodo] |
907 | + |
908 | + |
909 | + des1 = [i for i in row if row[1] < 2 if self.cvr_hr(d[0]) < self.cvr_hr(d[1]) if row[-1] in periodo] |
910 | + des2 = [] |
911 | + if self.cvr_hr(d[0]) < self.cvr_hr(d[1]): |
912 | + if row[1] >= 2: |
913 | + if self.cvr_hr(row[2]) >= self.cvr_hr(d[0]) + timedelta(minutes=15) and row[-1] in periodo: |
914 | + des2 = list(row) |
915 | + else: |
916 | + if self.cvr_hr(row[2]) >= self.cvr_hr(d[0]) + timedelta(minutes=15) and row[-1] in periodo: |
917 | + des2 = list(row) |
918 | + |
919 | + |
920 | + des3 = [] |
921 | + if self.cvr_hr(d[0]) < self.cvr_hr(d[1]): |
922 | + if row[1] >= 2: |
923 | + if self.cvr_hr(row[2]) >= self.cvr_hr(d[0]) + timedelta(minutes=5) and self.cvr_hr(row[2]) < self.cvr_hr(d[0]) + timedelta(minutes=15) and row[-1] in periodo: |
924 | + des3 = list(row) |
925 | + else: |
926 | + if self.cvr_hr(row[2]) >= self.cvr_hr(d[0]) + timedelta(minutes=5) and self.cvr_hr(row[2]) < self.cvr_hr(d[0]) + timedelta(minutes=15) and row[-1] in periodo: |
927 | + des3 = list(row) |
928 | + |
929 | + des4 = [i for i in row if row[1] >= 2 if self.cvr_hr(d[0]) < self.cvr_hr(d[1]) if self.cvr_hr(row[3]) < self.cvr_hr(d[1]) if row[-1] in periodo] |
930 | + |
931 | + |
932 | |
933 | if des1: |
934 | - asusencia.append(1) |
935 | - #~ print "descuento1", des1 |
936 | + ausencia.append(1) |
937 | |
938 | if des2: |
939 | - asusencia.append(1) |
940 | - #~ print "descuento2", des2[2] |
941 | + ausencia.append(1) |
942 | |
943 | if des3: |
944 | - #~ print des3 |
945 | - j.append(1) |
946 | - if len(j) > 3: |
947 | - asusencia.append(1) |
948 | - #~ print "descuento totelacia" |
949 | + tolerancia.append(1) |
950 | + if len(tolerancia) > 3: |
951 | + ausencia.append(1) |
952 | else: |
953 | if des3[-1] in periodo: |
954 | dif = self.subtract_hours(des3[2], d[0], 3600) |
955 | retardos.append(dif) |
956 | - #~ print "tolerancia acumulada", len(j), des3, dif |
957 | |
958 | if des4: |
959 | dif = self.subtract_hours(des4[3], d[1], 3600) |
960 | tiempo_no_laborado.append(dif) |
961 | - #~ print "descuento saldia" , dif, des4[3] |
962 | |
963 | return [{'employee_id': empleado_id[0], 'value': sum(retardos), 'payroll_id': False, 'variable_concept_id': variable_id[0], 'type': 'qty', 'concept_id': concepto}, |
964 | {'employee_id': empleado_id[0], 'value': sum(tiempo_no_laborado), 'payroll_id': False, 'variable_concept_id': variable_id[0], 'type': 'qty', 'concept_id': concepto_horas_no_trabajadas_id}, |
965 | - {'employee_id': empleado_id[0], 'value': sum(asusencia), 'payroll_id': False, 'variable_concept_id': variable_id[0], 'type': 'qty', 'concept_id': concepto_jornada_no_trabajda_id}] |
966 | + {'employee_id': empleado_id[0], 'value': sum(ausencia), 'payroll_id': False, 'variable_concept_id': variable_id[0], 'type': 'qty', 'concept_id': concepto_jornada_no_trabajda_id}] |
967 | |
968 | def cvr_hr(self, hours): |
969 | """ |
970 | @@ -293,15 +311,14 @@ |
971 | periodo = [i for i in fecha if i not in hr_holidays_calendar if self.discount_case(period, i)[0] != '00:00:00' and self.discount_case(period, i)[1] != '00:00:00'] |
972 | return periodo |
973 | |
974 | - def absence(self, cr, uid, ids, context, fecha, periodo, concepto, variable_id, codigo, asusencia): |
975 | + def absence(self, cr, uid, ids, context, fecha, periodo, concepto, variable_id, codigo, ausencia): |
976 | empleado_obj = self.pool.get('hr.employee') |
977 | empleado_id = empleado_obj.search(cr, uid, [('cod_number', '=', codigo)]) |
978 | for x in periodo: |
979 | if x not in fecha: |
980 | dif_total = self.total_discount('mensual') |
981 | - asusencia.append(1) |
982 | - #~ print "descuento por el dia no trabajado",x, codigo |
983 | - return {'employee_id': empleado_id[0], 'value': int(sum(asusencia)), 'payroll_id': False, 'variable_concept_id': variable_id[0], 'type': 'qty', 'concept_id': concepto} |
984 | + ausencia.append(1) |
985 | + return {'employee_id': empleado_id[0], 'value': int(sum(ausencia)), 'payroll_id': False, 'variable_concept_id': variable_id[0], 'type': 'qty', 'concept_id': concepto} |
986 | |
987 | def name_for_codnumber(self, cr, uid, ids, codigo): |
988 | empleado_obj = self.pool.get('hr.employee') |