[IMP] <mrp_bom_version> If BoM exist it is active so state must be 'active'

This commit is contained in:
oihane
2015-06-02 18:21:02 +02:00
parent f5868e0ccc
commit d44673b1f1
2 changed files with 13 additions and 1 deletions

View File

@@ -2,4 +2,15 @@
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from . import models
from openerp import SUPERUSER_ID
def set_bom_inactive(cr, registry):
"""Set all draft or historical state BoMs inactive."""
mrp_bom_obj = registry['mrp.bom']
mrp_bom_ids = mrp_bom_obj.search(cr, SUPERUSER_ID,
[('active', '=', True)])
for mrp_bom in mrp_bom_obj.browse(cr, SUPERUSER_ID, mrp_bom_ids):
mrp_bom_obj.write(cr, SUPERUSER_ID, mrp_bom.id, {'state': 'active'})

View File

@@ -41,5 +41,6 @@
"views/res_config_view.xml",
"views/mrp_bom_view.xml",
],
"installable": True
"installable": True,
"post_init_hook": "set_bom_inactive",
}