Merge lp:~inddiana/sisb/sisb_nomina_resumen_reporte_gastos into lp:sisb
- sisb_nomina_resumen_reporte_gastos
- Merge into sisb
Proposed by
[SISB] Aryrosa Fuentes
Status: | Merged |
---|---|
Merged at revision: | 985 |
Proposed branch: | lp:~inddiana/sisb/sisb_nomina_resumen_reporte_gastos |
Merge into: | lp:sisb |
Diff against target: |
558 lines (+502/-0) 10 files modified
sisb_nomina_resumen/__init__.py (+1/-0) sisb_nomina_resumen/__openerp__.py (+42/-0) sisb_nomina_resumen/i18n/es_VE.po (+109/-0) sisb_nomina_resumen/report/__init__.py (+1/-0) sisb_nomina_resumen/report/report_nomina_resumen.py (+35/-0) sisb_nomina_resumen/security/groups.xml (+20/-0) sisb_nomina_resumen/security/ir.model.access.csv (+2/-0) sisb_nomina_resumen/wizard/__init__.py (+1/-0) sisb_nomina_resumen/wizard/sisb_nomina_resumen.py (+253/-0) sisb_nomina_resumen/wizard/sisb_nomina_resumen_wizard.xml (+38/-0) |
To merge this branch: | bzr merge lp:~inddiana/sisb/sisb_nomina_resumen_reporte_gastos |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juan Lugo | Pending | ||
Review via email: mp+337282@code.launchpad.net |
Commit message
Description of the change
[IMP] se creo el modulo sisb_nomina_resumen para generar un reporte de los gasto de nominas por mes.
[FIX] Ajsutes en el reporte con respecto a la forma de obtener la fecha de inicio de la relacion laboral. Se asume que en sisb_nomina ya existe la funcion que realiza el calculo.
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 | === added directory 'sisb_nomina_resumen' |
2 | === added file 'sisb_nomina_resumen/__init__.py' |
3 | --- sisb_nomina_resumen/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ sisb_nomina_resumen/__init__.py 2018-02-07 15:37:15 +0000 |
5 | @@ -0,0 +1,1 @@ |
6 | +import wizard, report |
7 | |
8 | === added file 'sisb_nomina_resumen/__openerp__.py' |
9 | --- sisb_nomina_resumen/__openerp__.py 1970-01-01 00:00:00 +0000 |
10 | +++ sisb_nomina_resumen/__openerp__.py 2018-02-07 15:37:15 +0000 |
11 | @@ -0,0 +1,42 @@ |
12 | +# -*- coding:utf-8 -*- |
13 | +############################################################################## |
14 | +# |
15 | +# SISB, Sistema Integral Simon Bolivar |
16 | +# Copyright (C) 2012-2013 Industrias Diana, C.A. All Rights Reserved |
17 | +# |
18 | +# This program is free software: you can redistribute it and/or modify |
19 | +# it under the terms of the GNU Affero General Public License as published by |
20 | +# the Free Software Foundation, either version 3 of the License, or |
21 | +# (at your option) any later version. |
22 | +# |
23 | +# This program is distributed in the hope that it will be useful, |
24 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
26 | +# GNU Affero General Public License for more details. |
27 | +# |
28 | +# You should have received a copy of the GNU Affero General Public License |
29 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
30 | +# |
31 | +############################################################################## |
32 | +{ |
33 | + 'name': 'Resumen general de asignaciones y deducciones de nomina.', |
34 | + 'version': '1.0', |
35 | + "author": "Industrias Diana C.A.", |
36 | + "category": "Human Resources", |
37 | + "website": "http://www.industriasdiana.gob.ve", |
38 | + 'description': """Modulo que genera un reporte general con todas las asignaciones y deducciones de todos |
39 | + los trabajadores, clasificandolos por el tipo de nomina, en formato .ods y protegido |
40 | + contra escritura.""", |
41 | + 'depends': ['base', 'sisb_nomina'], |
42 | + 'external_dependencies': { |
43 | + 'python': ['xlwt'] |
44 | + }, |
45 | + 'init_xml': [], |
46 | + 'update_xml': [ |
47 | + 'security/groups.xml', |
48 | + 'security/ir.model.access.csv', |
49 | + 'wizard/sisb_nomina_resumen_wizard.xml' |
50 | + ], |
51 | + 'active': True, |
52 | + 'installable': True |
53 | +} |
54 | |
55 | === added directory 'sisb_nomina_resumen/i18n' |
56 | === added file 'sisb_nomina_resumen/i18n/es_VE.mo' |
57 | Binary files sisb_nomina_resumen/i18n/es_VE.mo 1970-01-01 00:00:00 +0000 and sisb_nomina_resumen/i18n/es_VE.mo 2018-02-07 15:37:15 +0000 differ |
58 | === added file 'sisb_nomina_resumen/i18n/es_VE.po' |
59 | --- sisb_nomina_resumen/i18n/es_VE.po 1970-01-01 00:00:00 +0000 |
60 | +++ sisb_nomina_resumen/i18n/es_VE.po 2018-02-07 15:37:15 +0000 |
61 | @@ -0,0 +1,109 @@ |
62 | +# Translation of OpenERP Server. |
63 | +# This file contains the translation of the following modules: |
64 | +# * sisb_nomina_resumen |
65 | +# |
66 | +msgid "" |
67 | +msgstr "" |
68 | +"Project-Id-Version: OpenERP Server 6.0.4\n" |
69 | +"Report-Msgid-Bugs-To: support@openerp.com\n" |
70 | +"POT-Creation-Date: 2017-05-10 13:33+0000\n" |
71 | +"PO-Revision-Date: 2017-05-10 09:37-0400\n" |
72 | +"Last-Translator: carmelo <carmelolopez3@hotmail.com>\n" |
73 | +"Language-Team: \n" |
74 | +"MIME-Version: 1.0\n" |
75 | +"Content-Type: text/plain; charset=UTF-8\n" |
76 | +"Content-Transfer-Encoding: 8bit\n" |
77 | +"Plural-Forms: \n" |
78 | + |
79 | +#. module: sisb_nomina_resumen |
80 | +#: code:addons/sisb_nomina_resumen/wizard/sisb_nomina_resumen.py:190 |
81 | +#, python-format |
82 | +msgid "Net Total" |
83 | +msgstr "Total Neto" |
84 | + |
85 | +#. module: sisb_nomina_resumen |
86 | +#: code:addons/sisb_nomina_resumen/wizard/sisb_nomina_resumen.py:157 |
87 | +#, python-format |
88 | +msgid "Roster" |
89 | +msgstr "Nómina" |
90 | + |
91 | +#. module: sisb_nomina_resumen |
92 | +#: view:sisb.nomina.resumen:0 |
93 | +msgid "Print" |
94 | +msgstr "Imprimir" |
95 | + |
96 | +#. module: sisb_nomina_resumen |
97 | +#: code:addons/sisb_nomina_resumen/wizard/sisb_nomina_resumen.py:220 |
98 | +#, python-format |
99 | +msgid "roster_report_" |
100 | +msgstr "reporte_nomina_" |
101 | + |
102 | +#. module: sisb_nomina_resumen |
103 | +#: model:ir.actions.act_window,name:sisb_nomina_resumen.action_wizard_sisb_nomina_resumen |
104 | +#: model:ir.ui.menu,name:sisb_nomina_resumen.menu_wizard_sisb_nomina_resumen |
105 | +msgid "Resumen mensual de nomina" |
106 | +msgstr "Resumen mensual de nomina" |
107 | + |
108 | +#. module: sisb_nomina_resumen |
109 | +#: model:ir.actions.report.xml,name:sisb_nomina_resumen.report_nomina_resumen |
110 | +msgid "Reporte de nomina" |
111 | +msgstr "Reporte de nomina" |
112 | + |
113 | +#. module: sisb_nomina_resumen |
114 | +#: code:addons/sisb_nomina_resumen/wizard/sisb_nomina_resumen.py:177 |
115 | +#, python-format |
116 | +msgid "Total bonuses" |
117 | +msgstr "Total Asignaciones" |
118 | + |
119 | +#. module: sisb_nomina_resumen |
120 | +#: field:sisb.nomina.resumen,month:0 |
121 | +msgid "Month" |
122 | +msgstr "Mes" |
123 | + |
124 | +#. module: sisb_nomina_resumen |
125 | +#: code:addons/sisb_nomina_resumen/wizard/sisb_nomina_resumen.py:158 |
126 | +#, python-format |
127 | +msgid "Employee" |
128 | +msgstr "Empleado" |
129 | + |
130 | +#. module: sisb_nomina_resumen |
131 | +#: code:addons/sisb_nomina_resumen/wizard/sisb_nomina_resumen.py:162 |
132 | +#, python-format |
133 | +msgid "Job" |
134 | +msgstr "Cargo" |
135 | + |
136 | +#. module: sisb_nomina_resumen |
137 | +#: code:addons/sisb_nomina_resumen/wizard/sisb_nomina_resumen.py:159 |
138 | +#, python-format |
139 | +msgid "Identification" |
140 | +msgstr "Cédula" |
141 | + |
142 | +#. module: sisb_nomina_resumen |
143 | +#: code:addons/sisb_nomina_resumen/wizard/sisb_nomina_resumen.py:160 |
144 | +#, python-format |
145 | +msgid "Join date" |
146 | +msgstr "Fecha Ingreso" |
147 | + |
148 | +#. module: sisb_nomina_resumen |
149 | +#: code:addons/sisb_nomina_resumen/wizard/sisb_nomina_resumen.py:161 |
150 | +#, python-format |
151 | +msgid "Department" |
152 | +msgstr "Departamento" |
153 | + |
154 | +#. module: sisb_nomina_resumen |
155 | +#: model:ir.model,name:sisb_nomina_resumen.model_sisb_nomina_resumen |
156 | +msgid "sisb.nomina.resumen" |
157 | +msgstr "sisb.nomina.resumen" |
158 | + |
159 | +#. module: sisb_nomina_resumen |
160 | +#: code:addons/sisb_nomina_resumen/wizard/sisb_nomina_resumen.py:223 |
161 | +#, python-format |
162 | +msgid "No data found" |
163 | +msgstr "No se encontró información" |
164 | + |
165 | +#. module: sisb_nomina_resumen |
166 | +#: code:addons/sisb_nomina_resumen/wizard/sisb_nomina_resumen.py:186 |
167 | +#, python-format |
168 | +msgid "Total debts" |
169 | +msgstr "Total Deducciones" |
170 | + |
171 | |
172 | === added directory 'sisb_nomina_resumen/report' |
173 | === added file 'sisb_nomina_resumen/report/__init__.py' |
174 | --- sisb_nomina_resumen/report/__init__.py 1970-01-01 00:00:00 +0000 |
175 | +++ sisb_nomina_resumen/report/__init__.py 2018-02-07 15:37:15 +0000 |
176 | @@ -0,0 +1,1 @@ |
177 | +import report_nomina_resumen |
178 | |
179 | === added file 'sisb_nomina_resumen/report/report_nomina_resumen.py' |
180 | --- sisb_nomina_resumen/report/report_nomina_resumen.py 1970-01-01 00:00:00 +0000 |
181 | +++ sisb_nomina_resumen/report/report_nomina_resumen.py 2018-02-07 15:37:15 +0000 |
182 | @@ -0,0 +1,35 @@ |
183 | +#!/usr/bin/env python |
184 | +# -*- coding: utf-8 -*- |
185 | +from report import report_sxw |
186 | +import os |
187 | + |
188 | + |
189 | +class report_nomina_resumen(report_sxw.rml_parse): |
190 | + """ Herencia a clase base para reportes de OpenERP |
191 | + """ |
192 | + _name = 'report.nomina.resumen' |
193 | + |
194 | + def __init__(self, cr, uid, name, context): |
195 | + """ Se sobrecarga el init para agregarle el context |
196 | + """ |
197 | + super(report_nomina_resumen, self).__init__(cr, uid, name, context) |
198 | + self.context = context |
199 | + |
200 | + |
201 | +report_sxw = report_sxw.report_sxw |
202 | + |
203 | + |
204 | +class TxtParser(report_sxw): |
205 | + def __init__(self, name, table, rml=False, parser=False, header=True, store=False): |
206 | + self.parser_instance = False |
207 | + self.localcontext = {} |
208 | + report_sxw.__init__(self, name, table, rml, parser, header, store) |
209 | + |
210 | + def create_single_pdf(self, cursor, uid, ids, data, report_xml, context): |
211 | + file = open(data['file'], 'r') |
212 | + output = file.read() |
213 | + os.remove(data['file']) |
214 | + return (output, 'ods') |
215 | + |
216 | + |
217 | +TxtParser('report.nomina.resumen', 'nomina.resumen', None, parser=report_nomina_resumen, header=False) |
218 | |
219 | === added directory 'sisb_nomina_resumen/security' |
220 | === added file 'sisb_nomina_resumen/security/groups.xml' |
221 | --- sisb_nomina_resumen/security/groups.xml 1970-01-01 00:00:00 +0000 |
222 | +++ sisb_nomina_resumen/security/groups.xml 2018-02-07 15:37:15 +0000 |
223 | @@ -0,0 +1,20 @@ |
224 | +<?xml version="1.0" encoding="utf-8"?> |
225 | +<openerp> |
226 | + <data noupdate="0"> |
227 | + <!-- Groups --> |
228 | + <record id="group_sisb_nomina_resumen" model="res.groups"> |
229 | + <field name="name">Nomina / Reporte Mensual</field> |
230 | + </record> |
231 | + <!-- Access to menues --> |
232 | + <record model="ir.ui.menu" id="hr.menu_hr_root"> |
233 | + <field eval="[(4, ref('group_sisb_nomina_resumen'))]" name="groups_id"/> |
234 | + </record> |
235 | + |
236 | + <record model="ir.ui.menu" id="hr.menu_hr_reporting"> |
237 | + <field eval="[(4, ref('group_sisb_nomina_resumen'))]" name="groups_id"/> |
238 | + </record> |
239 | + <record model="ir.ui.menu" id="sisb_nomina.menu_hr_payroll_reporting"> |
240 | + <field eval="[(4, ref('group_sisb_nomina_resumen'))]" name="groups_id"/> |
241 | + </record> |
242 | + </data> |
243 | +</openerp> |
244 | |
245 | === added file 'sisb_nomina_resumen/security/ir.model.access.csv' |
246 | --- sisb_nomina_resumen/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 |
247 | +++ sisb_nomina_resumen/security/ir.model.access.csv 2018-02-07 15:37:15 +0000 |
248 | @@ -0,0 +1,2 @@ |
249 | +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
250 | +access_sisb_nomina_resumen_hr_month,Resumen Nomina: hr.month,sisb_nomina.model_hr_month,group_sisb_nomina_resumen,1,0,0,0 |
251 | |
252 | === added directory 'sisb_nomina_resumen/wizard' |
253 | === added file 'sisb_nomina_resumen/wizard/__init__.py' |
254 | --- sisb_nomina_resumen/wizard/__init__.py 1970-01-01 00:00:00 +0000 |
255 | +++ sisb_nomina_resumen/wizard/__init__.py 2018-02-07 15:37:15 +0000 |
256 | @@ -0,0 +1,1 @@ |
257 | +import sisb_nomina_resumen |
258 | |
259 | === added file 'sisb_nomina_resumen/wizard/sisb_nomina_resumen.py' |
260 | --- sisb_nomina_resumen/wizard/sisb_nomina_resumen.py 1970-01-01 00:00:00 +0000 |
261 | +++ sisb_nomina_resumen/wizard/sisb_nomina_resumen.py 2018-02-07 15:37:15 +0000 |
262 | @@ -0,0 +1,253 @@ |
263 | +#!/usr/bin/env python |
264 | +# -*- coding: utf-8 -*- |
265 | +"""Modelos del modulo :Resumen mensual de nomina:""" |
266 | +from osv import fields, osv |
267 | +from tools.translate import _ |
268 | +from datetime import datetime |
269 | +import xlwt |
270 | + |
271 | + |
272 | +class FitCol(object): |
273 | + """Ajusta el ancho de las columnas automaticamente""" |
274 | + |
275 | + def __init__(self, sheet): |
276 | + self.sheet = sheet |
277 | + self.widths = dict() |
278 | + |
279 | + def write(self, r, c, label='', *args, **kwargs): |
280 | + if isinstance(label, str) and len(args) == 0: |
281 | + data = label.decode('utf-8') |
282 | + elif isinstance(label, str) and len(args) > 0: |
283 | + data = datetime.strptime(label, '%Y-%m-%d') |
284 | + else: |
285 | + data = label |
286 | + self.sheet.write(r, c, data, *args, **kwargs) |
287 | + if isinstance(label, (int, float)): |
288 | + label = str(label).decode('utf-8') |
289 | + width = (len(label) + 1) * 256 |
290 | + if width > self.widths.get(c, 0): |
291 | + self.widths[c] = width |
292 | + self.sheet.col(c).width = width |
293 | + |
294 | + def __getattr__(self, attr): |
295 | + return getattr(self.sheet, attr) |
296 | + |
297 | + |
298 | +class sisb_nomina_resumen(osv.osv_memory): |
299 | + """Asistente para el reporte del resumen de nomina""" |
300 | + _name = 'sisb.nomina.resumen' |
301 | + _columns = { |
302 | + 'month': fields.many2one('hr.month', 'Month', required=True) |
303 | + } |
304 | + |
305 | + def get_employees_data(self, cr, month): |
306 | + """ Query a Postgres para obtener informacion de los empleados en un mes. |
307 | + |
308 | + :param month: Nombre del mes a consultar. |
309 | + """ |
310 | + query = ''' |
311 | + SELECT |
312 | + hde.payroll as nom, |
313 | + he.name as emp, |
314 | + he.identification_id as ide, |
315 | + date_start_rel_laboral(he.id) as dst, |
316 | + hde.department_id as dpt, |
317 | + hde.job as job, |
318 | + case when hpl.type_calc = 'deduction' then 'debt' else 'bonus' end as typ, |
319 | + hc.name as con, |
320 | + sum(hpl.total) |
321 | + FROM |
322 | + hr_payslip_line as hpl |
323 | + join hr_payslip as hrp on hrp.id = hpl.slip_id |
324 | + join hr_employee as he on he.id = hpl.employee_id |
325 | + join hr_department_employee as hde on hde.employee_id = he.id |
326 | + and hde.date_start < hrp.date_from and (hde.date_end > hrp.date_from or hde.date_end is null) |
327 | + join hr_concept as hc on hc.id = hpl.concept_id and hc.type <> 'aporte_patronal' |
328 | + join hr_process as hp on hp.id = hpl.process_id and hp.type in ('nomina') |
329 | + join hr_period_process_rel as hppr on hppr.process_id = hp.id |
330 | + join hr_period as hpe on hpe.id = hppr.period_id |
331 | + join hr_month as hm on hm.id = hpe.hr_month_id and hm.name = '%s' |
332 | + WHERE appears_on_payslip = True |
333 | + group by emp, con, typ, ide, nom, dst, dpt, job |
334 | + order by emp, typ, con |
335 | + ''' % (month) |
336 | + |
337 | + cr.execute(query) |
338 | + employees = {} |
339 | + for roster, name, identification, join_date, department, job, asign, concept, total in cr.fetchall(): |
340 | + if identification not in employees: |
341 | + employees[identification] = {} |
342 | + employees[identification]['roster'] = roster |
343 | + employees[identification]['name'] = name |
344 | + employees[identification]['identification'] = identification |
345 | + employees[identification]['join_date'] = join_date |
346 | + employees[identification]['department'] = department |
347 | + employees[identification]['job'] = job |
348 | + if 'bonuses' not in employees[identification]: |
349 | + employees[identification]['bonuses'] = {} |
350 | + if 'debts' not in employees[identification]: |
351 | + employees[identification]['debts'] = {} |
352 | + if asign == 'bonus': |
353 | + employees[identification]['bonuses'][concept] = total |
354 | + else: |
355 | + employees[identification]['debts'][concept] = total |
356 | + |
357 | + return employees |
358 | + |
359 | + def get_concepts_header(self, cr, month): |
360 | + """ Query que se trae todos los conceptos de asignaciones y deducciones de los trabajadores en el mes indicado. |
361 | + |
362 | + :param month: Nombre del mes a consultar. |
363 | + """ |
364 | + query = ''' |
365 | + SELECT |
366 | + case when hpl.type_calc = 'deduction' then 'debt' else 'bonus' end as asigned, |
367 | + hc.name as concept, |
368 | + hc.code as code |
369 | + FROM |
370 | + hr_payslip_line as hpl |
371 | + join hr_employee as he on he.id = hpl.employee_id |
372 | + join hr_payroll as hno on hno.id = he.hr_payroll_id |
373 | + join hr_concept as hc on hc.id = hpl.concept_id and hc.type <> 'aporte_patronal' |
374 | + join hr_process as hp on hp.id = hpl.process_id and hp.type in ('nomina') |
375 | + join hr_period_process_rel as hppr on hppr.process_id = hp.id |
376 | + join hr_period as hpe on hpe.id = hppr.period_id |
377 | + join hr_month as hm on hm.id = hpe.hr_month_id and hm.name = '%s' |
378 | + WHERE appears_on_payslip = True |
379 | + group by concept, asigned, hc.code |
380 | + order by asigned, concept |
381 | + ''' % (month) |
382 | + |
383 | + cr.execute(query) |
384 | + bonuses = [''] |
385 | + debts = [] |
386 | + for row in cr.fetchall(): |
387 | + con_type, concept, code = row |
388 | + if con_type == 'bonus': |
389 | + if code == '0100': |
390 | + bonuses[0] = concept |
391 | + else: |
392 | + bonuses.append(concept) |
393 | + else: |
394 | + debts.append(concept) |
395 | + |
396 | + return {'bonuses': bonuses, 'debts': debts} |
397 | + |
398 | + def get_payrolls_pages(self, cr, month): |
399 | + """ Query que se trae los nombres de las nominas de los trabajadores del mes indicado. |
400 | + |
401 | + :param month: Nombre del mes a consultar. |
402 | + """ |
403 | + query = ''' |
404 | + SELECT |
405 | + hde.payroll as roster |
406 | + FROM |
407 | + hr_payslip_line as hpl |
408 | + join hr_payslip as hrp on hrp.id = hpl.slip_id |
409 | + join hr_employee as he on he.id = hpl.employee_id |
410 | + join hr_payroll as hno on hno.id = he.hr_payroll_id |
411 | + join hr_department_employee as hde on hde.employee_id = he.id and hde.date_start < hrp.date_from |
412 | + and (hde.date_end > hrp.date_from or hde.date_end is null) |
413 | + join hr_process as hp on hp.id = hpl.process_id and hp.type in ('nomina') |
414 | + join hr_period_process_rel as hppr on hppr.process_id = hp.id |
415 | + join hr_period as hpe on hpe.id = hppr.period_id |
416 | + join hr_month as hm on hm.id = hpe.hr_month_id and hm.name = '%s' |
417 | + WHERE appears_on_payslip = True |
418 | + group by roster |
419 | + ''' % (month) |
420 | + |
421 | + cr.execute(query) |
422 | + return [row[0] for row in cr.fetchall()] |
423 | + |
424 | + def print_results(self, cr, uid, ids, context=None): |
425 | + """ Funcion llamada por el wizard para imprimir los resultados. |
426 | + """ |
427 | + month = self.browse(cr, uid, ids)[0].month.name |
428 | + rosters = self.get_payrolls_pages(cr, month) |
429 | + doc = xlwt.Workbook() |
430 | + pages = {} |
431 | + j = {} # Seran los indices de las filas de cada pagina |
432 | + for roster in rosters: |
433 | + roster = roster[:31] # Por limitaciones de los archivos xls, los nombres de paginas no pueden exceder los 31 caracteres |
434 | + # Se crean las paginas y se guardan. Se le van creando las cabeceras |
435 | + pages[roster] = doc.add_sheet(roster, True) |
436 | + pages[roster].protect = True |
437 | + pages[roster] = FitCol(pages[roster]) |
438 | + pages[roster].write(0, 0, _('N°')) |
439 | + pages[roster].write(0, 1, _('Employee')) |
440 | + pages[roster].write(0, 2, _('Identification')) |
441 | + pages[roster].write(0, 3, _('Join date')) |
442 | + pages[roster].write(0, 4, _('Department')) |
443 | + pages[roster].write(0, 5, _('Job')) |
444 | + j[roster] = 1 |
445 | + |
446 | + # Se procede a crear las cabeceras de conceptos en cada una de las paginas |
447 | + i = 6 # Columns index |
448 | + columns = {} |
449 | + concepts = self.get_concepts_header(cr, month) |
450 | + bonuses = concepts['bonuses'] |
451 | + debts = concepts['debts'] |
452 | + for bonus in bonuses: |
453 | + for page in pages.values(): |
454 | + page.write(0, i, bonus) |
455 | + columns[bonus] = i |
456 | + i += 1 |
457 | + for page in pages.values(): |
458 | + page.write(0, i, _('Total bonuses')) |
459 | + columns['bonuses'] = i |
460 | + i += 1 |
461 | + for debt in debts: |
462 | + for page in pages.values(): |
463 | + page.write(0, i, debt) |
464 | + columns[debt] = i |
465 | + i += 1 |
466 | + for page in pages.values(): |
467 | + page.write(0, i, _('Total debts')) |
468 | + columns['debts'] = i |
469 | + i += 1 |
470 | + for page in pages.values(): |
471 | + page.write(0, i, _('Net Total')) |
472 | + columns['net_total'] = i |
473 | + |
474 | + # -------- EMPEZAMOS A LLENAR LA DATA DE LOS TRABAJADORES ------------ |
475 | + datas = self.get_employees_data(cr, month) |
476 | + date_format = xlwt.XFStyle() |
477 | + date_format.num_format_str = 'dd/mm/yyyy' |
478 | + currency_format = xlwt.XFStyle() |
479 | + currency_format.num_format_str = "#,##0.00" |
480 | + for data in datas: |
481 | + n = datas[data]['roster'][:31] |
482 | + pages[n].write(j[n], 0, j[n]) |
483 | + pages[n].write(j[n], 1, datas[data]['name']) |
484 | + pages[n].write(j[n], 2, int(datas[data]['identification'])) |
485 | + pages[n].write(j[n], 3, datas[data]['join_date'], date_format) |
486 | + pages[n].write(j[n], 4, datas[data]['department']) |
487 | + pages[n].write(j[n], 5, datas[data]['job']) |
488 | + total_bonuses = 0 |
489 | + for bonus in datas[data]['bonuses']: |
490 | + pages[n].write(j[n], columns[bonus], datas[data]['bonuses'][bonus], currency_format) |
491 | + total_bonuses += datas[data]['bonuses'][bonus] |
492 | + pages[n].write(j[n], columns['bonuses'], total_bonuses, currency_format) |
493 | + total_debts = 0 |
494 | + for debt in datas[data]['debts']: |
495 | + pages[n].write(j[n], columns[debt], datas[data]['debts'][debt], currency_format) |
496 | + total_debts += datas[data]['debts'][debt] |
497 | + pages[n].write(j[n], columns['debts'], total_debts, currency_format) |
498 | + pages[n].write(j[n], columns['net_total'], total_bonuses - total_debts, currency_format) |
499 | + j[n] += 1 |
500 | + try: |
501 | + file_name = '/tmp/' + _('roster_report_') + datetime.now().strftime('%H%M%S%d%m%Y') |
502 | + doc.save(file_name) |
503 | + except: |
504 | + raise osv.except_osv('ERROR', _('No data found')) |
505 | + |
506 | + data = {} |
507 | + data['file'] = file_name |
508 | + return { |
509 | + 'type': 'ir.actions.report.xml', |
510 | + 'report_name': 'nomina.resumen', |
511 | + 'datas': data, |
512 | + } |
513 | + |
514 | + |
515 | +sisb_nomina_resumen() |
516 | |
517 | === added file 'sisb_nomina_resumen/wizard/sisb_nomina_resumen_wizard.xml' |
518 | --- sisb_nomina_resumen/wizard/sisb_nomina_resumen_wizard.xml 1970-01-01 00:00:00 +0000 |
519 | +++ sisb_nomina_resumen/wizard/sisb_nomina_resumen_wizard.xml 2018-02-07 15:37:15 +0000 |
520 | @@ -0,0 +1,38 @@ |
521 | +<?xml version="1.0" encoding="utf-8"?> |
522 | +<openerp> |
523 | + <data> |
524 | + <!-- Wizard view --> |
525 | + <record id="view_sisb_nomina_resumen" model="ir.ui.view"> |
526 | + <field name="name">sisb.nomina.resumen.form</field> |
527 | + <field name="model">sisb.nomina.resumen</field> |
528 | + <field name="type">form</field> |
529 | + <field name="arch" type="xml"> |
530 | + <form> |
531 | + <field name="month" /> |
532 | + <button name="print_results" string="Print" type="object" icon="gtk-print" /> |
533 | + </form> |
534 | + </field> |
535 | + </record> |
536 | + <!-- Action --> |
537 | + <record id="action_wizard_sisb_nomina_resumen" model="ir.actions.act_window"> |
538 | + <field name="name">Resumen mensual de nomina</field> |
539 | + <field name="type">ir.actions.act_window</field> |
540 | + <field name="res_model">sisb.nomina.resumen</field> |
541 | + <field name="view_type">form</field> |
542 | + <field name="view_mode">form</field> |
543 | + <field name="target">new</field> |
544 | + </record> |
545 | + <!-- Report --> |
546 | + <report |
547 | + auto="False" |
548 | + id="report_nomina_resumen" |
549 | + model="sisb.nomina.resumen" |
550 | + name="nomina.resumen" |
551 | + rml="" |
552 | + string="Reporte de nomina" |
553 | + /> |
554 | + <!-- Menu --> |
555 | + <menuitem id="menu_wizard_sisb_nomina_resumen" action="action_wizard_sisb_nomina_resumen" |
556 | + parent="sisb_nomina.menu_hr_payroll_reporting" name="Resumen mensual de nomina" groups="group_sisb_nomina_resumen" /> |
557 | + </data> |
558 | +</openerp> |