We have a manufacturing order that is a sub-assembly. When the top level assembly was originally released with a schedule date, it set the deadline date on the sub-assembly, but we need to adjust the schedule due to vendor part delivery, but it will not update the availability on the top level assembly
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilitat
- Inventari
- PoS
- Project
- MRP
This question has been flagged
We also have the same problem. I would like that the deadline in the manufacturing order is related to the deadline in the sale order. If the sale order deadline is changed, the deadline in de manufacturing order should change. Is this easy to realise?
I'll share my experience. I'm using Odoo Online version 18. But, I've opted to maintain my own automation rules. Heads up- I am no professional, I bounce a lot of code back and forth with AI and end up coming up with a solution, this may not be something you're willing to do, but it has allowed me to solve a lot of fallbacks that I have found with Odoo Online without breaking the bank for outside customization.
This was on my list to write the delivery date of the sale.order. I have a field that I put in the sale order heading commitment date that is required for all of our sale orders, this is related to the delivery order field, just to explain the code more.
I also have one2many related fields on the sale order for this code and some others for a quick reference of related DOs and MOs. This was to avoid having to use search in the automation rules.
Now that you know what these studio fields are in my code, this is what I've gotten to work. A simple "write()" function did not work, I'm guessing because date_deadline is a natively readonly field. I then found that if you used this code to write the date_deadline more than once, it would go back to the original every other time. So that's why there is a boolean condition in the code to change the way it writes the field upon additional changes.
if record.x_studio_commitment_date:
# Update the scheduled date on the associated delivery order(s)
for delivery in record.x_studio_delivery_order.filtered(lambda d: d.state not in ['cancel', 'done']):
delivery.sudo().write({'scheduled_date': record.x_studio_commitment_date})
# Step 1: Update scheduled end date (`date_finished`) and deadline (`date_deadline`)
for mo in record.x_studio_manufacturing_order.filtered(lambda m: m.state not in ['cancel', 'done']):
# Update scheduled end date (`date_finished`)
mo.sudo().write({'date_finished': record.x_studio_commitment_date})
# Check if the deadline has been manually edited
if not mo.x_studio_deadline_date_edited:
# Use SQL to update the readonly field
mo.env.cr.execute("""
UPDATE mrp_production
SET date_deadline = %s
WHERE id = %s
""", (record.x_studio_commitment_date, mo.id))
mo.env.cr.commit() # Commit the transaction
# Mark that the deadline was updated by automation
mo.sudo().write({'x_studio_deadline_date_edited': True})
else:
# If manually edited, write the deadline normally
mo.sudo().write({'date_deadline': record.x_studio_commitment_date})
Because the start date of the MO depends on the BOM Manufacturing Leadtime (or others if you have them) you will have to rewrite these as well. I had a lot of issues with this as the manufacturing lead-time is an integer field. Again, I like to use related fields in the model I'm working with to run code, so I brought over my BOM Leadtime via related field.
This is the separate automation rule to update the Start date:
if record.date_finished:
# Fetch the lead time in days (default to 0 if undefined)
leadtime_days = record.x_studio_bom_manufacturing_leadtime or 0 # Integer value
# Calculate the new start date using relativedelta
new_start_date = record.date_finished - dateutil.relativedelta.relativedelta(days=leadtime_days)
# Update the start date
record.sudo().write({'date_start': new_start_date})
Note, if you have other manufacturing leadtimes built in, you likely will have to add them into the code to give the correct start date.
Same Problem here. Did you find a workaround for this or a solution? We have the problem that a customer maybe wants to change the original delivery date and this should effect the manufacturing orders too but Odoo doesn't seem to have a solution for this. I can change the delivery date on the sales order and adjust manually the planned date on the MO's but the deadline on the MO doesn't change. Would be nice when the deadline on the MO get's updated similar to the delivery order.
Anybody found a solution for this?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Registrar-se