From e6df7bb718962c01effdb68a5a8f9bd633ddb280 Mon Sep 17 00:00:00 2001 From: "Nasreddin (bon)" Date: Thu, 4 Jun 2020 10:51:41 +0000 Subject: [PATCH] [FIX] hr: Empty required name on quick create department Issue - Open console in debugger of the browser. - Install "Employees" app - Go to "Employees" and edit or create any employee - In 'Department' field, quick create one Error is raised in console and the modal department form view is opened. Cause 'name' field is required but empty since 'complete_name' is the one set as _rec_name in 'Department' python model. Solution Cherry-pick of 7c0fed48a1479b08e3a2d526f8557d247466a547 opw-2267356 closes odoo/odoo#52489 X-original-commit: 056618914e9f1f437f8855459c302fc0ac6663c5 Signed-off-by: Nicolas Martinelli (nim) Signed-off-by: bon-odoo --- addons/hr/models/hr_department.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/hr/models/hr_department.py b/addons/hr/models/hr_department.py index 081318ef3e1..d65b8cb9de9 100644 --- a/addons/hr/models/hr_department.py +++ b/addons/hr/models/hr_department.py @@ -29,6 +29,10 @@ class Department(models.Model): return [(record.id, record.name) for record in self] return super(Department, self).name_get() + @api.model + def name_create(self, name): + return self.create({'name': name}).name_get()[0] + @api.depends('name', 'parent_id.complete_name') def _compute_complete_name(self): for department in self: