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

Hi forum!


I try to calculate employees leaves and i get this error:

record.current_holiday_pool = total_holidays.remaining_count - total_record
TypeError: unsupported operand type(s) for -: 'int' and 'hr.holidays'


my method:


current_holiday_pool = fields.Integer(compute="_get_current_holiday_pool", store=True)

@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')
record.current_holiday_pool = total_holidays.remaining_count - total_record

What do I do wrong?
Thank you for your help!

Regards,

Steven

الصورة الرمزية
إهمال
أفضل إجابة

Hi Steven: total_record is returning a recordset, whereas according to the error message, total_holidays.remaining_count is an integer. Assuming that you are trying to get a count of the records, change total_record to len(total_record) and it should work.

الصورة الرمزية
إهمال
الكاتب

Thank you very much for your reply, solved the issue!

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
يوليو 25
2
2
أبريل 21
13710
2
فبراير 19
7917
2
أغسطس 18
4673
0
أبريل 16
9140