Hello Odooers,
i got 2 fields:
date_from and date_to with time both.
How to compute a field to be "True" if record date_from.time() and date_to.time() is between 00:00 and 07:00.
Thank you
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello Odooers,
i got 2 fields:
date_from and date_to with time both.
How to compute a field to be "True" if record date_from.time() and date_to.time() is between 00:00 and 07:00.
Thank you
def _compute_in_range(self):
for record in self:
# Get user's timezone
tz = self.env.user.tz or 'UTC'
# Convert datetime_field to user's timezone
dt = pytz.timezone(tz).localize(record.datetime_field)
start = datetime.strptime("00:00", "%H:%M").time()
end = datetime.strptime("07:30", "%H:%M").time()
new_dt = add_time_range(dt)
if new_dt.time() >= start and new_dt.time() <= end:
record.in_range = True
else:
record.in_range = False
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
2
ก.ค. 22
|
2175 | ||
|
2
มี.ค. 22
|
6789 | ||
|
1
ก.ค. 22
|
2417 | ||
|
1
ก.พ. 22
|
2808 | ||
|
1
เม.ย. 24
|
1475 |