mirror of
https://gitlab.com/sonalarora/tra_backend.git
synced 2025-12-18 18:59:08 +02:00
add new module
This commit is contained in:
20
hr_payroll_community/models/hr_employee.py
Normal file
20
hr_payroll_community/models/hr_employee.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class HrEmployee(models.Model):
|
||||
_inherit = 'hr.employee'
|
||||
_description = 'Employee'
|
||||
|
||||
slip_ids = fields.One2many('hr.payslip', 'employee_id', string='Payslips', readonly=True, help="payslip")
|
||||
payslip_count = fields.Integer(compute='_compute_payslip_count', string='Payslip Count')
|
||||
|
||||
def _compute_payslip_count(self):
|
||||
payslip_data = self.env['hr.payslip'].sudo().read_group([('employee_id', 'in', self.ids)],
|
||||
['employee_id'], ['employee_id'])
|
||||
result = dict((data['employee_id'][0], data['employee_id_count']) for data in payslip_data)
|
||||
for employee in self:
|
||||
employee.payslip_count = result.get(employee.id, 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user