Files
manufacture/mrp_workorder_sequence/hooks.py
Akim Juillerat 821909547c Ensure workorder sequence is applied on new workorders
Test sequence is applied for multiple operations
Rewrite _reset_work_order_sequence in a more pythonic way
Change _order of mrp.workorder to use sequence
Set sequence on existing workorders after module install
2024-04-24 08:52:55 +02:00

12 lines
471 B
Python

# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import SUPERUSER_ID, api, tools
def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
all_workorders = env["mrp.workorder"].search([], order="production_id ASC, id ASC")
for _, workorders in tools.groupby(all_workorders, lambda w: w.production_id):
for seq, wo in enumerate(workorders, 1):
wo.sequence = seq