Odoo Help


Help Extend Script

Abayomi Olatidoye
on 7/23/16, 6:35 AM 765 views

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']


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.

On 7/23/16, 10:55 AM

maybe you should change:

ids = self.pool['hr.payslip'].search(self.cr, self.uid, [], context=self.context)


ids = self.pool['hr.payslip'].search(self.cr, self.uid, [('struct_id.name', 'in', [ 'Accord Engineering Structure', 'IT_Accord_Structure'])], context=self.context)

Abayomi Olatidoye
On 7/23/16, 3:15 PM

It is perfect!

Thanks Tuan.

:) great!

on 7/23/16, 9:18 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 7/23/16, 6:35 AM
Seen: 765 times
Last updated: 7/24/16, 1:24 AM