fix: ensure branch departments always display short names

- Modified name_get method to prioritize is_branch flag
- Branch departments (is_branch=True) now always show name only
- Maintains context support for other cases
- Fixes issue where branch names showed full hierarchical path
- Ensures consistent short name display across all related fields

Files modified:
- odex25_hr/hr_base/models/hr_department.py

This resolves the issue where branch names appeared with full path
even when context was provided for short display.
This commit is contained in:
Mohamed Eltayar 2025-11-13 15:33:55 +03:00
parent 1ff8aca934
commit 5b10bd7065
1 changed files with 7 additions and 3 deletions

View File

@ -26,11 +26,15 @@ class HrDepartment(models.Model):
def name_get(self):
result = []
for department in self:
# إذا كان السياق من branch_name field أو طلب عرض مختصر
if self.env.context.get('from_branch_field') or self.env.context.get('show_branch_short'):
# إذا كان هذا القسم فرع، اعرض الاسم فقط بدون مسار
if department.is_branch:
name = department.name # الاسم فقط بدون مسار للفروع
# إذا كان السياق يطلب عرض مختصر
elif (self.env.context.get('from_branch_field') or
self.env.context.get('show_branch_short')):
name = department.name # الاسم فقط بدون مسار
else:
# العرض الافتراضي (مع المسار الهرمي)
# العرض الافتراضي (مع المسار الهرمي) للأقسام العادية
name = super(HrDepartment, department).name_get()[0][1]
result.append((department.id, name))
return result