Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2633 มุมมอง

Hi Forum!


I got this error:


  anual_leave_total += rec.remaining_count or 0
AttributeError: 'hr.holidays' object has no attribute 'remaining_count'


The method that is causing the problem:

@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)
total_record = total_holidays.mapped("holidays_ids").filtered(lambda lm: lm.holiday_status_id.name == 'annual')
anual_leave_total = 0
for rec in total_record:
anual_leave_total += rec.remaining_count or 0
record.current_holiday_pool = anual_leave_total

I think the problem may be because the remaining_count is in the hr.employee model, how could I rewrite the method to work?

Thank you for your help!


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
How to find the field type? แก้ไขแล้ว
1
มิ.ย. 25
5068
3
ก.ค. 20
11700
4
ต.ค. 24
5252
0
พ.ย. 16
4054
1
ส.ค. 15
4608