Merge pull request #5419 from expsa/feature/hr-department-correct-display-20251113-233449

fix: correct HR department and branch name display logic
This commit is contained in:
Mohamed Eltayar 2025-11-13 23:35:46 +03:00 committed by GitHub
commit 2d76a307ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 13 deletions

View File

@ -26,24 +26,25 @@ class HrDepartment(models.Model):
def name_get(self):
result = []
for department in self:
# إذا كان السياق يطلب المسار الكامل
if self.env.context.get('show_full_path'):
name = super(HrDepartment, department).name_get()[0][1]
else:
# الاسم المختصر (الافتراضي)
name = department.name
name = department.name
# إضافة اسم الفرع فقط للأقسام (ليس للفروع)
if not department.is_branch and department.branch_name:
name = f"{department.name} - {department.branch_name.name}"
result.append((department.id, name))
return result
@property
def display_name(self):
"""Override display_name to show short name for all departments"""
# إذا كان السياق يطلب المسار الكامل
if self.env.context.get('show_full_path'):
return super().display_name
else:
# الاسم المختصر (الافتراضي)
return self.name
"""Override display_name to show department name with branch"""
name = self.name
# إضافة اسم الفرع فقط للأقسام (ليس للفروع)
if not self.is_branch and self.branch_name:
name = f"{self.name} - {self.branch_name.name}"
return name
@api.depends('is_branch','parent_id')
def get_is_branch(self):