
    aXj                     V    d dl mZmZmZmZ d dlmZ dZ G d dej                        Z	y)    )_apifieldsmodels)	UserErrorz"hr_holidays.group_hr_holidays_userc                       e Zd ZdZdZ ej                  ddd      Z ej                  dd      Z	 ej                  dd      Z
 ej                  d	d
      Z ej                  d      d        Zd Zy)XenoLeaveHolidayDeductzxeno.leave.holiday.deductaO  HR: deduct a leave day from one or more employees for a company holiday, per this company's policy that a company holiday draws down Annual Leave, falling back to Personal Leave and then Unpaid Leave if balance is insufficient -- never split across types for the same day(s), the whole deduction moves to the next tier if the current one can't cover it in full. The cascade itself lives on hr.leave (_xeno_deduct_for_company_holiday), shared with xeno_holidays' automatic hook on company-holiday creation -- this wizard is the manual, pick-your-own-employees entry point onto the same logic.zhr.employeeEmployeeT)stringrequiredzHoliday Start DatezHoliday End DateReasonzCompany holiday deduction)r   default	date_fromc                     | j                   r8| j                  r| j                  | j                   k  r| j                   | _        y y y )N)r   date_toselfs    F/home/susu/odoo-hr-migration/xeno_leave/wizard/leave_holiday_deduct.py_onchange_date_fromz*XenoLeaveHolidayDeduct._onchange_date_from   s1    >>4<<4<<$..3P>>DL 4Q>    c                    | j                          | j                  j                  j                  t              st        t        d            | j                  | j                  k  rt        t        d            | j                  d   j                  | j                  | j                  | j                  | j                         ddiS )NzXOnly Time Off Officers can deduct a company holiday against an employee's leave balance.z(End date must be on or after start date.zhr.leave)reasontypezir.actions.act_window_close)
ensure_oneenvuser	has_groupHR_OFFICER_GROUPr   r   r   r    _xeno_deduct_for_company_holidayemployee_idsnamer   s    r   action_applyz#XenoLeaveHolidayDeduct.action_apply    s    xx}}&&'78A78 9 9 <<$..(AHIJJ==t~~t||DII 	> 	O566r   N)__name__
__module____qualname___name_descriptionr   	Many2manyr    Dater   r   Textr!   r   onchanger   r"    r   r   r	   r	      s    'E		+  $6##M*tTL#7$GIfkk!3dCG6;;h0KLDS\\+* *
7r   r	   N)
odoor   r   r   r   odoo.exceptionsr   r   TransientModelr	   r,   r   r   <module>r0      s&    ' ' %7 #7V22 #7r   