Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
5181 Vistas

Hello,

Can any one help me to create and calculate the payslip for all emlpoyes with one link. for now for do this i must to enter to the all employes (one by one),

There is a function that calaculat automatiquely the payslip ? 

Avatar
Descartar
Mejor respuesta
this need some customization by adding new button in payslip batch to call compute function (process_sheet) in model(hr.payslip) for every payslip.

this snap code may help you:

@api.v7def compute_sheet(self, cr, uid, ids, context=None):    emp_pool = self.pool.get('hr.employee')    slip_pool = self.pool.get('hr.payslip')    run_pool = self.pool.get('hr.payslip.run')    slip_ids = []    if context is None:        context = {}    data = self.read(cr, uid, ids, context=context)[0]    count = 0    run_data = {}    if context and context.get('active_id', False):        run_data = run_pool.read(cr, uid, [context['active_id']], ['date_start', 'date_end', 'credit_note'])[0]        slips_ids = slip_pool.search(cr, uid, [('payslip_run_id', '=', context['active_id'])])        if len(slips_ids) > 0:            count = len(slips_ids)    from_date = run_data.get('date_start', False)    to_date = run_data.get('date_end', False)    credit_note = run_data.get('credit_note', False)    if not data['employee_ids']:        raise ValidationError(_("You must select employee(s) to generate payslip(s)."))    for emp in emp_pool.browse(cr, uid, data['employee_ids'], context=context):        count += 1        slip_data = slip_pool.onchange_employee_id(cr, uid, [], from_date, to_date, emp.id, contract_id=False,                                                   context=context)        res = {            'seq_count': count,            'employee_id': emp.id,            'name': _('Salary Slip of %s') % (emp.name),            'struct_id': slip_data['value'].get('struct_id', False),            'contract_id': slip_data['value'].get('contract_id', False),            'payslip_run_id': context.get('active_id', False),            'input_line_ids': [(0, 0, x) for x in slip_data['value'].get('input_line_ids', False)],            'worked_days_line_ids': [(0, 0, x) for x in slip_data['value'].get('worked_days_line_ids', False)],            'date_from': from_date,            'date_to': to_date,            'credit_note': credit_note,        }        slip_ids.append(slip_pool.create(cr, uid, res, context=context))    slip_pool.compute_sheet(cr, uid, slip_ids, context=context)    return {'type': 'ir.actions.act_window_close'}
Avatar
Descartar
Autor Mejor respuesta

Hi belal salah, 

Thanx for your answer, I did what you said, but i dont have the all payslips of employees.



Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
dic 23
1272
1
sept 23
1467
1
feb 23
2398
0
dic 22
1813
0
nov 22
2169