diff options
Diffstat (limited to 'addons/hr')
| -rw-r--r-- | addons/hr/models/hr_employee.py | 7 | ||||
| -rw-r--r-- | addons/hr/views/hr_employee_views.xml | 1 | ||||
| -rw-r--r-- | addons/hr/wizard/hr_departure_wizard.py | 20 | ||||
| -rw-r--r-- | addons/hr/wizard/hr_departure_wizard_views.xml | 9 |
4 files changed, 21 insertions, 16 deletions
diff --git a/addons/hr/models/hr_employee.py b/addons/hr/models/hr_employee.py index 4f2bdafd323..0324babaf23 100644 --- a/addons/hr/models/hr_employee.py +++ b/addons/hr/models/hr_employee.py @@ -114,6 +114,7 @@ class HrEmployeePrivate(models.Model): ('retired', 'Retired') ], string="Departure Reason", groups="hr.group_hr_user", copy=False, tracking=True) departure_description = fields.Text(string="Additional Information", groups="hr.group_hr_user", copy=False, tracking=True) + departure_date = fields.Date(string="Departure Date", groups="hr.group_hr_user", copy=False, tracking=True) message_main_attachment_id = fields.Many2one(groups="hr.group_hr_user") _sql_constraints = [ @@ -273,10 +274,14 @@ class HrEmployeePrivate(models.Model): def toggle_active(self): res = super(HrEmployeePrivate, self).toggle_active() - self.filtered(lambda employee: employee.active).write({ + unarchived_employees = self.filtered(lambda employee: employee.active) + unarchived_employees.write({ 'departure_reason': False, 'departure_description': False, + 'departure_date': False }) + archived_addresses = unarchived_employees.mapped('address_home_id').filtered(lambda addr: not addr.active) + archived_addresses.toggle_active() if len(self) == 1 and not self.active: return { 'type': 'ir.actions.act_window', diff --git a/addons/hr/views/hr_employee_views.xml b/addons/hr/views/hr_employee_views.xml index 6ee8eb06309..c94bd150f9e 100644 --- a/addons/hr/views/hr_employee_views.xml +++ b/addons/hr/views/hr_employee_views.xml @@ -113,6 +113,7 @@ <group name="departure" string="Departure" attrs="{'invisible': [('active', '=', True)]}"> <field name="departure_reason"/> <field name="departure_description"/> + <field name="departure_date"/> </group> <group string="Schedule" groups="base.group_no_one"> <field name="resource_calendar_id" required="1"/> diff --git a/addons/hr/wizard/hr_departure_wizard.py b/addons/hr/wizard/hr_departure_wizard.py index c01b00c7fba..5e7782a1648 100644 --- a/addons/hr/wizard/hr_departure_wizard.py +++ b/addons/hr/wizard/hr_departure_wizard.py @@ -22,22 +22,18 @@ class HrDepartureWizard(models.TransientModel): ('retired', 'Retired') ], string="Departure Reason", default="fired") departure_description = fields.Text(string="Additional Information") - plan_id = fields.Many2one('hr.plan', default=lambda self: self.env['hr.plan'].search([], limit=1)) + departure_date = fields.Date(string="Departure Date", required=True, default=fields.Date.today) employee_id = fields.Many2one('hr.employee', string='Employee', required=True) + archive_private_address = fields.Boolean('Archive Private Address', default=True) def action_register_departure(self): employee = self.employee_id employee.departure_reason = self.departure_reason employee.departure_description = self.departure_description + employee.departure_date = self.departure_date - if not employee.user_id.partner_id: - return - - for activity_type in self.plan_id.plan_activity_type_ids: - self.env['mail.activity'].create({ - 'res_id': employee.user_id.partner_id.id, - 'res_model_id': self.env['ir.model']._get('res.partner').id, - 'activity_type_id': activity_type.activity_type_id.id, - 'summary': activity_type.summary, - 'user_id': activity_type.get_responsible_id(employee).id, - }) + if self.archive_private_address: + # ignore contact links to internal users + private_address = employee.address_home_id + if private_address and private_address.active and not self.env['res.users'].search([('partner_id', '=', private_address.id)]): + private_address.toggle_active() diff --git a/addons/hr/wizard/hr_departure_wizard_views.xml b/addons/hr/wizard/hr_departure_wizard_views.xml index 4b096235fc3..22b3b2b7157 100644 --- a/addons/hr/wizard/hr_departure_wizard_views.xml +++ b/addons/hr/wizard/hr_departure_wizard_views.xml @@ -7,16 +7,19 @@ <field name="arch" type="xml"> <form> <sheet> - <group> - <field name="plan_id"/> + <group id="info" string="Departure Info"> <field name="employee_id" invisible="1"/> <field name="departure_reason"/> <field name="departure_description"/> + <field name="archive_private_address"/> + </group> + <group id="date" string="Departure Date"> + <field name="departure_date" /> </group> </sheet> <footer> <button name="action_register_departure" string="Save" type="object" class="oe_highlight"/> - <button string="Cancel" class="btn-secondary" special="cancel"/> + <button string="Only Employee" class="btn-secondary" special="cancel"/> </footer> </form> </field> |
