تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
4089 أدوات العرض

I have this method, i need to change it to if the value of annual_leave changes, nothing should happen, but if the value does not change, add +1 to the remaining count variable. How can i do it ?

@api.multi
@api.depends('yearly_holidays_ids')
def _get_current_holiday_pool(self):
    for record in self:
        current_year = datetime.date.today().year
        total_holidays = record.yearly_holidays_ids.filtered(lambda lm:lm.year == current_year)
        annual_leaves = self.env['hr.holidays'].search_count([('holiday_status_id.name', '=', 'annual')])
        if annual_leaves > 1:
            total_holidays = total_holidays[0]
            record.current_holiday_pool = total_holidays.remaining_count
        elif annual_leaves == 1:
            record.current_holiday_pool = total_holidays.remaining_count
        elif annual_leaves == 0:
            record.current_holiday_pool = 0

Thank you for your help!

Regards, Steven


الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
3
فبراير 16
5655
1
يوليو 23
2818
5
ديسمبر 24
33119
Expected singleton تم الحل
9
مارس 20
42024
1
يناير 19
5738