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: | Needs review |
---|---|
Proposed branch: | lp:~inddiana/diana-addons/imp_he_biostar |
Merge into: | lp:diana-addons/6.0 |
Diff against target: |
393 lines (+165/-43) 5 files modified
diana_integracion_biostar/model/biostar.py (+61/-8) diana_integracion_biostar/view/biostar_view.xml (+40/-1) diana_integracion_biostar/wizard/export_biostar_view.xml (+2/-2) diana_integracion_biostar/wizard/horas_marcaje_view.xml (+2/-2) diana_integracion_biostar/wizard/horas_marcaje_wizard.py (+60/-30) |
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+183961@code.launchpad.net |
Commit message
Description of the change
sustituido empleado por trabajador y validado que la tupla que retorna el biostar no esten vacias
To post a comment you must log in.
Unmerged revisions
- 79. By Mauricio Sanchez <email address hidden>
-
creada vista para elegir el suceso del evento
- 78. By Mauricio Sanchez <email address hidden>
-
modificado herencia de la tabla para crear las lineas
- 77. By Mauricio Sanchez <email address hidden>
-
sustituido empleado por trabajador y validado que la tupla que retorna el biostar no esten vacias
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'diana_integracion_biostar/model/biostar.py' |
2 | --- diana_integracion_biostar/model/biostar.py 2013-02-07 12:46:58 +0000 |
3 | +++ diana_integracion_biostar/model/biostar.py 2013-10-15 16:02:48 +0000 |
4 | @@ -14,14 +14,14 @@ |
5 | _name='biostar.settings' |
6 | _description = 'modulo de configuracion para la conexcion de odbc' |
7 | _columns = { |
8 | - 'ip': fields.char('Direccion ip', size=16, required=True), |
9 | - 'data_base': fields.char('Base de datos', size=60, required=True), |
10 | + 'ip': fields.char('Direccion ip', size=16, required=True), |
11 | + 'data_base': fields.char('Base de datos', size=60, required=True), |
12 | 'port': fields.integer('Puerto', size=5, required=True), |
13 | - 'user': fields.char('Usuario', size=64, required=True), |
14 | - 'password': fields.char('Contraseña', size=64, required=True), |
15 | + 'user': fields.char('Usuario', size=64, required=True), |
16 | + 'password': fields.char('Contraseña', size=64, required=True), |
17 | 'active': fields.boolean('Activo'), |
18 | 'state': fields.selection([('draft','Borrardor'), ('confirmed','Confirmado')],'Estado',required=True,readonly=True), |
19 | - } |
20 | + } |
21 | _defaults = { |
22 | 'state': lambda *a: 'draft', |
23 | 'active': lambda *a: True, |
24 | @@ -139,14 +139,37 @@ |
25 | d['reader_id'] = row[0] |
26 | d['ip'] = row[2] |
27 | self.check_fingerprint(cr, uid, ids, row[0], d, context = None) |
28 | + |
29 | + cursor.execute('select * from TB_EVENT_DATA') |
30 | + rows = cursor.fetchall() |
31 | + d = {} |
32 | + for row in rows: |
33 | + d['nombre'] = row[1] |
34 | + d['event_id'] = row[0] |
35 | + d['descripcion'] = row[2] |
36 | + self.check_even_data(cr, uid, ids, row[0], d, context = None) |
37 | + |
38 | except pyodbc.Error, err: |
39 | raise osv.except_osv('ERROR', "Fallo de conexión") |
40 | + return True |
41 | |
42 | def check_fingerprint(self, cr, uid, ids, vid, valor, context = None): |
43 | obj = self.pool.get('biostar.fingerprint') |
44 | s = obj.search(cr, uid, [('reader_id', '=', vid )]) |
45 | - if len(s) == 1: |
46 | - obj.write(cr, uid, ids, valor) |
47 | + if s: |
48 | + #~ obj.write(cr, uid, ids, valor) |
49 | + pass |
50 | + else: |
51 | + obj.create(cr, uid, valor, context=None) |
52 | + |
53 | + return True |
54 | + |
55 | + def check_even_data(self, cr, uid, ids, vid, valor, context = None): |
56 | + obj = self.pool.get('biostar.event.data') |
57 | + s = obj.search(cr, uid, [('event_id', '=', vid )]) |
58 | + if s: |
59 | + #~ obj.write(cr, uid, ids, valor) |
60 | + pass |
61 | else: |
62 | obj.create(cr, uid, valor, context=None) |
63 | |
64 | @@ -169,13 +192,43 @@ |
65 | 'reader_id': fields.integer('Id', size=5, required=True, readonly=True), |
66 | 'ip': fields.char('Direccion ip', size=16, required=True, readonly=True), |
67 | 'valido': fields.boolean('Valido'), |
68 | - } |
69 | + } |
70 | |
71 | _defaults = { |
72 | 'valido': lambda *a: False, |
73 | } |
74 | |
75 | biostar_fingerprint() |
76 | + |
77 | +class biostar_event_data(osv.osv): |
78 | + |
79 | + _name = 'biostar.event.data' |
80 | + _description = 'modulo para definir los eventos' |
81 | + _rec_name = 'nombre' |
82 | + _columns = { |
83 | + 'nombre': fields.char('Evento', size=64, required=True, readonly=True), |
84 | + 'event_id': fields.integer('Id', size=5, required=True, readonly=True), |
85 | + 'descripcion': fields.char('Descripcion', size=16, readonly=True), |
86 | + 'valido': fields.boolean('Valido'), |
87 | + } |
88 | + |
89 | + _defaults = { |
90 | + 'valido': lambda *a: False, |
91 | + } |
92 | + |
93 | + def even_id(self, cr, uid, ids): |
94 | + event_id = self.search(cr, uid, [('valido', '=', True)]) |
95 | + event_brw = self.browse(cr, uid, event_id) |
96 | + t = [n.event_id for n in event_brw] |
97 | + if len(t) > 1: |
98 | + t = 'IN %s' %str(tuple(t)) |
99 | + elif len(t) == 1: |
100 | + t = '= %s' %t[0] |
101 | + else: |
102 | + t = '' |
103 | + return t |
104 | + |
105 | +biostar_event_data() |
106 | |
107 | |
108 | |
109 | |
110 | === modified file 'diana_integracion_biostar/view/biostar_view.xml' |
111 | --- diana_integracion_biostar/view/biostar_view.xml 2013-05-02 20:04:28 +0000 |
112 | +++ diana_integracion_biostar/view/biostar_view.xml 2013-10-15 16:02:48 +0000 |
113 | @@ -14,7 +14,7 @@ |
114 | <field name="port" select="1" /> |
115 | <field name="active" select="1" /> |
116 | <separator /> |
117 | - <group colspan='4'> |
118 | + <group colspan='4' col='8' > |
119 | <field name="state" select="4" colspan='1' /> |
120 | <!-- |
121 | <label colspan='1' /> |
122 | @@ -22,6 +22,7 @@ |
123 | <button string="Comprobar conexión" name="test_connection" type="object" icon="gtk-ok" colspan='1' states='draft'/> |
124 | <button string="Leer Biometrico" name="fingerprint" type="object" icon="gtk-ok" colspan='1' states='confirmed' /> |
125 | </group> |
126 | + |
127 | </form> |
128 | </field> |
129 | </record> |
130 | @@ -80,7 +81,45 @@ |
131 | <field name="view_type">form</field> |
132 | <field name="view_mode">form,tree</field> |
133 | </record> |
134 | + |
135 | + <record model="ir.ui.view" id="biostar_event_data_form"> |
136 | + <field name="name">biostar.event.data.form</field> |
137 | + <field name="model">biostar.event.data</field> |
138 | + <field name="type">form</field> |
139 | + <field name="arch" type="xml"> |
140 | + <form string="Configurar Eventos"> |
141 | + <field name="nombre" select="1" /> |
142 | + <field name="event_id" select="1" /> |
143 | + <field name="descripcion" select="1" /> |
144 | + <field name="valido" select="1" /> |
145 | + </form> |
146 | + </field> |
147 | + </record> |
148 | + |
149 | + <record model="ir.ui.view" id="biostar_event_data_tree"> |
150 | + <field name="name">biostar.event.data.tree</field> |
151 | + <field name="model">biostar.event.data</field> |
152 | + <field name="type">tree</field> |
153 | + <field name="arch" type="xml"> |
154 | + <tree string="Configurar Eventos"> |
155 | + <field name="nombre" select="1" /> |
156 | + <field name="event_id" select="1" /> |
157 | + <field name="descripcion" select="1" /> |
158 | + <field name="valido" select="1" /> |
159 | + </tree> |
160 | + </field> |
161 | + </record> |
162 | + |
163 | + <record model="ir.actions.act_window" id="action_biostar_event_data"> |
164 | + <field name="name">Configurar Eventos </field> |
165 | + <field name="view_id" ref="biostar_event_data_tree" /> |
166 | + <field name="res_model">biostar.event.data</field> |
167 | + <field name="view_type">form</field> |
168 | + <field name="view_mode">form,tree</field> |
169 | + </record> |
170 | + |
171 | <menuitem name="Configurar Conexión ODBC" id="biostart" action="action_biostar_settings" parent="hr.menu_hr_configuration" sequence="15" /> |
172 | <menuitem name="Lectores Biometricos " id="fingerprint" action="action_biostar_fingerprint" parent="biostart" sequence="15" /> |
173 | + <menuitem name="Evenetos de Biometricos" id="event_data" action="action_biostar_event_data" parent="biostart" sequence="15" /> |
174 | </data> |
175 | </openerp> |
176 | |
177 | === modified file 'diana_integracion_biostar/wizard/export_biostar_view.xml' |
178 | --- diana_integracion_biostar/wizard/export_biostar_view.xml 2013-07-01 19:17:55 +0000 |
179 | +++ diana_integracion_biostar/wizard/export_biostar_view.xml 2013-10-15 16:02:48 +0000 |
180 | @@ -6,7 +6,7 @@ |
181 | <field name="model">exportar.empleado.biostar.wizard</field> |
182 | <field name="type">form</field> |
183 | <field name="arch" type="xml"> |
184 | - <form string="Exportar empleado a BioStar"> |
185 | + <form string="Exportar trabajador a BioStar"> |
186 | <group colspan="4"> |
187 | <button string="EXPORTAR" name="export" type="object" icon="gtk-ok" confirm="Desea exportar los usuarios seleccionados"/> |
188 | <button string="SALIR" name="salir" type="object" icon="gtk-cancel" colspan="1" /> |
189 | @@ -15,7 +15,7 @@ |
190 | </field> |
191 | </record> |
192 | |
193 | - <act_window name="Exportar empleado a BioStar" |
194 | + <act_window name="Exportar trabajador a BioStar" |
195 | res_model="exportar.empleado.biostar.wizard" |
196 | src_model="hr.employee" |
197 | key2="client_action_multi" |
198 | |
199 | === modified file 'diana_integracion_biostar/wizard/horas_marcaje_view.xml' |
200 | --- diana_integracion_biostar/wizard/horas_marcaje_view.xml 2013-05-16 18:27:40 +0000 |
201 | +++ diana_integracion_biostar/wizard/horas_marcaje_view.xml 2013-10-15 16:02:48 +0000 |
202 | @@ -30,7 +30,7 @@ |
203 | <field name="model">horas.marcaje.wizard</field> |
204 | <field name="type">form</field> |
205 | <field name="arch" type="xml"> |
206 | - <form string="Marcaje del Empleado"> |
207 | + <form string="Marcaje del Trabajador"> |
208 | <field name="fecha_desde" readonly="True" /> |
209 | <field name="fecha_hasta" readonly="True" /> |
210 | <field name="h_line_ids" readonly="True" nolabel="1" colspan='4'> |
211 | @@ -66,6 +66,6 @@ |
212 | <!-- |
213 | <act_window name="Buscar marcaje del empleado" res_model="horas.marcaje.next.wizard" src_model="hr.employee" key2="client_action_multi" multi="True" view_mode="form" view_type="form" target="new" id="action_horas_marcaje_next_wizard" /> |
214 | --> |
215 | - <act_window name="Buscar marcaje del empleado" res_model="horas.marcaje.next.wizard" src_model="hr.employee" key2="client_action_multi" multi="True" view_mode="form" view_type="form" target="new" id="action_horas_marcaje_next_wizard" /> |
216 | + <act_window name="Buscar marcaje del Trabajador" res_model="horas.marcaje.next.wizard" src_model="hr.employee" key2="client_action_multi" multi="True" view_mode="form" view_type="form" target="new" id="action_horas_marcaje_next_wizard" /> |
217 | </data> |
218 | </openerp> |
219 | |
220 | === modified file 'diana_integracion_biostar/wizard/horas_marcaje_wizard.py' |
221 | --- diana_integracion_biostar/wizard/horas_marcaje_wizard.py 2013-09-03 15:33:56 +0000 |
222 | +++ diana_integracion_biostar/wizard/horas_marcaje_wizard.py 2013-10-15 16:02:48 +0000 |
223 | @@ -12,9 +12,26 @@ |
224 | _columns = { |
225 | 'fecha_desde': fields.date('Fecha desde'), |
226 | 'fecha_hasta': fields.date('Fecha hasta'), |
227 | + 'h_line_ids': fields.one2many('horas.marcaje.lineas.wizard', 'horas_marcaje_id', 'Lineas de marcaje'), |
228 | |
229 | } |
230 | |
231 | + def imprimir(self, cr, uid, ids, context=None): |
232 | + d = {} |
233 | + d = { |
234 | + 'ids': context.get('active_ids',[]), |
235 | + 'model': 'horas.marcaje.wizard', |
236 | + } |
237 | + |
238 | + data = self.read(cr, 1, ids) |
239 | + data = data[0] |
240 | + data.update(d) |
241 | + |
242 | + return { |
243 | + 'type': 'ir.actions.report.xml', |
244 | + 'report_name': 'horas.marcaje', |
245 | + #~ 'datas': data, |
246 | + } |
247 | |
248 | def salir(self, cr, uid, ids, context=None): |
249 | return { |
250 | @@ -35,6 +52,27 @@ |
251 | |
252 | horas_marcaje_wizard() |
253 | |
254 | + |
255 | +class horas_marcaje_lineas_wizard(osv.osv_memory): |
256 | + _name = 'horas.marcaje.lineas.wizard' |
257 | + _description = 'muestra los campos de salida del Biostart' |
258 | + _columns = { |
259 | + #~ 'hora_entrada': fields.time('Hora de entrada'), |
260 | + 'hora': fields.time('Hora', readonly=True), |
261 | + #~ 'hora_salida': fields.time('Hora de salida'), |
262 | + 'fecha': fields.date('Fecha'), |
263 | + 'codigo': fields.char('Codigo', size=64), |
264 | + 'nombre': fields.char('Nombre', size=64), |
265 | + 'capta_huella': fields.char('Capta Huellas', size=200), |
266 | + 'horas_marcaje_id': fields.many2one('horas.marcaje.wizard', 'hora de marcaje'), |
267 | + } |
268 | + |
269 | + |
270 | + |
271 | + |
272 | +horas_marcaje_lineas_wizard() |
273 | + |
274 | + |
275 | class horas_marcaje_next_wizard(osv.osv_memory): |
276 | _name = 'horas.marcaje.next.wizard' |
277 | _description = 'busca la hora de marcaje en el Biometrico' |
278 | @@ -56,14 +94,17 @@ |
279 | data = self.read(cr, 1, ids)[0] |
280 | idsw = [context['active_id']] |
281 | conex = self.conexion(cr, uid, ids, context=None) |
282 | - |
283 | + self.evento = self.pool.get('biostar.event.data').even_id(cr, uid, ids) |
284 | + if not self.evento: |
285 | + raise osv.except_osv('ERROR', 'No existen sucesos definidos para la busqueda') |
286 | + |
287 | if context['active_ids'] > 1: |
288 | idsw = context['active_ids'] |
289 | |
290 | fd = data['fecha_desde'] |
291 | fh = data['fecha_hasta'] |
292 | |
293 | - |
294 | + l = self.validate_line |
295 | hmw_id = self.pool.get('horas.marcaje.wizard').create(cr, uid, {'fecha_desde': fd, 'fecha_hasta':fh}) |
296 | driver = self.reader_id(cr, uid, ids) |
297 | if driver: |
298 | @@ -78,8 +119,11 @@ |
299 | nombre = idt.name |
300 | sql = self.query(cod,fd, fh, driver) |
301 | rows = conex.execute(sql) |
302 | + if not rows: |
303 | + print rows |
304 | for row in rows: |
305 | - 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}) |
306 | + if row: |
307 | + crl = self.pool.get('horas.marcaje.lineas.wizard').create(cr, uid, {'hora':l(row[0]), 'fecha':l(row[1]),'codigo':l(row[3]),'nombre':l(nombre), 'capta_huella':l(row[2]), 'horas_marcaje_id':l(hmw_id)}) |
308 | brw = self.pool.get('horas.marcaje.wizard').browse(cr, 1, ids)[0] |
309 | line = self.pool.get('horas.marcaje.lineas.wizard').browse(cr, 1, ids)[0] |
310 | |
311 | @@ -89,11 +133,8 @@ |
312 | context.update({'active_model':'horas.marcaje.wizard'}) |
313 | context.update(cabecera) |
314 | |
315 | - 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} |
316 | - |
317 | - |
318 | - |
319 | - try: |
320 | + try: |
321 | + lineas = {'hora': l(line.hora) , 'fecha':l(line.fecha) , 'capta_huella':l(line.capta_huella), 'horas_marcaje_id':l(line.horas_marcaje_id.id) , 'nombre': l(line.nombre), 'codigo': l(line.codigo), 'id': l(line.id)} |
322 | context.update(lineas) |
323 | except: |
324 | raise osv.except_osv('ERROR', 'No existen marcajes en el perido desde %s hasta %s' %(fd, fh)) |
325 | @@ -126,6 +167,11 @@ |
326 | t = '' |
327 | return t |
328 | |
329 | + def validate_line(self, args): |
330 | + if args: |
331 | + return args |
332 | + return '' |
333 | + |
334 | def conexion(self, cr, uid, ids, context=None): |
335 | bio_obj = self.pool.get('horas.extras') |
336 | bio_conect = bio_obj.conexion(cr, uid, ids, context = None) |
337 | @@ -133,45 +179,29 @@ |
338 | return cursor |
339 | |
340 | def query(self, cod,fd, fh, t): |
341 | + cod = str(cod).strip() |
342 | + t = str(t).strip() |
343 | + |
344 | sql = ''' |
345 | SELECT CONVERT(VARCHAR(11), DATEADD(s, nDateTime, '1970-01-01'),108), CONVERT(nVarchar(10), DATEADD(s, EVENT.nDateTime, '1970-01-01'), 20), READER.sName, C.sFieldValue5 |
346 | FROM TB_EVENT_LOG AS EVENT |
347 | JOIN TB_USER AS U ON EVENT.nUserID = U.sUserId |
348 | JOIN TB_READER AS READER ON EVENT.nReaderIdn = READER.nReaderIdn JOIN TB_EVENT_DATA AS E_DATA ON EVENT.nEventIdn = E_DATA.nEventIdn |
349 | JOIN TB_USER_CUSTOMINFO As C ON C.nUserIdn = U.nUserIdn |
350 | - WHERE E_DATA.nEventIdn = 55 |
351 | + WHERE E_DATA.nEventIdn %s |
352 | AND CONVERT(nVarchar(10), DATEADD(s, EVENT.nDateTime, '1970-01-01'), 20) >= '%s' |
353 | AND CONVERT(nVarchar(10), DATEADD(s, EVENT.nDateTime, '1970-01-01'), 20) <= '%s' |
354 | AND READER.nReaderIdn %s |
355 | AND C.sFieldValue5 = %s |
356 | GROUP BY CONVERT(VARCHAR(11), DATEADD(s, nDateTime, '1970-01-01'),108), READER.sName, CONVERT(nVarchar(10), DATEADD(s, EVENT.nDateTime, '1970-01-01'), 20), C.sFieldValue5 |
357 | ORDER BY CONVERT(nVarchar(10), DATEADD(s, EVENT.nDateTime, '1970-01-01'), 20) |
358 | - '''%(fd, fh, t, cod) |
359 | + '''%(self.evento, fd, fh, t, cod) |
360 | return sql |
361 | |
362 | |
363 | |
364 | horas_marcaje_next_wizard() |
365 | |
366 | -class horas_marcaje_lineas_wizard(osv.osv_memory): |
367 | - _name = 'horas.marcaje.lineas.wizard' |
368 | - _description = 'muestra los campos de salida del Biostart' |
369 | - _columns = { |
370 | - #~ 'hora_entrada': fields.time('Hora de entrada'), |
371 | - 'hora': fields.time('Hora', readonly=True), |
372 | - #~ 'hora_salida': fields.time('Hora de salida'), |
373 | - 'fecha': fields.date('Fecha'), |
374 | - 'codigo': fields.char('Codigo', size=64), |
375 | - 'nombre': fields.char('Nombre', size=64), |
376 | - 'capta_huella': fields.char('Capta Huellas', size=200), |
377 | - 'horas_marcaje_id': fields.many2one('horas.marcaje.wizard', 'hora de marcaje'), |
378 | - } |
379 | - |
380 | - |
381 | - |
382 | - |
383 | -horas_marcaje_lineas_wizard() |
384 | - |
385 | |
386 | class horas_marcaje_wizard(osv.osv_memory): |
387 | |
388 | @@ -200,5 +230,5 @@ |
389 | } |
390 | |
391 | |
392 | -horas_marcaje_wizard() |
393 | +#~ horas_marcaje_wizard() |
394 |