Odoo Help

Welcome!

This community 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.

0

Help Extend Script

By
Abayomi Olatidoye
on 7/23/16, 6:35 AM 253 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']

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.

1
Tuan
On 7/23/16, 10:55 AM

maybe you should change:

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

to 

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

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

It is perfect!

Thanks Tuan.


:) great!

Tuan
on 7/23/16, 9:18 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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