Hello, When I want to calculate the payslips in batches, I receive this error message below.
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\fields.py", line 3681, in __get__ raise ValueError("Expected singleton: %s" % record) ValueError: Expected singleton: hr.employee(2356, 2357, 2358, 2359, 2360, 2361, 2362, 2363, 2365, 2364, 2366, 2367, 2369, 2370, 2371, 2368, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2382, 2381, 2432, 2383, 2384, 2388, 2389, 2390, 2385, 2386, 2387, 2391, 2392, 764, 2394, 2433, 2395, 2400, 2401, 2402, 2403, 2404, 2396, 2398, 2397, 2399, 2405, 2406, 2407, 2408, 2410, 2409, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422, 2423, 2424, 2425, 2426, 2427, 2428, 2429, 2430, 2431, 2434)
Can you bring me a solution to this problem?
I use hr_payroll_community from Cybrosys Techno Solutions
Thank you for advance
The latest version for the hr_payroll_community module is 13.0.1.5.3, make sure you have the upgrade your module and give it a try?
I updated the module, but I still meet the same mistake. Is it possible to give me the directial link to the download of the update 13.0.1.5.3? thank you in advance
De : CorTex IT Solutions Ltd <notifications@mail.odoo.com>
Envoyé : lundi 21 février 2022 15:35
À : libre <emac@geclick.gq>
Objet : Re: Odoo 13 CE - when generating payslip batch i got this error
View Forum Post
The latest version for the hr_payroll_community module is 13.0.1.5.3, make sure you have the upgrade your module and give it a try?
Sent by Odoo S.A. using Odoo.
this is the error :
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\hr_payroll_account_community\wizard\hr_payroll_payslips_by_employees.py", line 12, in compute_sheet return super(HrPayslipEmployees, self.with_context(journal_id=journal_id)).compute_sheet() File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\hr_payroll_community\wizard\hr_payroll_payslips_by_employees.py", line 40, in compute_sheet payslips.compute_sheet() ** File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\dev_hr_loan\models\hr_payslip.py", line 24, in compute_sheet [('employee_id', '=', self.employee_id.id), ('loan_id.state', '=', 'done'), ('is_paid', '=', False),('date','<=',self.date_to)]) File "C:\Program Files (x86)\Odoo 13.0\server\odoo\fields.py", line 3681, in get raise ValueError("Expected singleton: %s" % record) ValueError: Expected singleton: hr.employee(2357, 2432)**
the code of loand it this :
----------------------------loan code ----------------------------------
class hr_payslip(models.Model):
_inherit = 'hr.payslip'
installment_ids = fields.Many2many('installment.line',string='Installment Lines')
installment_amount = fields.Float('Installment Amount',compute='get_installment_amount')
installment_int = fields.Float('Installment Amount',compute='get_installment_amount')
def compute_sheet(self):
installment_ids = self.env['installment.line'].search(
[('employee_id', '=', self.employee_id.id), ('loan_id.state', '=', 'done'), ('is_paid', '=', False),('date','<=',self.date_to)])
if installment_ids:
self.installment_ids = [(6, 0, installment_ids.ids)]
return super(hr_payslip,self).compute_sheet()
---------------------code hr_payroll_ payslip_employee --------------------------
# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
from odoo.exceptions import UserError
class HrPayslipEmployees(models.TransientModel):
_name = 'hr.payslip.employees'
_description = 'Generate payslips for all selected employees'
employee_ids = fields.Many2many('hr.employee', 'hr_employee_group_rel', 'payslip_id', 'employee_id', 'Employees')
def compute_sheet(self):
payslips = self.env['hr.payslip']
[data] = self.read()
active_id = self.env.context.get('active_id')
if active_id:
[run_data] = self.env['hr.payslip.run'].browse(active_id).read(['date_start', 'date_end', 'credit_note'])
from_date = run_data.get('date_start')
to_date = run_data.get('date_end')
if not data['employee_ids']:
raise UserError(_("You must select employee(s) to generate payslip(s)."))
for employee in self.env['hr.employee'].browse(data['employee_ids']):
slip_data = self.env['hr.payslip'].onchange_employee_id(from_date, to_date, employee.id, contract_id=False)
res = {
'employee_id': employee.id,
'name': slip_data['value'].get('name'),
'struct_id': slip_data['value'].get('struct_id'),
'contract_id': slip_data['value'].get('contract_id'),
'payslip_run_id': active_id,
'input_line_ids': [(0, 0, x) for x in slip_data['value'].get('input_line_ids')],
'worked_days_line_ids': [(0, 0, x) for x in slip_data['value'].get('worked_days_line_ids')],
'date_from': from_date,
'date_to': to_date,
'credit_note': run_data.get('credit_note'),
'company_id': employee.company_id.id,
}
payslips += self.env['hr.payslip'].create(res)
payslips.compute_sheet()
return {'type': 'ir.actions.act_window_close'}