I have compiled this script to return the payslip of my employees to return in a formatted rows and it worked.
However I have tried to make it print only employees with specific salary structure but has not been successful
The script is
from openerp.osv import osv
from openerp.report import report_sxw
from openerp import models
class quinax_cash_report_parser(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context=None):
if context is None:
context = {}
super(quinax_cash_report_parser, self).__init__(cr, uid, name, context=context)
self.localcontext.update( {
'get_payslips': self.get_payslips,
})
self.context = context
def get_payslips(self):
ids = self.pool['hr.payslip'].search(self.cr, self.uid, [], context=self.context)
payslips = self.pool['hr.payslip'].read(self.cr, self.uid, ids, context=self.context)
struct_id = self.pool['hr.payslip'].search(self.cr, self.uid, [], context=self.context)
cp = []
for payslip in payslips:
if struct_id == 'Accord Engineering Structure' and struct_id == 'IT_Accord_Structure':
row = {'employee_id': payslip ['employee_id'][1],
'date_from': payslip ['date_from'],
'date_to': payslip ['date_to']
}
lines = self.pool['hr.payslip.line'].read(self.cr, self.uid, payslip['line_ids'], context=self.context)
for line in lines:
row[line['code']] = line['total']
cp.append(row)
return cp
class report_generalledger(osv.AbstractModel):
_name = 'report.quinax_cash.my_report_cash'
_inherit = 'report.abstract_report'
_template = 'quinax_cash.my_report_cash'
_wrapped_report_class = quinax_cash_report_parser
class PayrollSchedule(models.Model):
_name = 'cash.payroll.schedule'
def print_payroll_schedule_report(self, cr, uid, ids, data, context=None):
if context is None:
context = {}
context['portrait'] = True
return self.pool['report'].get_action(cr, uid, [], 'quinax_cash.my_report_cash', context=context)
Kindly help look through and help with how I can limit this script to employees with particular structure.