mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-27 14:52:06 +02:00
Initial commit: Hr packages
This commit is contained in:
commit
62531cd146
2820 changed files with 1432848 additions and 0 deletions
|
|
@ -0,0 +1,35 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.tools.translate import _
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
class HrEmployee(models.Model):
|
||||
_inherit = "hr.employee"
|
||||
|
||||
newly_hired_employee = fields.Boolean('Newly hired employee', compute='_compute_newly_hired_employee',
|
||||
search='_search_newly_hired_employee')
|
||||
applicant_id = fields.One2many('hr.applicant', 'emp_id', 'Applicant')
|
||||
|
||||
def _compute_newly_hired_employee(self):
|
||||
now = fields.Datetime.now()
|
||||
for employee in self:
|
||||
employee.newly_hired_employee = bool(employee.create_date > (now - timedelta(days=90)))
|
||||
|
||||
def _search_newly_hired_employee(self, operator, value):
|
||||
employees = self.env['hr.employee'].search([
|
||||
('create_date', '>', fields.Datetime.now() - timedelta(days=90))
|
||||
])
|
||||
return [('id', 'in', employees.ids)]
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
employees = super().create(vals_list)
|
||||
for employee in employees:
|
||||
if employee.applicant_id:
|
||||
employee.applicant_id._message_log_with_view(
|
||||
'hr_recruitment.applicant_hired_template',
|
||||
values={'applicant': employee.applicant_id},
|
||||
subtype_id=self.env.ref("hr_recruitment.mt_applicant_hired").id)
|
||||
return employees
|
||||
Loading…
Add table
Add a link
Reference in a new issue