Hello,
Is there any way to block any periods in the field SCHEDULED DATE to avoid scheduling a date when we can´t deliver goods, for example during holidays? Or just enable a timeframe, for example Monday to Friday 09-17hrs?
Thank you,
Mireia
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello,
Is there any way to block any periods in the field SCHEDULED DATE to avoid scheduling a date when we can´t deliver goods, for example during holidays? Or just enable a timeframe, for example Monday to Friday 09-17hrs?
Thank you,
Mireia
Thank you!
Hi,
To add validation to the scheduled_date field, you can include the following conditions to restrict delivery scheduling to specific days and times and avoid holidays:
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
from datetime import time
@api.constrains('scheduled_date')
def _check_scheduled_date(self):
for picking in self:
if not picking.scheduled_date:
continue
local_date = fields.Datetime.context_timestamp(self, picking.scheduled_date)
if local_date.weekday() >= 5:
raise ValidationError(_('Deliveries cannot be scheduled on weekends'))
if not (time(9, 0) <= local_date.time() <= time(17, 0)):
raise ValidationError(_('Deliveries must be scheduled between 9:00 and 17:00'))
holiday_dates = self.env['resource.calendar.leaves'].search([
('date_from', '<=', picking.scheduled_date),
('date_to', '>=', picking.scheduled_date)
])
if holiday_dates:
raise ValidationError(_('Delivery cannot be scheduled on holidays'))
Hope it helps
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
0
พ.ย. 24
|
1157 | ||
|
1
ก.พ. 24
|
1481 | ||
|
1
ต.ค. 16
|
4597 | ||
|
1
มิ.ย. 25
|
669 | ||
|
1
มิ.ย. 25
|
692 |