Skip to content

Commit 7510f5a

Browse files
author
agyamuta@github.com
committed
[IMP] Updated _cron_process_action_post_inventory_wip to iterate over each MO ID with try/except, creating a "To Do" activity with summary "Post WIP error", exception details in the note, and assigned to the MO's responsible user when an exception occurs.
1 parent cc5b292 commit 7510f5a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

osi_mrp_auto_post_wip/models/mrp_production.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,19 @@ def _cron_process_action_post_inventory_wip(self):
1111
mrp_ids = self.env["mrp.production"].search(
1212
[("state", "in", ["progress", "to_close"])]
1313
)
14-
mrp_ids.action_post_inventory_wip()
14+
for mrp_id in mrp_ids:
15+
try:
16+
mrp_id.action_post_inventory_wip()
17+
except Exception as e:
18+
# Get the todo activity type
19+
activity_type = self.env.ref('mail.mail_activity_data_todo', raise_if_not_found=False)
20+
if not activity_type:
21+
activity_type = self.env['mail.activity.type'].search([('name', '=', 'To Do')], limit=1)
22+
23+
# Create activity with error details
24+
mrp_id.activity_schedule(
25+
activity_type_id=activity_type.id if activity_type else False,
26+
summary='Post WIP Error',
27+
note=str(e),
28+
user_id=mrp_id.user_id.id if mrp_id.user_id else False
29+
)

0 commit comments

Comments
 (0)