Merge lp:~inddiana/diana-addons/diana_integracion_modificacion into lp:diana-addons

Proposed by Mauricio Jose Sanchez Puerta
Status: Merged
Merged at revision: 38
Proposed branch: lp:~inddiana/diana-addons/diana_integracion_modificacion
Merge into: lp:diana-addons
Diff against target: 186 lines (+97/-10)
4 files modified
diana_integracion_biostar/report/horas_extras_planificacion.xml (+2/-0)
diana_integracion_biostar/report/horas_marcaje_report.py (+58/-6)
diana_integracion_biostar/wizard/horas_marcaje_view.xml (+5/-0)
diana_integracion_biostar/wizard/horas_marcaje_wizard.py (+32/-4)
To merge this branch: bzr merge lp:~inddiana/diana-addons/diana_integracion_modificacion
Reviewer Review Type Date Requested Status
[SISB] Yennifer Santiago Z Pending
Review via email: mp+204497@code.launchpad.net

Description of the change

modificado wizard para buscar marcajes del trabajador para imprimr reportes en csv o pdf

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'diana_integracion_biostar/report/horas_extras_planificacion.xml'
2--- diana_integracion_biostar/report/horas_extras_planificacion.xml 2013-05-16 18:27:40 +0000
3+++ diana_integracion_biostar/report/horas_extras_planificacion.xml 2014-02-03 14:07:59 +0000
4@@ -19,5 +19,7 @@
5 rml="diana_integracion_biostar/report/horas_marcaje_report.rml"
6 string="Reporte de marcajes"
7 />
8+
9+
10 </data>
11 </openerp>
12
13=== modified file 'diana_integracion_biostar/report/horas_marcaje_report.py'
14--- diana_integracion_biostar/report/horas_marcaje_report.py 2013-05-20 20:06:05 +0000
15+++ diana_integracion_biostar/report/horas_marcaje_report.py 2014-02-03 14:07:59 +0000
16@@ -1,6 +1,9 @@
17 from report import report_sxw
18 import datetime
19 from datetime import datetime
20+import pooler
21+
22+
23
24 class horas_marcaje_report(report_sxw.rml_parse):
25 _name = 'horas.marcaje.report'
26@@ -13,6 +16,7 @@
27
28 })
29 self.context = context
30+
31
32 def get_empresa(self, partner_id):
33 obj_addr = self.pool.get('res.partner.address')
34@@ -32,13 +36,61 @@
35
36 def get_final_date(self):
37 return datetime.now().strftime('%d/%m/%Y %H:%M')
38-
39-
40-
41-
42-report_sxw.report_sxw(
43- 'report.horas.marcaje',
44+
45+report_sxw = report_sxw.report_sxw
46+
47+class TxtParser(report_sxw):
48+ """Custom class that use webkit to render HTML reports
49+ Code partially taken from report openoffice. Thanks guys :)
50+ """
51+ def __init__(self, name, table, rml=False, parser=False,
52+ header=True, store=False):
53+ self.parser_instance = False
54+ self.localcontext={}
55+ report_sxw.__init__(self, name, table, rml, parser,
56+ header, store)
57+
58+
59+ def create_single_pdf(self, cursor, uid, ids, data, report_xml, context):
60+ """generate the PDF"""
61+
62+
63+ if context is None:
64+ context={}
65+
66+ if data['is_pdf']:
67+ return super(TxtParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
68+
69+ self.parser_instance = self.parser(
70+ cursor,
71+ uid,
72+ self.name2,
73+ context=context
74+ )
75+ if data['is_csv']:
76+ wizard_hextras = pooler.get_pool(cursor.dbname).get('horas.marcaje.wizard')
77+ wizard_hextras_brw = wizard_hextras.browse(cursor, uid, context['h_line_ids'])
78+ wizard_hextras_brw = [l for line in wizard_hextras_brw for l in line.h_line_ids ]
79+ titulo = "\t\tREPORTE DE MARCAJE\n\n"
80+ cabecera = '|HORA|\t|FECHA|\t|CODIGO|\t|NOMBRE|\t|CAJERO|\n '
81+ pdf = ''
82+ sal = ''
83+ txt = ''
84+ pdf = pdf + titulo
85+ for line in wizard_hextras_brw:
86+ txt = '|%s|%s|%s|%s|%s|'%(line.hora, line.fecha, line.codigo, line.nombre, line.capta_huella)
87+ pdf = pdf + txt + '\n'
88+ return (pdf, 'csv')
89+
90+
91+
92+
93+TxtParser(
94+ 'report.horas.marcaje',
95 'horas.marcaje.wizard',
96 'diana_integracion_biostar/report/horas_marcaje_report.rml',
97 parser=horas_marcaje_report, header=False)
98
99+
100+
101+
102
103=== modified file 'diana_integracion_biostar/wizard/horas_marcaje_view.xml'
104--- diana_integracion_biostar/wizard/horas_marcaje_view.xml 2013-09-04 19:22:41 +0000
105+++ diana_integracion_biostar/wizard/horas_marcaje_view.xml 2014-02-03 14:07:59 +0000
106@@ -42,6 +42,11 @@
107 <field name="capta_huella" readonly="True" />
108 </tree>
109 </field>
110+ <separator string="Formato de Impresion" />
111+ <group col="2" colspan="4">
112+ <field name="is_pdf" attrs= "{'readonly':[('is_csv','=','True')] }" />
113+ <field name="is_csv" attrs= "{'readonly':[('is_pdf','=','True')] }" />
114+ </group>
115 <group col="12" colspan="4">
116 <button name="imprimir" string="Imprimir" colspan="1" type="object" icon="gtk-print" />
117 <button string="SALIR" name="salir" type="object" icon="gtk-cancel" colspan="1" />
118
119=== modified file 'diana_integracion_biostar/wizard/horas_marcaje_wizard.py'
120--- diana_integracion_biostar/wizard/horas_marcaje_wizard.py 2014-01-30 19:30:56 +0000
121+++ diana_integracion_biostar/wizard/horas_marcaje_wizard.py 2014-02-03 14:07:59 +0000
122@@ -13,9 +13,13 @@
123 'fecha_desde': fields.date('Fecha desde'),
124 'fecha_hasta': fields.date('Fecha hasta'),
125 'h_line_ids': fields.one2many('horas.marcaje.lineas.wizard', 'horas_marcaje_id', 'Lineas de marcaje'),
126+ 'is_pdf': fields.boolean('PDF'),
127+ 'is_csv': fields.boolean('CSV'),
128
129 }
130
131+
132+
133 def imprimir(self, cr, uid, ids, context=None):
134 d = {}
135 d = {
136@@ -23,15 +27,38 @@
137 'model': 'horas.marcaje.wizard',
138 }
139
140- data = self.read(cr, 1, ids)
141- data = data[0]
142- data.update(d)
143+
144+ datos = self.read(cr, 1, ids)
145+ brw = self.browse(cr, 1, ids)
146+ datos = datos[0]
147+ pdf = datos['is_pdf']
148+ csv = datos['is_csv']
149+
150+ context['is_pdf'] = pdf
151+ context['is_csv'] = csv
152+
153+
154+ if not pdf and not csv:
155+ raise osv.except_osv('ERROR', 'Debe Seleccionar un Formato para poder Imprimir el reporte')
156+
157+ data = {}
158+
159+
160+ if pdf and not csv:
161+ data.update(context)
162+
163+ salida = []
164+ if csv and not pdf:
165+ data.update({'is_csv':csv, 'is_pdf':pdf})
166
167 return {
168 'type': 'ir.actions.report.xml',
169 'report_name': 'horas.marcaje',
170- #~ 'datas': data,
171+ 'datas': data,
172+ #~ 'context': context,
173 }
174+
175+
176
177 def salir(self, cr, uid, ids, context=None):
178 return {
179@@ -136,6 +163,7 @@
180
181 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}
182
183+ context.update({'is_pdf':True, 'is_csv':False})
184 context.update({'active_id': hmw_id, 'active_model':'horas.marcaje.wizard'})
185 context.update({'active_model':'horas.marcaje.wizard'})
186 context.update(cabecera)

Subscribers

People subscribed via source and target branches