Merge lp:~inddiana/sisb/sisb_reporte_pasivo_max_vacaciones into lp:sisb
- sisb_reporte_pasivo_max_vacaciones
- Merge into sisb
Proposed by
[SISB] Marvi Diaz
Status: | Merged |
---|---|
Merged at revision: | 982 |
Proposed branch: | lp:~inddiana/sisb/sisb_reporte_pasivo_max_vacaciones |
Merge into: | lp:sisb |
Diff against target: |
723 lines (+205/-196) 2 files modified
sisb_nomina/wizard/reporte_pasivo_maximo_vacaciones.py (+188/-181) sisb_nomina/wizard/reporte_pasivo_maximo_vacaciones.xml (+17/-15) |
To merge this branch: | bzr merge lp:~inddiana/sisb/sisb_reporte_pasivo_max_vacaciones |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Industrias Diana | Pending | ||
Review via email: mp+334136@code.launchpad.net |
Commit message
Description of the change
[IMP] se modifico sisb_nomina/
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 'sisb_nomina/wizard/reporte_pasivo_maximo_vacaciones.py' | |||
2 | --- sisb_nomina/wizard/reporte_pasivo_maximo_vacaciones.py 2016-11-23 11:59:11 +0000 | |||
3 | +++ sisb_nomina/wizard/reporte_pasivo_maximo_vacaciones.py 2017-11-22 18:25:51 +0000 | |||
4 | @@ -1,9 +1,7 @@ | |||
5 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
6 | 2 | 2 | ||
7 | 3 | import time | ||
8 | 4 | from osv import fields, osv | 3 | from osv import fields, osv |
9 | 5 | from datetime import datetime | 4 | from datetime import datetime |
10 | 6 | import pooler | ||
11 | 7 | import calendar | 5 | import calendar |
12 | 8 | import logging | 6 | import logging |
13 | 9 | import netsvc | 7 | import netsvc |
14 | @@ -12,9 +10,10 @@ | |||
15 | 12 | _name = "wizard.maximum.passive.holiday" | 10 | _name = "wizard.maximum.passive.holiday" |
16 | 13 | _logger = logging.getLogger('wizard.maximum.passive.holiday') | 11 | _logger = logging.getLogger('wizard.maximum.passive.holiday') |
17 | 14 | _columns = { | 12 | _columns = { |
19 | 15 | 'type_report': fields.selection([('resumido', 'Resumido'),('detallado', 'Detallado')], 'Reporte', select=True, required=True), | 13 | 'type_report': fields.selection([(False, ''),('detallado', 'Detallado'),('resumido', 'Resumido')], 'Reporte', select=True, required=True), |
20 | 16 | 'sede_id': fields.many2one('hr.sede', 'Sede'), | 14 | 'sede_id': fields.many2one('hr.sede', 'Sede'), |
21 | 17 | 'for_sede': fields.boolean(''), | 15 | 'for_sede': fields.boolean(''), |
22 | 16 | 'basic': fields.boolean('Incluir sueldo basico'), | ||
23 | 18 | 'mes': fields.many2one('hr.month', 'Mes', required=True), | 17 | 'mes': fields.many2one('hr.month', 'Mes', required=True), |
24 | 19 | } | 18 | } |
25 | 20 | _defaults = {'for_sede': True} | 19 | _defaults = {'for_sede': True} |
26 | @@ -23,7 +22,7 @@ | |||
27 | 23 | smtp_client = self.pool.get('email.smtpclient') | 22 | smtp_client = self.pool.get('email.smtpclient') |
28 | 24 | smtp_server = smtp_client.search(cr, uid, [('active','=',True),('state','=','confirm')], context=False) | 23 | smtp_server = smtp_client.search(cr, uid, [('active','=',True),('state','=','confirm')], context=False) |
29 | 25 | if not smtp_server: | 24 | if not smtp_server: |
31 | 26 | raise osv.except_osv(_('Acción Denegada!'), _('Debe configurar un servidor de correos para generar el reporte')) | 25 | raise osv.except_osv(('Acción Denegada!'), ('Debe configurar un servidor de correos para generar el reporte')) |
32 | 27 | return True | 26 | return True |
33 | 28 | 27 | ||
34 | 29 | def _check_user_email_adress(self, cr, uid, ids, context=None): | 28 | def _check_user_email_adress(self, cr, uid, ids, context=None): |
35 | @@ -35,8 +34,6 @@ | |||
36 | 35 | def _calcular_regla(self, cr, uid, rule, localdict, employee, context): | 34 | def _calcular_regla(self, cr, uid, rule, localdict, employee, context): |
37 | 36 | obj_rule = self.pool.get('hr.salary.rule') | 35 | obj_rule = self.pool.get('hr.salary.rule') |
38 | 37 | amount, qty, rate = obj_rule.compute_rule(cr, uid, rule.id, localdict, context=context) | 36 | amount, qty, rate = obj_rule.compute_rule(cr, uid, rule.id, localdict, context=context) |
39 | 38 | previous_amount = rule.code in localdict and localdict[rule.code] or 0.0 | ||
40 | 39 | tot_rule = amount * qty * rate / 100.0 | ||
41 | 40 | return { | 37 | return { |
42 | 41 | 'salary_rule_id': rule.id, | 38 | 'salary_rule_id': rule.id, |
43 | 42 | 'name': rule.name, | 39 | 'name': rule.name, |
44 | @@ -128,7 +125,24 @@ | |||
45 | 128 | return float(salario[-1][-1]) | 125 | return float(salario[-1][-1]) |
46 | 129 | return '' | 126 | return '' |
47 | 130 | 127 | ||
49 | 131 | def get_payslip_lines(self, cr, uid, structure_brw, employee, list_concept_codes, fecha_creada): | 128 | |
50 | 129 | def remuneracion(self, cr, uid, employee_id, date_from): | ||
51 | 130 | |||
52 | 131 | monto = 0.0 | ||
53 | 132 | payslip = self.pool.get('hr.payslip') | ||
54 | 133 | payslip_line = self.pool.get('hr.payslip.line') | ||
55 | 134 | payslip_id = payslip.search(cr, uid, [('employee_id', '=', employee_id), ('type_process', '=', 'nomina'), ('state', '=', 'done'),('date_from','<=',date_from)], limit=1) | ||
56 | 135 | if payslip_id: | ||
57 | 136 | payslip_line_id = payslip_line.search(cr, uid, [('slip_id', '=', payslip_id), ('code', '=', 'SD')] ) | ||
58 | 137 | if not payslip_line_id: | ||
59 | 138 | payslip_id = payslip.search(cr, uid, [('employee_id', '=', employee_id), ('type_process', '=', 'nomina'), ('state', '=', 'done'), ('line_ids.code','=','SD')], limit=1) | ||
60 | 139 | payslip_line_id = payslip_line.search(cr, uid, [('slip_id', '=', payslip_id), ('code', '=', 'SD')] ) | ||
61 | 140 | payslip_line_brw = payslip_line.browse(cr, uid, payslip_line_id[0]) | ||
62 | 141 | monto = payslip_line_brw.amount | ||
63 | 142 | return monto | ||
64 | 143 | |||
65 | 144 | |||
66 | 145 | def get_payslip_lines(self, cr, uid, structure_brw, employee, list_concept_codes, fecha_creada, context): | ||
67 | 132 | 146 | ||
68 | 133 | obj_rule = self.pool.get('hr.salary.rule') | 147 | obj_rule = self.pool.get('hr.salary.rule') |
69 | 134 | obj_line_liq = self.pool.get('hr.linea.liquidacion') | 148 | obj_line_liq = self.pool.get('hr.linea.liquidacion') |
70 | @@ -137,14 +151,14 @@ | |||
71 | 137 | fecha_liquidacion = datetime.strptime(fecha_creada,"%Y-%m-%d") | 151 | fecha_liquidacion = datetime.strptime(fecha_creada,"%Y-%m-%d") |
72 | 138 | 152 | ||
73 | 139 | period = self.pool.get('hr.period').search(cr, uid, [ | 153 | period = self.pool.get('hr.period').search(cr, uid, [ |
76 | 140 | ('date_start','<=', fecha_liquidacion), | 154 | ('date_start','<=', fecha_liquidacion),('date_end','>=', fecha_liquidacion), |
75 | 141 | ('date_end','>=', fecha_liquidacion), | ||
77 | 142 | ('type','=',employee.hr_payroll_id.hr_payment_calendar_id.type)]) | 155 | ('type','=',employee.hr_payroll_id.hr_payment_calendar_id.type)]) |
78 | 143 | 156 | ||
79 | 144 | period = self.pool.get('hr.period').browse(cr, uid, period[0]) | 157 | period = self.pool.get('hr.period').browse(cr, uid, period[0]) |
80 | 145 | 158 | ||
81 | 146 | #se obtienen los conceptos de la estructura salarial | 159 | #se obtienen los conceptos de la estructura salarial |
82 | 147 | rule_ids = self.pool.get('hr.payroll.structure').get_all_rules(cr, uid, [structure_brw.id], employee, period.id, context=None) | 160 | rule_ids = self.pool.get('hr.payroll.structure').get_all_rules(cr, uid, [structure_brw.id], employee, period.id, context=None) |
83 | 161 | |||
84 | 148 | sorted_rule_ids = [id for id, sequence in sorted(rule_ids, key=lambda x:x[1])] | 162 | sorted_rule_ids = [id for id, sequence in sorted(rule_ids, key=lambda x:x[1])] |
85 | 149 | 163 | ||
86 | 150 | # vac_vencidas: Lista de tuplas. Cada tupla tiene la forma (vac_vencida, num_dias_adicionales) | 164 | # vac_vencidas: Lista de tuplas. Cada tupla tiene la forma (vac_vencida, num_dias_adicionales) |
87 | @@ -154,34 +168,28 @@ | |||
88 | 154 | employee_hol_brw = False | 168 | employee_hol_brw = False |
89 | 155 | 169 | ||
90 | 156 | if employee_hol_ids: | 170 | if employee_hol_ids: |
91 | 171 | |||
92 | 157 | employee_hol_brw = self.pool.get('hr.employee.holidays').browse(cr, uid, employee_hol_ids[0], context=None) | 172 | employee_hol_brw = self.pool.get('hr.employee.holidays').browse(cr, uid, employee_hol_ids[0], context=None) |
93 | 158 | employee_hol_date = datetime.strptime(employee_hol_brw.corresp_to_end,"%Y-%m-%d") | 173 | employee_hol_date = datetime.strptime(employee_hol_brw.corresp_to_end,"%Y-%m-%d") |
94 | 174 | |||
95 | 159 | #Se cancelan 1 dia adicional por año a partir del 2º año | 175 | #Se cancelan 1 dia adicional por año a partir del 2º año |
103 | 160 | dias_adicionales = employee_hol_date.year-start_rel_lab.year-1 if \ | 176 | dias_adicionales = employee_hol_date.year-start_rel_lab.year-1 if employee_hol_date.year-start_rel_lab.year > 1 else 0 |
104 | 161 | employee_hol_date.year-start_rel_lab.year > 1 else 0 | 177 | dias_adicionales = dias_adicionales if dias_adicionales < 15 else 15 |
105 | 162 | dias_adicionales = dias_adicionales if dias_adicionales < 15 \ | 178 | num_vac_vencidas = (fecha_liquidacion.year - employee_hol_date.year) if fecha_liquidacion.month >= employee_hol_date.month else (fecha_liquidacion.year - employee_hol_date.year - 1) |
106 | 163 | else 15 | 179 | |
100 | 164 | num_vac_vencidas = (fecha_liquidacion.year - employee_hol_date.year) if \ | ||
101 | 165 | fecha_liquidacion.month >= employee_hol_date.month else \ | ||
102 | 166 | (fecha_liquidacion.year - employee_hol_date.year - 1) | ||
107 | 167 | for x in range(num_vac_vencidas): | 180 | for x in range(num_vac_vencidas): |
110 | 168 | vac_vencidas.append((employee_hol_date.year+x, dias_adicionales + \ | 181 | dias_adicionales = dias_adicionales + 1 if dias_adicionales < 15 else 15 |
111 | 169 | 1 if dias_adicionales < 15 else 15)) | 182 | vac_vencidas.append((employee_hol_date.year + x, dias_adicionales)) |
112 | 170 | else: | 183 | else: |
113 | 171 | new_date = datetime(start_rel_lab.year, start_rel_lab.month, start_rel_lab.day) | 184 | new_date = datetime(start_rel_lab.year, start_rel_lab.month, start_rel_lab.day) |
117 | 172 | num_vac_vencidas = (fecha_liquidacion.year - new_date.year) if \ | 185 | num_vac_vencidas = (fecha_liquidacion.year - new_date.year) if fecha_liquidacion.month > new_date.month else (fecha_liquidacion.year - new_date.year - 1) |
115 | 173 | fecha_liquidacion.month > new_date.month else \ | ||
116 | 174 | (fecha_liquidacion.year - new_date.year - 1) | ||
118 | 175 | 186 | ||
119 | 176 | for x in range(num_vac_vencidas): | 187 | for x in range(num_vac_vencidas): |
120 | 177 | dias_adicionales = x | 188 | dias_adicionales = x |
123 | 178 | vac_vencidas.append((new_date.year + x, dias_adicionales \ | 189 | vac_vencidas.append((new_date.year + x, dias_adicionales if dias_adicionales < 15 else 15)) |
122 | 179 | if dias_adicionales < 15 else 15)) | ||
124 | 180 | 190 | ||
125 | 181 | new_date = datetime(start_rel_lab.year, start_rel_lab.month, start_rel_lab.day) | 191 | new_date = datetime(start_rel_lab.year, start_rel_lab.month, start_rel_lab.day) |
129 | 182 | 192 | ultimo_anio_pagado = datetime.strptime(employee_hol_brw.corresp_to_end,"%Y-%m-%d") if employee_hol_brw else new_date | |
127 | 183 | ultimo_anio_pagado = datetime.strptime(employee_hol_brw.corresp_to_end,"%Y-%m-%d") \ | ||
128 | 184 | if employee_hol_brw else new_date | ||
130 | 185 | 193 | ||
131 | 186 | reg_vac_no_disf = obj_line_liq.vacaciones_no_disfrutadas(cr, uid, employee) | 194 | reg_vac_no_disf = obj_line_liq.vacaciones_no_disfrutadas(cr, uid, employee) |
132 | 187 | 195 | ||
133 | @@ -216,7 +224,6 @@ | |||
134 | 216 | } | 224 | } |
135 | 217 | 225 | ||
136 | 218 | localdict.update({'empleado': employee,}) | 226 | localdict.update({'empleado': employee,}) |
137 | 219 | param_fp_id = parameter_obj.search(cr, uid, [('type', '=', 'fecha_prest')]) | ||
138 | 220 | 227 | ||
139 | 221 | parameters_dict = {} | 228 | parameters_dict = {} |
140 | 222 | for parameter in employee.hr_payroll_id.parameters_ids: | 229 | for parameter in employee.hr_payroll_id.parameters_ids: |
141 | @@ -224,39 +231,41 @@ | |||
142 | 224 | 231 | ||
143 | 225 | localdict.update({'parametros': parameters_dict,}) | 232 | localdict.update({'parametros': parameters_dict,}) |
144 | 226 | localdict['periodo'] = period | 233 | localdict['periodo'] = period |
149 | 227 | rules_dict = {} | 234 | |
146 | 228 | rules_dict['SUELDO'] = self._sueldo(employee.id, fecha_creada, cr, uid) | ||
147 | 229 | localdict['concepto'] = rules_dict | ||
148 | 230 | |||
150 | 231 | categories_concept_dict={} | 235 | categories_concept_dict={} |
151 | 232 | blacklist = {} | 236 | blacklist = {} |
152 | 233 | result_dict = {} | 237 | result_dict = {} |
153 | 234 | 238 | ||
154 | 235 | for rule in obj_rule.browse(cr, uid, sorted_rule_ids, context=None): | 239 | for rule in obj_rule.browse(cr, uid, sorted_rule_ids, context=None): |
155 | 240 | |||
156 | 236 | key = rule.code | 241 | key = rule.code |
157 | 237 | if key in list_concept_codes: | 242 | if key in list_concept_codes: |
158 | 243 | rules_dict = {} | ||
159 | 244 | |||
160 | 245 | if key == 'VND': | ||
161 | 246 | rules_dict['SUELDO'] = self._sueldo(employee.id, fecha_creada, cr, uid) | ||
162 | 247 | elif key == 'DAV190' or key == 'V190': | ||
163 | 248 | rules_dict['SD'] = self.remuneracion(cr, uid, employee.id, fecha_liquidacion) | ||
164 | 249 | |||
165 | 250 | localdict['concepto'] = rules_dict | ||
166 | 238 | localdict['result'] = None | 251 | localdict['result'] = None |
167 | 239 | localdict['result_qty'] = localdict['cantidad'] = 1.0 | 252 | localdict['result_qty'] = localdict['cantidad'] = 1.0 |
169 | 240 | 253 | inicial_dict = self._calcular_regla(cr, uid, rule, localdict, employee, context=None) | |
170 | 254 | amount = inicial_dict['amount'] | ||
171 | 255 | qty = localdict['cantidad'] = inicial_dict['quantity'] | ||
172 | 256 | |||
173 | 241 | if obj_rule.satisfy_condition(cr, uid, rule.id, localdict, context=None) and rule.id not in blacklist: | 257 | if obj_rule.satisfy_condition(cr, uid, rule.id, localdict, context=None) and rule.id not in blacklist: |
174 | 242 | inicial_dict = self._calcular_regla(cr, uid, rule, localdict, employee, context=None) | ||
175 | 243 | amount = inicial_dict['amount'] | ||
176 | 244 | qty = localdict['cantidad'] = inicial_dict['quantity'] | ||
177 | 245 | 258 | ||
184 | 246 | if rule.code == concept_vac_ven_brw.code or rule.code == \ | 259 | if rule.code == concept_vac_ven_brw.code or rule.code == concept_dias_vac_ven_brw.code: |
185 | 247 | concept_dias_vac_ven_brw.code: | 260 | |
186 | 248 | 261 | qty_concept = parameters_dict['vacaciones'] if rule.code == concept_vac_ven_brw.code else 15 | |
181 | 249 | qty_concept = parameters_dict['vacaciones'] \ | ||
182 | 250 | if rule.code == concept_vac_ven_brw.code else 15 | ||
183 | 251 | |||
187 | 252 | desde = datetime.strptime(employee.start_rel_lab,"%Y-%m-%d") | 262 | desde = datetime.strptime(employee.start_rel_lab,"%Y-%m-%d") |
191 | 253 | 263 | num_vac = len(vac_vencidas) if (desde.month == fecha_liquidacion.month and desde.day == fecha_liquidacion.day) else len(vac_vencidas) + 1 | |
189 | 254 | num_vac = len(vac_vencidas) if (desde.month == fecha_liquidacion.month and | ||
190 | 255 | desde.day == fecha_liquidacion.day) else len(vac_vencidas) + 1 | ||
192 | 256 | 264 | ||
193 | 257 | for c in range(num_vac): | 265 | for c in range(num_vac): |
195 | 258 | 266 | ||
196 | 259 | if fecha_liquidacion.year > desde.year: | 267 | if fecha_liquidacion.year > desde.year: |
197 | 268 | |||
198 | 260 | if fecha_liquidacion.month == desde.month: | 269 | if fecha_liquidacion.month == desde.month: |
199 | 261 | if fecha_liquidacion.day < desde.day: | 270 | if fecha_liquidacion.day < desde.day: |
200 | 262 | meses = 12 - desde.month + fecha_liquidacion.month - 1 | 271 | meses = 12 - desde.month + fecha_liquidacion.month - 1 |
201 | @@ -267,50 +276,44 @@ | |||
202 | 267 | meses = 12 | 276 | meses = 12 |
203 | 268 | 277 | ||
204 | 269 | elif fecha_liquidacion.month < desde.month: | 278 | elif fecha_liquidacion.month < desde.month: |
205 | 279 | |||
206 | 270 | if fecha_liquidacion.day < desde.day: | 280 | if fecha_liquidacion.day < desde.day: |
207 | 271 | meses = 12 - desde.month + fecha_liquidacion.month - 1 | 281 | meses = 12 - desde.month + fecha_liquidacion.month - 1 |
208 | 272 | else: | 282 | else: |
209 | 273 | meses = 12 - desde.month + fecha_liquidacion.month | 283 | meses = 12 - desde.month + fecha_liquidacion.month |
210 | 274 | else: | 284 | else: |
211 | 285 | |||
212 | 275 | meses = fecha_liquidacion.month - desde.month | 286 | meses = fecha_liquidacion.month - desde.month |
213 | 276 | if fecha_liquidacion.day < desde.day: | 287 | if fecha_liquidacion.day < desde.day: |
214 | 277 | meses = fecha_liquidacion.month - desde.month - 1 | 288 | meses = fecha_liquidacion.month - desde.month - 1 |
215 | 278 | else: | 289 | else: |
216 | 279 | meses = fecha_liquidacion.month - desde.month | 290 | meses = fecha_liquidacion.month - desde.month |
217 | 280 | else: | 291 | else: |
218 | 292 | |||
219 | 281 | meses = fecha_liquidacion.month - desde.month | 293 | meses = fecha_liquidacion.month - desde.month |
220 | 294 | |||
221 | 282 | if fecha_liquidacion.day < desde.day: | 295 | if fecha_liquidacion.day < desde.day: |
222 | 283 | meses = fecha_liquidacion.month - desde.month - 1 | 296 | meses = fecha_liquidacion.month - desde.month - 1 |
223 | 284 | else: | 297 | else: |
224 | 285 | meses = fecha_liquidacion.month - desde.month | 298 | meses = fecha_liquidacion.month - desde.month |
225 | 286 | 299 | ||
230 | 287 | qty = qty_concept if ((ultimo_anio_pagado.year+c < fecha_liquidacion.year-1) or \ | 300 | qty = qty_concept if ((ultimo_anio_pagado.year+c < fecha_liquidacion.year-1) or (ultimo_anio_pagado.year+c == fecha_liquidacion.year-1 and fecha_liquidacion.month > ultimo_anio_pagado.month)) else float(qty_concept)/12*meses |
227 | 288 | (ultimo_anio_pagado.year+c == fecha_liquidacion.year-1 and \ | ||
228 | 289 | fecha_liquidacion.month > ultimo_anio_pagado.month)) \ | ||
229 | 290 | else float(qty_concept)/12*meses | ||
231 | 291 | 301 | ||
232 | 292 | key_ = key + '-' + str(ultimo_anio_pagado.year+c) | 302 | key_ = key + '-' + str(ultimo_anio_pagado.year+c) |
233 | 303 | |||
234 | 293 | result_dict[key_] = inicial_dict.copy() | 304 | result_dict[key_] = inicial_dict.copy() |
235 | 305 | |||
236 | 294 | result_dict[key_].update({ | 306 | result_dict[key_].update({ |
237 | 295 | 'name': rule.name, | 307 | 'name': rule.name, |
249 | 296 | 'periodo': 'Periodo ' + str(ultimo_anio_pagado.year+c) \ | 308 | 'periodo': 'Periodo ' + str(ultimo_anio_pagado.year+c) + '-' + str(ultimo_anio_pagado.year+1+c) if qty == qty_concept else 'Fraccion periodo ' + str(fecha_liquidacion.year) + '-' + str(fecha_liquidacion.year+1) if fecha_liquidacion.month > ultimo_anio_pagado.month else 'Fraccion periodo ' + str(fecha_liquidacion.year-1) + '-' + str(fecha_liquidacion.year), 'quantity': qty, |
239 | 297 | + '-' + str(ultimo_anio_pagado.year+1+c)\ | ||
240 | 298 | if qty == qty_concept \ | ||
241 | 299 | else 'Fraccion periodo ' + \ | ||
242 | 300 | str(fecha_liquidacion.year) \ | ||
243 | 301 | + '-' + str(fecha_liquidacion.year+1) if \ | ||
244 | 302 | fecha_liquidacion.month > ultimo_anio_pagado.month else | ||
245 | 303 | 'Fraccion periodo ' + \ | ||
246 | 304 | str(fecha_liquidacion.year-1) \ | ||
247 | 305 | + '-' + str(fecha_liquidacion.year), | ||
248 | 306 | 'quantity': qty, | ||
250 | 307 | }) | 309 | }) |
251 | 308 | rules_dict[key_] = amount * qty or 0.0 | 310 | rules_dict[key_] = amount * qty or 0.0 |
252 | 309 | localdict['concepto'] = rules_dict | 311 | localdict['concepto'] = rules_dict |
253 | 310 | 312 | ||
254 | 311 | elif rule.code == concept_dias_adic_vac_ven_brw.code: | 313 | elif rule.code == concept_dias_adic_vac_ven_brw.code: |
256 | 312 | 314 | ||
257 | 313 | for c in range(len(vac_vencidas)): | 315 | for c in range(len(vac_vencidas)): |
258 | 316 | |||
259 | 314 | qty = vac_vencidas[c][1] | 317 | qty = vac_vencidas[c][1] |
260 | 315 | key_ = key + '-' + str(ultimo_anio_pagado.year+c) | 318 | key_ = key + '-' + str(ultimo_anio_pagado.year+c) |
261 | 316 | result_dict[key_] = inicial_dict.copy() | 319 | result_dict[key_] = inicial_dict.copy() |
262 | @@ -334,79 +337,56 @@ | |||
263 | 334 | localdict['concepto'] = rules_dict | 337 | localdict['concepto'] = rules_dict |
264 | 335 | 338 | ||
265 | 336 | elif rule.code == concept_vac_no_disf_brw.code: | 339 | elif rule.code == concept_vac_no_disf_brw.code: |
266 | 340 | |||
267 | 337 | for _vac in reg_vac_no_disf: | 341 | for _vac in reg_vac_no_disf: |
268 | 342 | |||
269 | 338 | anio = datetime.strptime(_vac.employee_holidays_add_id.corresp_to_end,"%Y-%m-%d").year | 343 | anio = datetime.strptime(_vac.employee_holidays_add_id.corresp_to_end,"%Y-%m-%d").year |
270 | 339 | tipo = _vac.name[_vac.name.find('/')+13:] | ||
271 | 340 | qty = reg_vac_no_disf[_vac] | 344 | qty = reg_vac_no_disf[_vac] |
273 | 341 | key_ = key + '-' + str(_vac.name[_vac.name.find('/')+2:]) | 345 | key_ = key + '-' + str(_vac.name[_vac.name.find('/') + 2:]) |
274 | 342 | result_dict[key_] = inicial_dict.copy() | 346 | result_dict[key_] = inicial_dict.copy() |
275 | 347 | |||
276 | 343 | result_dict[key_].update({ | 348 | result_dict[key_].update({ |
277 | 349 | |||
278 | 344 | 'name': rule.name, | 350 | 'name': rule.name, |
279 | 345 | 'periodo': 'Periodo ' + str(anio-1) + ' - ' + str(anio), | 351 | 'periodo': 'Periodo ' + str(anio-1) + ' - ' + str(anio), |
280 | 346 | 'quantity': qty, | 352 | 'quantity': qty, |
281 | 347 | }) | 353 | }) |
283 | 348 | rules_dict[key_] = amount*qty or 0.0 | 354 | |
284 | 355 | rules_dict[key_] = amount * qty or 0.0 | ||
285 | 349 | localdict['concepto'] = rules_dict | 356 | localdict['concepto'] = rules_dict |
286 | 350 | |||
287 | 351 | else: | ||
288 | 352 | result_dict[key] = inicial_dict.copy() | ||
289 | 353 | |||
290 | 354 | if rule.code == concept_util_liq_brw.code: | ||
291 | 355 | qty = parameters_dict['utilidades'] | ||
292 | 356 | result_dict[key]['quantity'] = qty | ||
293 | 357 | |||
294 | 358 | elif rule.code == concept_prest_liq_brw.code: | ||
295 | 359 | qty = 5 | ||
296 | 360 | result_dict[key]['quantity'] = qty | ||
297 | 361 | |||
298 | 362 | elif rule.code == concept_util_frac_liq_brw.code: | ||
299 | 363 | contract_date_start = datetime.strptime(employee.start_rel_lab,"%Y-%m-%d") | ||
300 | 364 | fraccion_mes = fecha_liquidacion.day / \ | ||
301 | 365 | calendar.monthrange(fecha_liquidacion.year,fecha_liquidacion.month)[1] | ||
302 | 366 | if contract_date_start.year < fecha_liquidacion.year: | ||
303 | 367 | qty = parameters_dict['utilidades']/12*(fecha_liquidacion.month \ | ||
304 | 368 | - 1 + fraccion_mes) | ||
305 | 369 | result_dict[key]['quantity'] = qty | ||
306 | 370 | elif contract_date_start.year == fecha_liquidacion.year: | ||
307 | 371 | qty = parameters_dict['utilidades']/12*(fecha_liquidacion.month - \ | ||
308 | 372 | contract_date_start.month+fraccion_mes) | ||
309 | 373 | result_dict[key]['quantity'] = qty | ||
310 | 374 | |||
311 | 375 | rules_dict[key] = amount*qty or 0.0 | ||
312 | 376 | localdict['concepto'] = rules_dict | ||
313 | 377 | 357 | ||
314 | 378 | if rule.concept_id.category_id.code not in categories_concept_dict: | 358 | if rule.concept_id.category_id.code not in categories_concept_dict: |
317 | 379 | categories_concept_dict[rule.concept_id.category_id.code] = \ | 359 | |
318 | 380 | amount or 0.0 | 360 | categories_concept_dict[rule.concept_id.category_id.code] = amount or 0.0 |
319 | 381 | else: | 361 | else: |
323 | 382 | categories_concept_dict[rule.concept_id.category_id.code] = \ | 362 | categories_concept_dict[rule.concept_id.category_id.code] = categories_concept_dict[rule.concept_id.category_id.code] + amount |
324 | 383 | categories_concept_dict[rule.concept_id.category_id.code] \ | 363 | |
322 | 384 | + amount | ||
325 | 385 | localdict['categoria_concepto'] = categories_concept_dict | 364 | localdict['categoria_concepto'] = categories_concept_dict |
326 | 365 | |||
327 | 386 | else: | 366 | else: |
331 | 387 | blacklist += [id for id, seq in | 367 | |
332 | 388 | self.pool.get('hr.salary.rule')._recursive_search_of_rules(cr, | 368 | blacklist += [id for id, seq in self.pool.get('hr.salary.rule')._recursive_search_of_rules(cr, uid, [rule], context=context)] |
330 | 389 | uid, [rule], context=context)] | ||
333 | 390 | 369 | ||
334 | 391 | result = [value for code, value in result_dict.items()] | 370 | result = [value for code, value in result_dict.items()] |
335 | 392 | 371 | ||
336 | 393 | return result | 372 | return result |
337 | 394 | 373 | ||
339 | 395 | 374 | ||
340 | 396 | def _send_report_by_email(self, cr, uid, parameters, context=None): | 375 | def _send_report_by_email(self, cr, uid, parameters, context=None): |
341 | 397 | 376 | ||
342 | 398 | subject = parameters['subject'] | 377 | subject = parameters['subject'] |
343 | 399 | message = parameters['message'] | 378 | message = parameters['message'] |
344 | 400 | data = parameters['data'] | 379 | data = parameters['data'] |
345 | 380 | title = parameters['data']['titulo'] | ||
346 | 401 | file_name = parameters['file_name'] | 381 | file_name = parameters['file_name'] |
347 | 402 | fecha_creada = parameters['data']['fecha_creada'] | 382 | fecha_creada = parameters['data']['fecha_creada'] |
349 | 403 | 383 | type_report = parameters['data']['type_report'] | |
350 | 384 | basic = parameters['data']['sueldo_basico'] | ||
351 | 385 | |||
352 | 404 | smtp_client = self.pool.get('email.smtpclient') | 386 | smtp_client = self.pool.get('email.smtpclient') |
353 | 405 | smtp_server = smtp_client.search(cr, uid, [('active','=',True),('state','=','confirm')], context=False) | 387 | smtp_server = smtp_client.search(cr, uid, [('active','=',True),('state','=','confirm')], context=False) |
354 | 406 | 388 | ||
355 | 407 | parameter_obj = self.pool.get('hr.parameters') | 389 | parameter_obj = self.pool.get('hr.parameters') |
356 | 408 | payroll_obj = self.pool.get('hr.payroll') | ||
357 | 409 | payroll_structure_obj = self.pool.get('hr.payroll.structure') | ||
358 | 410 | obj_line_liq = self.pool.get('hr.linea.liquidacion') | 390 | obj_line_liq = self.pool.get('hr.linea.liquidacion') |
359 | 411 | 391 | ||
360 | 412 | param_struct_id = parameter_obj.search(cr, uid, [('type', '=', 'estructuras_liq')]) | 392 | param_struct_id = parameter_obj.search(cr, uid, [('type', '=', 'estructuras_liq')]) |
361 | @@ -416,71 +396,102 @@ | |||
362 | 416 | 396 | ||
363 | 417 | if data['for_sede']: | 397 | if data['for_sede']: |
364 | 418 | employee_ids = self.pool.get('hr.employee').search(cr, uid, [('state','in',['vacaciones','activo','reposo']),('start_rel_lab','<=', fecha_creada)]) | 398 | employee_ids = self.pool.get('hr.employee').search(cr, uid, [('state','in',['vacaciones','activo','reposo']),('start_rel_lab','<=', fecha_creada)]) |
365 | 419 | title = "Todas las sedes" | ||
366 | 420 | else: | 399 | else: |
367 | 421 | brw_sede = self.pool.get('hr.sede').browse(cr, uid, data['sede']) | ||
368 | 422 | employee_ids = self.pool.get('hr.employee').search(cr, uid, [('hr_sede_id','=',data['sede']),('state','in',['vacaciones','activo','reposo']),('start_rel_lab','<=', fecha_creada)]) | 400 | employee_ids = self.pool.get('hr.employee').search(cr, uid, [('hr_sede_id','=',data['sede']),('state','in',['vacaciones','activo','reposo']),('start_rel_lab','<=', fecha_creada)]) |
374 | 423 | title = brw_sede.name | 401 | |
375 | 424 | 402 | list_concept_codes = self.query_concept(cr) | |
371 | 425 | list_val = [] | ||
372 | 426 | value = [] | ||
373 | 427 | |||
376 | 428 | dicc_department = {} | 403 | dicc_department = {} |
377 | 429 | 404 | ||
391 | 430 | for i in employee_ids: | 405 | if employee_ids: |
392 | 431 | employee = self.pool.get('hr.employee').browse(cr, uid, [i]) | 406 | c = 0 |
393 | 432 | if employee[0].start_rel_lab <= fecha_creada: | 407 | for i in employee_ids: |
394 | 433 | dicc_department[employee[0].department_id.id] = [] | 408 | c = c + 1 |
395 | 434 | 409 | #~ print str(c) + " de " + str(len(employee_ids)) | |
396 | 435 | 410 | val= [] | |
397 | 436 | for i in employee_ids: | 411 | l=[] |
398 | 437 | employee = self.pool.get('hr.employee').browse(cr, uid, [i]) | 412 | |
399 | 438 | if employee[0].start_rel_lab <= fecha_creada: | 413 | employee = self.pool.get('hr.employee').browse(cr, uid, [i]) |
400 | 439 | struct_brw = [x for x in struct_list if x.hr_payroll_id == employee[0].hr_payroll_id] | 414 | |
401 | 440 | lines = self.get_payslip_lines(cr, uid, struct_brw[0], employee[0], list_concept_codes, fecha_creada) | 415 | if employee[0].start_rel_lab <= fecha_creada: |
402 | 441 | val= [] | 416 | |
403 | 442 | l=[] | 417 | struct_list = parameter_obj.browse(cr, uid, param_struct_id)[0].estruc_liq_ids |
404 | 418 | struct_brw = [x for x in struct_list if x.hr_payroll_id == employee[0].hr_payroll_id] | ||
405 | 419 | if struct_brw: | ||
406 | 420 | obj_line_liq.vacaciones_no_disfrutadas(cr, uid, employee[0]) | ||
407 | 421 | else: | ||
408 | 422 | raise osv.except_osv(('ERROR!'), ('La %s no esta incluida en los parametros de la estructura para liquidacion'%(employee[0].hr_payroll_id.name))) | ||
409 | 423 | |||
410 | 424 | struct_brw = [x for x in struct_list if x.hr_payroll_id == employee[0].hr_payroll_id] | ||
411 | 425 | lines = self.get_payslip_lines(cr, uid, struct_brw[0], employee[0], list_concept_codes, fecha_creada, context) | ||
412 | 426 | |||
413 | 443 | [l.append(key) for key in lines if key not in l] | 427 | [l.append(key) for key in lines if key not in l] |
414 | 428 | |||
415 | 429 | sd = self.remuneracion(cr, uid, employee[0].id, fecha_creada) | ||
416 | 430 | |||
417 | 444 | for line in l: | 431 | for line in l: |
418 | 445 | if line['amount'] > 0.0 and line['quantity'] > 0.0: | 432 | if line['amount'] > 0.0 and line['quantity'] > 0.0: |
419 | 446 | amount = line['amount'] * line['quantity'] | 433 | amount = line['amount'] * line['quantity'] |
421 | 447 | val.append({'n':line['name'] + " " + line['periodo'], 'a':amount, 'q':line['quantity'], 'p':line['periodo']}) | 434 | basico = sd * line['quantity'] |
422 | 435 | val.append({'sd':basico,'n':line['name'] + " " + line['periodo'], 'a':amount, 'q':line['quantity'], 'p':line['periodo']}) | ||
423 | 436 | |||
424 | 448 | if val: | 437 | if val: |
425 | 438 | |||
426 | 439 | if not employee[0].department_id.id in dicc_department: | ||
427 | 440 | dicc_department[employee[0].department_id.id]=[] | ||
428 | 449 | dicc_department[employee[0].department_id.id].append((employee[0].cod_number, employee[0].name, sorted(val))) | 441 | dicc_department[employee[0].department_id.id].append((employee[0].cod_number, employee[0].name, sorted(val))) |
430 | 450 | 442 | ||
431 | 451 | total_departamento={} | 443 | total_departamento={} |
432 | 444 | total_departamento_basico={} | ||
433 | 445 | |||
434 | 452 | for c in dicc_department: | 446 | for c in dicc_department: |
435 | 453 | total_departamento[c] = 0.0 | 447 | total_departamento[c] = 0.0 |
436 | 448 | total_departamento_basico[c] = 0.0 | ||
437 | 454 | 449 | ||
438 | 455 | for c in dicc_department: | 450 | for c in dicc_department: |
439 | 456 | amount = 0.0 | 451 | amount = 0.0 |
440 | 452 | basico = 0.0 | ||
441 | 457 | for i in dicc_department[c]: | 453 | for i in dicc_department[c]: |
442 | 454 | |||
443 | 458 | for x in i[2]: | 455 | for x in i[2]: |
444 | 459 | amount += x['a'] | 456 | amount += x['a'] |
445 | 457 | basico += x['sd'] | ||
446 | 458 | |||
447 | 460 | total_departamento[c] = amount | 459 | total_departamento[c] = amount |
448 | 460 | total_departamento_basico[c] = basico | ||
449 | 461 | 461 | ||
450 | 462 | total_resumen = [] | 462 | total_resumen = [] |
451 | 463 | total_resumen_basico = [] | ||
452 | 463 | for c in total_departamento: | 464 | for c in total_departamento: |
453 | 464 | total_resumen.append(total_departamento[c]) | 465 | total_resumen.append(total_departamento[c]) |
454 | 466 | total_resumen_basico.append(total_departamento_basico[c]) | ||
455 | 467 | |||
456 | 465 | total_resumen = sum(total_resumen) | 468 | total_resumen = sum(total_resumen) |
457 | 469 | total_resumen_basico = sum(total_resumen_basico) | ||
458 | 466 | 470 | ||
459 | 467 | total_empleado = {} | 471 | total_empleado = {} |
460 | 472 | total_empleado_basico = {} | ||
461 | 468 | for c in dicc_department: | 473 | for c in dicc_department: |
462 | 469 | for i in dicc_department[c]: | 474 | for i in dicc_department[c]: |
463 | 470 | total_empleado[i[0]] = 0.0 | 475 | total_empleado[i[0]] = 0.0 |
464 | 476 | total_empleado_basico[i[0]] = 0.0 | ||
465 | 471 | 477 | ||
466 | 472 | for c in dicc_department: | 478 | for c in dicc_department: |
467 | 473 | for i in dicc_department[c]: | 479 | for i in dicc_department[c]: |
468 | 474 | for x in i[2]: | 480 | for x in i[2]: |
469 | 475 | total_empleado[i[0]] += x['a'] | 481 | total_empleado[i[0]] += x['a'] |
470 | 482 | total_empleado_basico[i[0]] += x['sd'] | ||
471 | 476 | 483 | ||
472 | 477 | new = datetime.strptime(fecha_creada, '%Y-%m-%d') | 484 | new = datetime.strptime(fecha_creada, '%Y-%m-%d') |
474 | 478 | 485 | ||
475 | 479 | data['form'] = dicc_department | 486 | data['form'] = dicc_department |
476 | 480 | data['total_resumen'] = total_resumen | 487 | data['total_resumen'] = total_resumen |
477 | 488 | data['total_resumen_basico'] = total_resumen_basico | ||
478 | 481 | data['total_empleado'] = total_empleado | 489 | data['total_empleado'] = total_empleado |
479 | 490 | data['total_empleado_basico'] = total_empleado_basico | ||
480 | 482 | data['sede'] = title | 491 | data['sede'] = title |
482 | 483 | data['al'] = str(new.strftime('%d-%m-%Y')) | 492 | data['sueldo_basico'] = basic |
483 | 493 | data['type_report'] = type_report | ||
484 | 494 | data['al'] = str(new.strftime('%d/%m/%Y')) | ||
485 | 484 | 495 | ||
486 | 485 | report = self._create_report(cr, uid, data['ids'], data['model'], file_name, data) | 496 | report = self._create_report(cr, uid, data['ids'], data['model'], file_name, data) |
487 | 486 | attachments = report[0] and [report[1]] or [] | 497 | attachments = report[0] and [report[1]] or [] |
488 | @@ -502,17 +513,13 @@ | |||
489 | 502 | 'from': uid, | 513 | 'from': uid, |
490 | 503 | 'attachments': attachments | 514 | 'attachments': attachments |
491 | 504 | } | 515 | } |
492 | 505 | |||
493 | 506 | smtp_client.send_email(cr, uid, smtp_server_id, email['to'], email['name'], email['body'], email['attachments']) | 516 | smtp_client.send_email(cr, uid, smtp_server_id, email['to'], email['name'], email['body'], email['attachments']) |
494 | 507 | finally: | 517 | finally: |
495 | 508 | cron = self.pool.get('ir.cron') | 518 | cron = self.pool.get('ir.cron') |
496 | 509 | accion_planificada = cron.search(cr, uid, [('name','=', subject)]) | 519 | accion_planificada = cron.search(cr, uid, [('name','=', subject)]) |
497 | 510 | cron.unlink(cr, uid, accion_planificada) | 520 | cron.unlink(cr, uid, accion_planificada) |
499 | 511 | 521 | ||
500 | 512 | def _send_request(self, cr, uid, ids, subject, message, context=None): | 522 | def _send_request(self, cr, uid, ids, subject, message, context=None): |
501 | 513 | """ | ||
502 | 514 | Metodo que envia una notificacion interna de OpenERP | ||
503 | 515 | """ | ||
504 | 516 | notificaciones = { | 523 | notificaciones = { |
505 | 517 | 'name': (subject), | 524 | 'name': (subject), |
506 | 518 | 'act_to': uid, | 525 | 'act_to': uid, |
507 | @@ -535,40 +542,36 @@ | |||
508 | 535 | fp.write(result); | 542 | fp.write(result); |
509 | 536 | fp.close(); | 543 | fp.close(); |
510 | 537 | except Exception,e: | 544 | except Exception,e: |
512 | 538 | print 'Exception in create report:',e | 545 | #~ print 'Exception in create report:',e |
513 | 539 | return (False, str(e)) | 546 | return (False, str(e)) |
514 | 540 | return (True, ret_file_name) | 547 | return (True, ret_file_name) |
515 | 541 | 548 | ||
527 | 542 | def getObtenerDia(self, mes, dia="primer"): | 549 | def getObtenerDia(self, mes, anio): |
528 | 543 | meses = {'ENERO':'01', 'FEBRERO':'02', 'MARZO':'03', 'ABRIL':'04', 'MAYO':'05', 'JUNIO':'06', | 550 | calendario = calendar.monthrange(anio, mes) |
529 | 544 | 'JULIO':'07', 'AGOSTO':'08', 'SEPTIEMBRE':'09', 'OCTUBRE':'10', 'NOVIEMBRE':'11', 'DICIEMBRE':'12'} | 551 | return '%s-%s-%s'%(anio, '0'+ str(mes) if len(str(mes)) < 2 else mes, calendario[1]) |
519 | 545 | mes = mes.split(" ") | ||
520 | 546 | anio = mes[1] | ||
521 | 547 | mes = meses[mes[0].upper()] | ||
522 | 548 | calendario = calendar.monthrange(int(anio),int(mes)) | ||
523 | 549 | if dia == "ultimo": | ||
524 | 550 | fecha_creada = str(anio)+"-"+ str(mes)+ "-" + str(calendario[1]) | ||
525 | 551 | return fecha_creada | ||
526 | 552 | return str(anio)+"-"+ str(mes)+ "-" + "-01" | ||
530 | 553 | 552 | ||
531 | 554 | def print_report_buton(self, cr, uid, ids, context=None): | 553 | def print_report_buton(self, cr, uid, ids, context=None): |
532 | 555 | 554 | ||
540 | 556 | brw = self.browse(cr, uid, ids)[0] | 555 | if context is None:context = {} |
541 | 557 | mes = brw.mes.name | 556 | context['procesar'] = True |
542 | 558 | month_id = brw.mes.id | 557 | |
536 | 559 | fecha_creada = self.getObtenerDia(mes, 'ultimo') | ||
537 | 560 | for_sede = brw.for_sede | ||
538 | 561 | type_report = brw.type_report | ||
539 | 562 | |||
543 | 563 | self._check_email_server(cr, uid, ids, context) | 558 | self._check_email_server(cr, uid, ids, context) |
544 | 564 | email = self._check_user_email_adress(cr, uid, ids, context) | 559 | email = self._check_user_email_adress(cr, uid, ids, context) |
545 | 565 | 560 | ||
546 | 561 | if not email: | ||
547 | 562 | raise osv.except_osv(('ERROR!'), ('No hay un correo electronico asociado al usuario.')) | ||
548 | 563 | |||
549 | 566 | parameter_obj = self.pool.get('hr.parameters') | 564 | parameter_obj = self.pool.get('hr.parameters') |
550 | 567 | payroll_obj = self.pool.get('hr.payroll') | 565 | payroll_obj = self.pool.get('hr.payroll') |
551 | 568 | payroll_structure_obj = self.pool.get('hr.payroll.structure') | 566 | payroll_structure_obj = self.pool.get('hr.payroll.structure') |
552 | 569 | obj_line_liq = self.pool.get('hr.linea.liquidacion') | ||
553 | 570 | obj_process = self.pool.get('hr.process') | 567 | obj_process = self.pool.get('hr.process') |
554 | 571 | obj_period = self.pool.get('hr.period') | 568 | obj_period = self.pool.get('hr.period') |
555 | 569 | obj_line_liq = self.pool.get('hr.linea.liquidacion') | ||
556 | 570 | |||
557 | 571 | brw = self.browse(cr, uid, ids)[0] | ||
558 | 572 | mes_brw = brw.mes | ||
559 | 573 | sede_id = brw.sede_id | ||
560 | 574 | fecha_creada = self.getObtenerDia(mes_brw.month_year, mes_brw.hr_year_id.year) | ||
561 | 572 | 575 | ||
562 | 573 | param_struct_id = parameter_obj.search(cr, uid, [('type', '=', 'estructuras_liq')]) | 576 | param_struct_id = parameter_obj.search(cr, uid, [('type', '=', 'estructuras_liq')]) |
563 | 574 | if not param_struct_id: | 577 | if not param_struct_id: |
564 | @@ -611,7 +614,8 @@ | |||
565 | 611 | la pestaña Configuracion -> Configuraciones de nomina -> \ | 614 | la pestaña Configuracion -> Configuraciones de nomina -> \ |
566 | 612 | Parametros de nomina y registrar un parametro de tipo \ | 615 | Parametros de nomina y registrar un parametro de tipo \ |
567 | 613 | Conceptos Vacaciones no disfrutadas')) | 616 | Conceptos Vacaciones no disfrutadas')) |
569 | 614 | 617 | ||
570 | 618 | |||
571 | 615 | nomina_ids = payroll_obj.search(cr, uid, []) | 619 | nomina_ids = payroll_obj.search(cr, uid, []) |
572 | 616 | nomina_browse = payroll_obj.browse(cr, uid, nomina_ids) | 620 | nomina_browse = payroll_obj.browse(cr, uid, nomina_ids) |
573 | 617 | 621 | ||
574 | @@ -621,6 +625,7 @@ | |||
575 | 621 | raise osv.except_osv(('ERROR!'), ('No hay una Estructuras de Liquidaciones para la nomina %s')%(i.name)) | 625 | raise osv.except_osv(('ERROR!'), ('No hay una Estructuras de Liquidaciones para la nomina %s')%(i.name)) |
576 | 622 | 626 | ||
577 | 623 | for i in nomina_browse: | 627 | for i in nomina_browse: |
578 | 628 | |||
579 | 624 | param_concept_salary_id = parameter_obj.search(cr, uid, [('type', '=', 'concepto_sueldo'), | 629 | param_concept_salary_id = parameter_obj.search(cr, uid, [('type', '=', 'concepto_sueldo'), |
580 | 625 | ('payroll_id', '=', i.id)]) | 630 | ('payroll_id', '=', i.id)]) |
581 | 626 | 631 | ||
582 | @@ -635,54 +640,58 @@ | |||
583 | 635 | Parametros de nomina y registrar un parametro de tipo \ | 640 | Parametros de nomina y registrar un parametro de tipo \ |
584 | 636 | Concepto Salario')%(i.name)) | 641 | Concepto Salario')%(i.name)) |
585 | 637 | 642 | ||
589 | 638 | fecha_liquidacion = datetime.strptime(fecha_creada,"%Y-%m-%d") | 643 | period_id = obj_period.search(cr, uid, [('hr_month_id', '=', mes_brw.id), ('state', '=', 'close')]) |
587 | 639 | |||
588 | 640 | period_id = obj_period.search(cr, uid, [('hr_month_id', '=', month_id), ('state', '=', 'close')]) | ||
590 | 641 | 644 | ||
591 | 642 | if not period_id: | 645 | if not period_id: |
594 | 643 | raise osv.except_osv(('ERROR!'), ('No hay un periodo asociado a la fecha %s para la %s')%(today, i.name)) | 646 | raise osv.except_osv(('ERROR!'), ('No hay un periodo asociado al mes seleccionado. para la %s')%(i.name)) |
595 | 644 | 647 | ||
596 | 645 | otros_procesos_id = obj_process.search(cr, uid, [('hr_payroll_ids', '=', i.id), | 648 | otros_procesos_id = obj_process.search(cr, uid, [('hr_payroll_ids', '=', i.id), |
599 | 646 | ('type', 'not in', ('prestaciones','bono_alimentacion','guarderias')), | 649 | ('type', 'not in', ('prestaciones','bono_alimentacion','guarderias')), |
600 | 647 | ('hr_period_ids', 'in', period_id), ('state', '=', 'done')]) | 650 | ('hr_period_ids', 'in', period_id), ('state', '=', 'done')]) |
601 | 648 | 651 | ||
602 | 649 | if otros_procesos_id: | 652 | if otros_procesos_id: |
606 | 650 | 653 | ||
607 | 651 | proceso_id = obj_process.search(cr, uid, [('hr_payroll_ids', '=', i.id), ('type', '=', 'prestaciones'), | 654 | proceso_id = obj_process.search(cr, uid, [('hr_payroll_ids', '=', i.id), |
608 | 652 | ('hr_period_ids', 'in', period_id), ('state', '=', 'done')]) | 655 | ('type', '=', 'prestaciones'), |
609 | 656 | ('hr_period_ids', 'in', period_id), | ||
610 | 657 | ('state', '=', 'done')]) | ||
611 | 653 | 658 | ||
612 | 654 | if not proceso_id: | 659 | if not proceso_id: |
615 | 655 | raise osv.except_osv(('ERROR!'), ('La %s para el mes de %s no \ | 660 | raise osv.except_osv(('ERROR!'), ('La %s para el mes de %s no posee proceso de Prestaciones Sociales aprobado'%(i.name, mes_brw.name))) |
614 | 656 | posee proceso de Prestaciones Sociales aprobado'%(i.name, mes))) | ||
616 | 657 | 661 | ||
619 | 658 | proceso_nomina_id = obj_process.search(cr, uid, [('hr_payroll_ids', '=', i.id), ('type', '=', 'nomina'), | 662 | proceso_nomina_id = obj_process.search(cr, uid, [('hr_payroll_ids', '=', i.id), |
620 | 659 | ('hr_period_ids', 'in', period_id), ('state', '=', 'done')]) | 663 | ('type', '=', 'nomina'), |
621 | 664 | ('hr_period_ids', 'in', period_id), | ||
622 | 665 | ('state', '=', 'done')]) | ||
623 | 660 | 666 | ||
624 | 661 | if not proceso_nomina_id: | 667 | if not proceso_nomina_id: |
627 | 662 | raise osv.except_osv(('ERROR!'), ('La %s para el mes de %s no \ | 668 | raise osv.except_osv(('ERROR!'), ('La %s para el mes de %s no posee proceso de Nomina aprobado'%(i.name, mes_brw.name))) |
626 | 663 | posee proceso de Nomina aprobado'%(i.name, mes))) | ||
628 | 664 | 669 | ||
630 | 665 | if for_sede: | 670 | if brw.for_sede: |
631 | 666 | employee_ids = self.pool.get('hr.employee').search(cr, uid, [('state','in',['vacaciones','activo','reposo'])]) | 671 | employee_ids = self.pool.get('hr.employee').search(cr, uid, [('state','in',['vacaciones','activo','reposo'])]) |
632 | 667 | title = "TODAS LAS SEDES" | ||
633 | 668 | else: | 672 | else: |
637 | 669 | employee_ids = self.pool.get('hr.employee').search(cr, uid, [('hr_sede_id','=',brw.sede_id.id),('state','in',['vacaciones','activo','reposo'])]) | 673 | employee_ids = self.pool.get('hr.employee').search(cr, uid, [('hr_sede_id','=',sede_id.id),('state','in',['vacaciones','activo','reposo'])]) |
638 | 670 | title = brw.sede_id.name | 674 | |
639 | 671 | 675 | title = sede_id.name if not brw.for_sede else 'TODAS LAS SEDES' | |
640 | 672 | 676 | ||
641 | 673 | if employee_ids: | 677 | if employee_ids: |
642 | 678 | |||
643 | 674 | for i in employee_ids: | 679 | for i in employee_ids: |
644 | 680 | |||
645 | 675 | employee = self.pool.get('hr.employee').browse(cr, uid, [i]) | 681 | employee = self.pool.get('hr.employee').browse(cr, uid, [i]) |
646 | 676 | if employee[0].start_rel_lab <= fecha_creada: | 682 | if employee[0].start_rel_lab <= fecha_creada: |
647 | 677 | struct_list = parameter_obj.browse(cr, uid, param_struct_id)[0].estruc_liq_ids | 683 | struct_list = parameter_obj.browse(cr, uid, param_struct_id)[0].estruc_liq_ids |
648 | 678 | struct_brw = [x for x in struct_list if x.hr_payroll_id == employee[0].hr_payroll_id] | 684 | struct_brw = [x for x in struct_list if x.hr_payroll_id == employee[0].hr_payroll_id] |
649 | 679 | if struct_brw: | 685 | if struct_brw: |
651 | 680 | reg_vac_no_disf = obj_line_liq.vacaciones_no_disfrutadas(cr, uid, employee[0]) | 686 | obj_line_liq.vacaciones_no_disfrutadas(cr, uid, employee[0]) |
652 | 681 | else: | 687 | else: |
653 | 682 | raise osv.except_osv(('ERROR!'), ('La %s no esta incluida en los parametros de la estructura para liquidacion'%(employee[0].hr_payroll_id.name))) | 688 | raise osv.except_osv(('ERROR!'), ('La %s no esta incluida en los parametros de la estructura para liquidacion'%(employee[0].hr_payroll_id.name))) |
654 | 689 | |||
655 | 683 | data = {} | 690 | data = {} |
656 | 684 | data['form'] = {} | 691 | data['form'] = {} |
657 | 685 | data['ids'] = [1] | 692 | data['ids'] = [1] |
658 | 693 | data['titulo'] = title | ||
659 | 694 | data['sueldo_basico'] = brw.basic | ||
660 | 686 | data['model'] = "wizard.maximum.passive.holiday" | 695 | data['model'] = "wizard.maximum.passive.holiday" |
661 | 687 | data['sede'] = brw.sede_id.id | 696 | data['sede'] = brw.sede_id.id |
662 | 688 | data['type_report'] = brw.type_report | 697 | data['type_report'] = brw.type_report |
663 | @@ -715,11 +724,9 @@ | |||
664 | 715 | self.pool.get('ir.cron').create(cr, uid, vals, context) | 724 | self.pool.get('ir.cron').create(cr, uid, vals, context) |
665 | 716 | self._send_request(cr, uid, ids, subject, request_message, context) | 725 | self._send_request(cr, uid, ids, subject, request_message, context) |
666 | 717 | return {'type':'ir.actions.act_window_close'} | 726 | return {'type':'ir.actions.act_window_close'} |
673 | 718 | else: | 727 | |
674 | 719 | raise osv.except_osv(('Accion Denegada!'), ('No existen datos disponibles para generar el reporte')) | 728 | raise osv.except_osv(('Accion Denegada!'), ('No existen datos disponibles para generar el reporte')) |
675 | 720 | else: | 729 | |
676 | 721 | raise osv.except_osv(('Accion Denegada!'), ('%s no cuenta con trabajadores para poder generar este reporte')%(title)) | 730 | raise osv.except_osv(('Accion Denegada!'), ('%s no cuenta con trabajadores para poder generar este reporte')%(title)) |
671 | 722 | |||
672 | 723 | |||
677 | 724 | 731 | ||
678 | 725 | wizard_maximum_passive_holiday() | 732 | wizard_maximum_passive_holiday() |
679 | 726 | 733 | ||
680 | === modified file 'sisb_nomina/wizard/reporte_pasivo_maximo_vacaciones.xml' | |||
681 | --- sisb_nomina/wizard/reporte_pasivo_maximo_vacaciones.xml 2016-11-22 14:39:04 +0000 | |||
682 | +++ sisb_nomina/wizard/reporte_pasivo_maximo_vacaciones.xml 2017-11-22 18:25:51 +0000 | |||
683 | @@ -7,23 +7,25 @@ | |||
684 | 7 | <field name="type">form</field> | 7 | <field name="type">form</field> |
685 | 8 | <field name="arch" type="xml"> | 8 | <field name="arch" type="xml"> |
686 | 9 | <form string="maximum passive holiday"> | 9 | <form string="maximum passive holiday"> |
701 | 10 | <group col="4" colspan="4" > | 10 | |
702 | 11 | 11 | <group colspan="2" col="6"> | |
703 | 12 | </group> | 12 | <field name="type_report"/> |
704 | 13 | <group colspan="4" col="8"> | 13 | <field name="sede_id" attrs= "{'readonly':[('for_sede','=','True')], 'required':[('for_sede','!=','True')] }"/> |
705 | 14 | <field name="type_report" colspan="1"/> | 14 | <field name="for_sede" /> |
706 | 15 | <field name="sede_id" colspan="2" attrs= "{'readonly':[('for_sede','=','True')], 'required':[('for_sede','!=','True')] }"/> | 15 | <field name="mes" /> |
707 | 16 | <field name="for_sede" colspan="2" /> | 16 | <field name="basic" /> |
708 | 17 | 17 | </group> | |
709 | 18 | <newline/> | 18 | |
710 | 19 | 19 | ||
711 | 20 | <field name="mes" colspan="2" /> | 20 | <newline/> |
712 | 21 | </group> | 21 | |
699 | 22 | <newline/> | ||
700 | 23 | <newline/> | ||
713 | 24 | <group> | 22 | <group> |
715 | 25 | <button name="print_report_buton" string="Print Report" type="object" icon="mail- " confirm="Antes de iniciar la generacion del reporte se validaran ciertos datos. Al finalizar se enviara a su direccion de correo" /> | 23 | |
716 | 24 | <button name="print_report_buton" string="Generar Reporte" type="object" icon="mail- " confirm="Antes de iniciar la generacion del reporte se validaran ciertos datos. Al finalizar se enviara a su direccion de correo" /> | ||
717 | 25 | |||
718 | 26 | </group> | 26 | </group> |
719 | 27 | |||
720 | 28 | |||
721 | 27 | </form> | 29 | </form> |
722 | 28 | </field> | 30 | </field> |
723 | 29 | </record> | 31 | </record> |