On mrp.bom model with super create function I have added logic that adds operations as first step, and then blocked_by operations to those.
When adding the operation dependecies(blocked_by_operation_ids), the operation with multiple blocked_by_operation_ids gets added correctly but the ones with single id wont be added.
Everything works as intended on my localhost, but when pushing the code to odoo.sh I get this issue.
Here is my function:
# Assign dependecies to newly created operations
for op in created_operations:
display_name = op.display_name
blocked_by_operations = []
blocked_by_ids = []
for operation_key, operation_data in operations.items():
if display_name == operation_data["display_name"]:
blocked_by_operations = operation_data["blocked_by"]
break
for b_op in blocked_by_operations:
for e in created_operations:
if e.display_name == b_op:
blocked_by_ids.append(e.id)
if blocked_by_ids:
if len(blocked_by_ids) == 1:
op.blocked_by_operation_ids = [(4, blocked_by_ids[0])]
else:
op.blocked_by_operation_ids = [(4, id) for id in blocked_by_ids]
op.env.cr.flush()
This is how it looks in frontend, most of the lines there should have 1 operation as blocked_by
I have tried using write method instead of [(4, id) for id in blocked_by_ids].
Also tried flushing before and after function.
Also tried adding a dummy id for those, and then it also works. For some reason it wont add single id operations to this record…