feat: enhance department display with short name support
🔧 **Key Improvements:** - Extended name_get to support show_department_short context - Added display_name property override for consistent short display - Enhanced tree view with department context for clean display - Fixed translation consistency (Department = القسم) 📁 **Files Modified:** - odex25_hr/hr_base/models/hr_department.py: Enhanced name_get and added display_name property - odex25_hr/hr_base/views/hr_base_view.xml: Added context to department fields in all views - odex25_hr/hr_base/i18n/ar_001.po: Unified Department translation to القسم ✅ **Impact:** - Department names now display without hierarchical path when context is set - Consistent short name display across all HR views (form, tree, search) - Unified Arabic translation for better UX - Maintains backward compatibility with existing functionality Synced with latest dev_odex25_hr on Thu Nov 13 18:25:53 +03 2025
This commit is contained in:
parent
0a8ee3ebfd
commit
e290c7fd3c
|
|
@ -1445,7 +1445,7 @@ msgstr "قسم الارتباط"
|
|||
#. module: hr_base
|
||||
#: model:ir.model.fields.selection,name:hr_base.selection__hr_department__department_type__department
|
||||
msgid "Department"
|
||||
msgstr "إدارة"
|
||||
msgstr "القسم"
|
||||
|
||||
#. module: hr_base
|
||||
#: model:ir.model.fields.selection,name:hr_base.selection__hr_department__department_type__unit
|
||||
|
|
|
|||
|
|
@ -29,9 +29,10 @@ class HrDepartment(models.Model):
|
|||
# إذا كان هذا القسم فرع، اعرض الاسم فقط بدون مسار
|
||||
if department.is_branch:
|
||||
name = department.name # الاسم فقط بدون مسار للفروع
|
||||
# إذا كان السياق يطلب عرض مختصر
|
||||
# إذا كان السياق يطلب عرض مختصر للفرع أو القسم
|
||||
elif (self.env.context.get('from_branch_field') or
|
||||
self.env.context.get('show_branch_short')):
|
||||
self.env.context.get('show_branch_short') or
|
||||
self.env.context.get('show_department_short')):
|
||||
name = department.name # الاسم فقط بدون مسار
|
||||
else:
|
||||
# العرض الافتراضي (مع المسار الهرمي) للأقسام العادية
|
||||
|
|
@ -39,6 +40,21 @@ class HrDepartment(models.Model):
|
|||
result.append((department.id, name))
|
||||
return result
|
||||
|
||||
@property
|
||||
def display_name(self):
|
||||
"""Override display_name to show short name when needed"""
|
||||
# إذا كان هذا القسم فرع، اعرض الاسم فقط
|
||||
if self.is_branch:
|
||||
return self.name
|
||||
# إذا كان السياق يطلب عرض مختصر
|
||||
elif (self.env.context.get('from_branch_field') or
|
||||
self.env.context.get('show_branch_short') or
|
||||
self.env.context.get('show_department_short')):
|
||||
return self.name
|
||||
else:
|
||||
# العرض الافتراضي (مع المسار الهرمي)
|
||||
return super().display_name
|
||||
|
||||
@api.depends('is_branch','parent_id')
|
||||
def get_is_branch(self):
|
||||
"""To know which unit or department belongs to a specific branch"""
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@
|
|||
<field name="contract_id" string="Contract" readonly="1"
|
||||
attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="department_id" required="True" string="Department"
|
||||
attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
attrs="{'readonly':[('state','!=','draft')]}" context="{'show_department_short': True}"/>
|
||||
<field name="branch_name" string="Branch Name" invisible="1" readonly="1" context="{'show_branch_short': True}"/>
|
||||
<field name="job_id" required="True" string="Job Position"
|
||||
attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
|
|
@ -567,6 +567,7 @@
|
|||
<field name="department_type" required="1"/>
|
||||
<field name="is_branch" string="Is Branch?"/>
|
||||
<field name="branch_name" string="Branch Name" context="{'show_branch_short': True}"/>
|
||||
<field name="department_id" context="{'show_department_short': True}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<label for="english_name" class="oe_edit_only"/>
|
||||
|
|
@ -604,6 +605,9 @@
|
|||
<xpath expr="//field[@name='display_name']" position="after">
|
||||
<field name="branch_name" string="Branch" context="{'show_branch_short': True}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='display_name']" position="attributes">
|
||||
<attribute name="context">{'show_department_short': True}</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
@ -615,10 +619,12 @@
|
|||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="branch_name" string="Branch" context="{'show_branch_short': True}"/>
|
||||
<field name="department_id" string="Department" context="{'show_department_short': True}"/>
|
||||
</xpath>
|
||||
<xpath expr="//filter[@name='inactive']" position="after">
|
||||
<separator/>
|
||||
<filter string="Branch" name="group_branch" context="{'group_by':'branch_name', 'show_branch_short': True}"/>
|
||||
<filter string="Department" name="group_department" context="{'group_by':'department_id', 'show_department_short': True}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
|||
Loading…
Reference in New Issue