Merge pull request #5412 from expsa/feature/department-display-enhancement-20251113-182545
feat: enhance department display with short name support
This commit is contained in:
commit
bc5f17dcf3
|
|
@ -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,15 +29,31 @@ 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:
|
||||
# العرض الافتراضي (مع المسار الهرمي) للأقسام العادية
|
||||
name = super(HrDepartment, department).name_get()[0][1]
|
||||
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):
|
||||
|
|
|
|||
|
|
@ -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