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

Correction for a costum fonction

By
Koffi KPONOUGLO
on 1/8/15, 10:56 AM 849 views

I am not developper but i writ this in 

class hr_payslip_run(osv.osv):

    _name = 'hr.payslip.run'
    _description = 'Payslip Batches'
    _columns = {

}

def validate_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')
        for slip_ids in slip_pool.browse(self, cr, uid, ids, context=context):
            if slip_ids.contract_id.date_end < slip_ids.date_from:
                 slip_ids.write(cr, uid, ids, {'state':'echu'}, context=context)
            slip_ids.write(cr, uid, ids, {'state':'done'}, context=context)
            self.write(cr, uid, ids, {'state': 'confirm'}, context=context)
        slip_pool.validate_sheet(cr, uid, slip_ids, context=context)     
        return True   

But i am getting this error 

Server Traceback (most recent call last): File "/home/benos/Public/openerp-7_12_14/openerp/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/home/benos/Public/openerp-7_12_14/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/home/benos/Public/openerp-7_12_14/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/home/benos/Public/openerp-7_12_14/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/home/benos/Public/openerp-7_12_14/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/home/benos/Public/openerp-7_12_14/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/home/benos/Public/openerp-7_12_14/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/home/benos/Public/openerp-7_12_14/openerp/addons/hr_payroll/hr_payroll.py", line 254, in validate_sheet for slip_ids in slip_pool.browse(self, cr, uid, ids, context=context): TypeError: browse() got multiple values for keyword argument 'context'

 

Can you help me please?

 

 

1
Nishant Jogi
On 1/8/15, 11:07 PM

Hello Koffi KPONOUGLO,

You did one mostake while browsing the record.

Replace for slip_ids in slip_pool.browse(self, cr, uid, ids, context=context):

with for slip_ids in slip_pool.browse(cr, uid, ids, context=context):

because while calling method of class you can not use self inside argument.

Thanks.

Thanks Nishant Jogi, i correct it and do another update. My goal is to write hr.payslip.run lines states into done when i am closing it. So i write this but anything happenp on lines states. def validate_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') for sheet in slip_pool.browse(cr, uid, ids, context=None): date_end = sheet.contract_id and sheet.contract_id.date_end or False date_from = sheet.date_from or False if date_end

Koffi KPONOUGLO
on 1/9/15, 12:31 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

1 follower(s)

Stats

Asked: 1/8/15, 10:56 AM
Seen: 849 times
Last updated: 3/16/15, 8:10 AM