diff --git a/mrp_operations_extension/__init__.py b/mrp_operations_extension/__init__.py index c1a24230c..3082d9efd 100644 --- a/mrp_operations_extension/__init__.py +++ b/mrp_operations_extension/__init__.py @@ -4,3 +4,16 @@ ############################################################################## from . import models from . import wizard + + +def post_init_hook(cr, pool): + """ Set do_production on the last workcenter line of each routing """ + cr.execute( + """ + UPDATE mrp_routing_workcenter SET do_production = TRUE + WHERE id IN ( + SELECT ( + SELECT id FROM mrp_routing_workcenter WHERE routing_id = mr.id + ORDER BY sequence DESC, id DESC LIMIT 1) + FROM mrp_routing mr); + """) diff --git a/mrp_operations_extension/__openerp__.py b/mrp_operations_extension/__openerp__.py index f7c896f3b..d56aaac5f 100644 --- a/mrp_operations_extension/__openerp__.py +++ b/mrp_operations_extension/__openerp__.py @@ -60,5 +60,6 @@ "demo/mrp_routing_demo.xml", "demo/mrp_production_demo.xml", ], + "post_init_hook": "post_init_hook", "installable": True }