B
    -Db                 @   sd   d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 G dd deZG dd	 d	eZd
S )    )	ModelFormwidgets)forms)Area)AccCombination)get_current_company_idc                   s@   e Zd Zejej dddZG dd dZ	 fddZ
  ZS )AccCombinationFormT)querysetdisabledrequiredc            	   @   s&   e Zd ZeZddddddddd	g	Zd
S )zAccCombinationForm.Metaareacombination_noZcombination_nameZremarkZgroup1Zgroup2Zgroup3Zgroup4Zgroup5N)__name__
__module____qualname__r   Zmodelfields r   r   ?G:\easytimepro\master/mysite/acc\forms\acc_combination_forms.pyMeta   s   r   c                s   t t| j|| d }|r*|d dd }t| drDt| drD| j}t }tj	j
|d| jd _y|| jd _W n tk
r   Y nX d S )Nr   r   	area_id_F)Zcompany__id)superr   __init__gethasattrgetattrr   r   r   objectsfilterr   r	   initial	Exception)selfargskwargsZdefault_areaZcurrent_company)	__class__r   r   r      s    zAccCombinationForm.__init__)r   r   r   r   ZModelChoiceFieldr   r   Znoner   r   r   __classcell__r   r   )r"   r   r      s   r   c                   s   e Zd Z fddZ  ZS )AccCombinationEditFormc                s:   t t| j|| |d}d| jd _|j| jd _d S )NinstanceTr   r   )r   r$   r   r   r   r
   Zarea_idr   )r   r    r!   obj)r"   r   r   r   '   s    
zAccCombinationEditForm.__init__)r   r   r   r   r#   r   r   )r"   r   r$   &   s   r$   N)Zdjango.formsr   r   Zmysite.adminr   Zmysite.personnel.modelsr   Zmysite.acc.modelsr   Zmysite.att.utilsr   r   r$   r   r   r   r   <module>   s   