From 44dd40d579b4329be3d7cf4fa1947ceebf99885e Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Wed, 21 Oct 2015 11:11:42 +0200 Subject: [PATCH] [ADD] Set default for do_production upon installation --- mrp_operations_extension/__init__.py | 13 +++++++++++++ mrp_operations_extension/__openerp__.py | 1 + 2 files changed, 14 insertions(+) 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 }