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

Dear Forum!

in this method, the total holidays variable is 20, and the total_record variable is the leave, which is the annual leave, I only need to subtract the total record values ​​from the 20 values. However, if you do not add a value to total_record (that is, if the employee takes a non-annual leave), add +1 to 20.

That is, a value should only be deducted from total_holidays.remaining_count if you take an annual for the type of leave used.

How should I change the method to achieve this?

@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_holidays:
anual_leave_total += rec.remaining_count or 0
record.current_holiday_pool = anual_leave_total

Thank you for your help!


Regards,

Steven

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello Steven Salty ,

I checked question, but there are some information is missing in your question, Can you please provide me below information so I can help you in your concern.

Questions:
1. Can you please provide me object name for the function which you have mentioned in question.
2. Can you please provide me object name for the yearly_holidays_ids.

Hope this may help you!

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

อวตาร
ละทิ้ง
ผู้เขียน

Hello Jainesh Shah(Aktiv Software)!

I replied to you by email, the subject of the email: How do I change the method? (Answer to Odoo forum question.)
My email: peehvideos@gmail.com

Thank you for your help!

Regards,
Steven Salty

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.ย. 21
3004
TypeError: 'int' object is not iterable แก้ไขแล้ว
4
ม.ค. 18
36263
0
ธ.ค. 21
1986
Why this computed field doest not work? แก้ไขแล้ว
1
ธ.ค. 21
6054
2
มี.ค. 24
2035