summaryrefslogtreecommitdiff
path: root/addons/hr/wizard
diff options
context:
space:
mode:
authorVictor Feyens <vfe@odoo.com>2020-07-14 14:32:37 +0000
committerVictor Feyens <vfe@odoo.com>2020-07-23 16:38:17 +0000
commit5dc8b7bdd8ea8a760d1929333cd8461047e5b4e6 (patch)
treea726b57bea6d1f801f802767396e2f7f736725c4 /addons/hr/wizard
parent71ab12840bc787ca486202255cd6faa21281b9e1 (diff)
[IMP] *: replace default_get overrides by default attribute on fields.
Leave the generic management of fields default to the orm as much as possible. * Default method is not called unless necessary. * Default values are correctly post-processed by the orm when necessary.
Diffstat (limited to 'addons/hr/wizard')
-rw-r--r--addons/hr/wizard/hr_departure_wizard.py13
-rw-r--r--addons/hr/wizard/hr_plan_wizard.py13
2 files changed, 8 insertions, 18 deletions
diff --git a/addons/hr/wizard/hr_departure_wizard.py b/addons/hr/wizard/hr_departure_wizard.py
index 5e7782a1648..af8619270d8 100644
--- a/addons/hr/wizard/hr_departure_wizard.py
+++ b/addons/hr/wizard/hr_departure_wizard.py
@@ -8,14 +8,6 @@ class HrDepartureWizard(models.TransientModel):
_name = 'hr.departure.wizard'
_description = 'Departure Wizard'
- @api.model
- def default_get(self, fields):
- res = super(HrDepartureWizard, self).default_get(fields)
- if (not fields or 'employee_id' in fields) and 'employee_id' not in res:
- if self.env.context.get('active_id'):
- res['employee_id'] = self.env.context['active_id']
- return res
-
departure_reason = fields.Selection([
('fired', 'Fired'),
('resigned', 'Resigned'),
@@ -23,7 +15,10 @@ class HrDepartureWizard(models.TransientModel):
], string="Departure Reason", default="fired")
departure_description = fields.Text(string="Additional Information")
departure_date = fields.Date(string="Departure Date", required=True, default=fields.Date.today)
- employee_id = fields.Many2one('hr.employee', string='Employee', required=True)
+ employee_id = fields.Many2one(
+ 'hr.employee', string='Employee', required=True,
+ default=lambda self: self.env.context.get('active_id', None),
+ )
archive_private_address = fields.Boolean('Archive Private Address', default=True)
def action_register_departure(self):
diff --git a/addons/hr/wizard/hr_plan_wizard.py b/addons/hr/wizard/hr_plan_wizard.py
index 0a9e27c35ea..69e1ee280b9 100644
--- a/addons/hr/wizard/hr_plan_wizard.py
+++ b/addons/hr/wizard/hr_plan_wizard.py
@@ -8,16 +8,11 @@ class HrPlanWizard(models.TransientModel):
_name = 'hr.plan.wizard'
_description = 'Plan Wizard'
- @api.model
- def default_get(self, fields_list):
- res = super(HrPlanWizard, self).default_get(fields_list)
- if (not fields_list or 'employee_id' in fields_list) and 'employee_id' not in res:
- if self.env.context.get('active_id'):
- res['employee_id'] = self.env.context['active_id']
- return res
-
plan_id = fields.Many2one('hr.plan', default=lambda self: self.env['hr.plan'].search([], limit=1))
- employee_id = fields.Many2one('hr.employee', string='Employee', required=True)
+ employee_id = fields.Many2one(
+ 'hr.employee', string='Employee', required=True,
+ default=lambda self: self.env.context.get('active_id', None),
+ )
def action_launch(self):
for activity_type in self.plan_id.plan_activity_type_ids: