To prevent Manufacturing Orders (MOs) or Work Orders from being scheduled during off-hours in Odoo (v17e) and ensure that operations respect the work center's defined working hours, follow these steps:
1. Understand the Issue
Odoo’s default planning engine for MOs and Work Orders tries to optimize for the earliest available start time. However, it does not automatically restrict operations to occur only within a work center’s scheduled hours unless additional configuration or logic is applied.
2. Configure Work Center Operating Hours
-
Set Work Center Working Hours:
- Navigate to Manufacturing > Configuration > Work Centers.
- Select the work center (e.g., USINE).
- Under the Working Hours field, assign the correct schedule (e.g., 8 AM to 5 PM).
-
Verify the Schedule:
- Go to Settings > Technical > Resources > Working Hours.
- Check that the working hours (e.g., 8 AM - 5 PM) and breaks (if any) are correctly defined.
3. Use the "One Work Order at a Time" Option
-
Configure Work Center Rules:
- Open the work center configuration and enable One Work Order at a Time.
- This ensures that only one work order is scheduled in the work center at a time, preventing overlapping jobs.
-
Ensure Capacity and Duration Align:
- For each manufacturing process, check that the duration of operations matches the work center’s schedule.
- Navigate to Manufacturing > Configuration > Operations and adjust the operation times if necessary.
4. Use the "Scheduling with Constraints" Feature
Odoo Enterprise includes tools to handle constraints in scheduling.
-
Enable Advanced Planning Options:
- Navigate to Settings > Manufacturing.
- Enable Work Order Dependencies or Planning by Work Centers if they aren’t already enabled.
-
Ensure Dependencies are Correctly Configured:
- For each operation, set up dependencies to ensure proper sequencing.
- Go to the Bill of Materials (BoM) and define the dependencies in the Operations tab.
-
Configure Work Center Schedules in Operations:
- In the Routing linked to your BoM, ensure the work center’s schedule is assigned.
5. Automatically Adjust Planning to Working Hours
Odoo's planning logic might require adjustments to prevent jobs from being split across off-hours. You can achieve this in one of two ways:
Option A: Manual Adjustment
- Use the Gantt view in the Manufacturing module:
- Navigate to Manufacturing > Planning > Work Centers.
- Drag and drop operations to align with work center hours.
Option B: Customization (Automated Adjustment)
- Use Python and Odoo Studio to create logic that prevents MOs from being scheduled outside working hours. Here’s an example:
Python Code:
from odoo import models, fields, api
from datetime import timedelta
class MrpWorkOrder(models.Model):
_inherit = 'mrp.workorder'
@api.model
def schedule_with_working_hours(self):
for workorder in self:
work_center = workorder.workcenter_id
working_hours = work_center.resource_calendar_id
planned_start = workorder.date_planned_start
# Adjust start time to align with work center working hours
if not working_hours.is_work_time(planned_start):
next_work_time = working_hours.plan_hours(0, planned_start)
workorder.date_planned_start = next_work_time
workorder.date_planned_finished = next_work_time + timedelta(hours=workorder.duration_expected)
- This logic checks if the planned start time aligns with working hours. If not, it shifts the start time to the next available working hour.
6. Test the Setup
-
Create a New MO:
- Ensure that the work order is planned within the configured work center hours.
- If using customizations, verify that the MOs adjust automatically to fit working hours.
-
Simulate Edge Cases:
- Test scenarios where the operation duration exceeds the remaining working hours in the day.
- Confirm that Odoo schedules the next part of the operation to the following working day.
7. Conclusion
In vanilla Odoo, while some adjustments can be made using configurations like working hours, dependencies, and the Gantt view, full automation of this behavior might require minor customization. Using the provided solutions, you can:
- Restrict scheduling to work center hours.
- Adjust the planning logic manually or automatically to align with defined schedules.
Let me know if you'd like further assistance with implementing any of these configurations or customizations!
I believe the only way is to manually plan the manufacturing orders.
By default, almost all systems will begin one MO after another.