Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2626 Представления

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 Ответы Просмотры Активность
1
июн. 25
5062
3
июл. 20
11696
4
окт. 24
5248
0
нояб. 16
4049
1
авг. 15
4606