[REF] hr_attendance: change employee.base to employee

Moves the changes to employee from hr_attendance from the hr.employee.base
model to the hr.employee model.

Task ID: 1904850
This commit is contained in:
William Braeckman
2021-07-06 11:35:01 +02:00
parent 2961513141
commit b429fce0e6
+29 -13
View File
@@ -8,19 +8,35 @@ from odoo import models, fields, api, exceptions, _
from odoo.tools import float_round
class HrEmployeeBase(models.AbstractModel):
_inherit = "hr.employee.base"
class HrEmployee(models.Model):
_inherit = "hr.employee"
attendance_ids = fields.One2many('hr.attendance', 'employee_id', help='list of attendances for the employee')
last_attendance_id = fields.Many2one('hr.attendance', compute='_compute_last_attendance_id', store=True)
last_check_in = fields.Datetime(related='last_attendance_id.check_in', store=True)
last_check_out = fields.Datetime(related='last_attendance_id.check_out', store=True)
attendance_state = fields.Selection(string="Attendance Status", compute='_compute_attendance_state', selection=[('checked_out', "Checked out"), ('checked_in', "Checked in")])
hours_last_month = fields.Float(compute='_compute_hours_last_month')
hours_today = fields.Float(compute='_compute_hours_today')
hours_last_month_display = fields.Char(compute='_compute_hours_last_month')
overtime_ids = fields.One2many('hr.attendance.overtime', 'employee_id')
total_overtime = fields.Float(compute='_compute_total_overtime')
attendance_ids = fields.One2many(
'hr.attendance', 'employee_id', groups="hr_attendance.group_hr_attendance_user",
help='list of attendances for the employee')
last_attendance_id = fields.Many2one(
'hr.attendance', compute='_compute_last_attendance_id', store=True,
groups="hr_attendance.group_hr_attendance_user")
last_check_in = fields.Datetime(
related='last_attendance_id.check_in', store=True,
groups="hr_attendance.group_hr_attendance_user")
last_check_out = fields.Datetime(
related='last_attendance_id.check_out', store=True,
groups="hr_attendance.group_hr_attendance_user")
attendance_state = fields.Selection(
string="Attendance Status", compute='_compute_attendance_state',
selection=[('checked_out', "Checked out"), ('checked_in', "Checked in")],
groups="hr_attendance.group_hr_attendance_user")
hours_last_month = fields.Float(
compute='_compute_hours_last_month', groups="hr_attendance.group_hr_attendance_user")
hours_today = fields.Float(
compute='_compute_hours_today', groups="hr_attendance.group_hr_attendance_user")
hours_last_month_display = fields.Char(
compute='_compute_hours_last_month', groups="hr_attendance.group_hr_attendance_user")
overtime_ids = fields.One2many(
'hr.attendance.overtime', 'employee_id', groups="hr_attendance.group_hr_attendance_user")
total_overtime = fields.Float(
compute='_compute_total_overtime', groups="hr_attendance.group_hr_attendance_user")
@api.depends('overtime_ids.duration', 'attendance_ids')
def _compute_total_overtime(self):
@@ -175,7 +191,7 @@ class HrEmployeeBase(models.AbstractModel):
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
if 'pin' in groupby or 'pin' in self.env.context.get('group_by', '') or self.env.context.get('no_group_by'):
raise exceptions.UserError(_('Such grouping is not allowed.'))
return super(HrEmployeeBase, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
return super(HrEmployee, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
def _compute_presence_icon(self):
res = super()._compute_presence_icon()