mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
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
This commit is contained in:
committed by
Antoni Marroig Campomar
parent
06c1b96d5f
commit
821909547c
11
mrp_workorder_sequence/hooks.py
Normal file
11
mrp_workorder_sequence/hooks.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# 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
|
||||
Reference in New Issue
Block a user