B
    GDb                 @   sv   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ eeG dd	 d	eZd
S )    )Q)admin)ZKModelAdmin)SalaryStructure)AddSalaryStructureActionSalaryStructureChangeForm)STATUS_RESIGN)Employeec                   sD   e Zd ZdZdZdZegZeZ	dd Z
dddZ fd	d
Z  ZS )SalaryStructureAdmin)idZemp_codeZ
first_name	last_nameZ
departmentsalary_amounteffective_dateZcreate_timeZdeductionformula_nameZexceptionformula_nameZincreasementformula_nameZleaveformula_nameZovertimeformula_nameZsalary_remark)employee__emp_codeZemployee__first_nameZemployee__last_namer   r   )r   c             C   s   dS )NF )selfrequestr   r   DG:\easytimepro\master/mysite/payroll\admin\salary_structure_admin.pyhas_add_permission   s    z'SalaryStructureAdmin.has_add_permissionNc             C   s   |r
dgS g S d S )Nemployeer   )r   r   objr   r   r   get_readonly_fields   s    z(SalaryStructureAdmin.get_readonly_fieldsc                s   t t| |j|jjd}|ddddddd}|jt	d	}|jj
}|jj}|jjs| rr|j| d
}| rtjj|jjdj| d}|j|d}| S )N)Zemployee__company_idr   Zemployee__departmentZdeductionformulaZexceptionformulaZincreasementformulaZleaveformulaZovertimeformula)Zemployee__status)Zemployee__department__in)Z
company_id)Zarea__in)Zemployee__in)superr
   get_querysetfilteruserZcurrent_companyZselect_relatedZprefetch_relatedZexcluder   Zget_auth_areaZget_auth_deptZis_superuserexistsallr	   ZobjectsZdistinct)r   r   ZqsZ	auth_areaZ	auth_deptZemp_list_by_area)	__class__r   r   r   "   s     z!SalaryStructureAdmin.get_queryset)N)__name__
__module____qualname__Zlist_displayZlist_filterZorderingr   Zactionsr   Zformr   r   r   __classcell__r   r   )r   r   r
      s   
r
   N)Zdjango.db.modelsr   mysiter   Zmysite.admin.kernelr   Zmysite.payroll.modelsr   Zmysite.payroll.formsr   r   Zmysite.admin.modelsr   Z&mysite.personnel.models.model_employeer	   registerr
   r   r   r   r   <module>   s   