openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #00277
lp:~therp-nl/ocb-addons/7.0_lp1234004_configurable_auto_confirm_mo into lp:ocb-addons
Ronald Portier (Therp) has proposed merging lp:~therp-nl/ocb-addons/7.0_lp1234004_configurable_auto_confirm_mo into lp:ocb-addons.
Requested reviews:
OpenERP Community Backports Team (ocb)
Related bugs:
Bug #1234004 in OpenERP Community Backports (Addons): "Manufacturing order created from procurement is automatically confirmed"
https://bugs.launchpad.net/ocb-addons/+bug/1234004
For more details, see:
https://code.launchpad.net/~therp-nl/ocb-addons/7.0_lp1234004_configurable_auto_confirm_mo/+merge/189005
Fix lp1234004. Should be possible to create manufacturing orders from procurement in draft state.
Although a new configuration option is added to mrp, care has been taken not to need a database update.
Creating a new module to fix the bug was not a good option for maintainability.
--
https://code.launchpad.net/~therp-nl/ocb-addons/7.0_lp1234004_configurable_auto_confirm_mo/+merge/189005
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~therp-nl/ocb-addons/7.0_lp1234004_configurable_auto_confirm_mo into lp:ocb-addons.
=== modified file 'mrp/procurement.py'
--- mrp/procurement.py 2012-10-23 16:05:04 +0000
+++ mrp/procurement.py 2013-10-03 08:16:35 +0000
@@ -83,6 +83,13 @@
res = procurement_obj.make_mo(cr, uid, ids, context=context)
res = res.values()
return len(res) and res[0] or 0
+
+ def _get_auto_confirm_mo(self, cr, uid, context=None):
+ val = self.pool.get('ir.config_parameter').get_param(
+ cr, uid, 'auto_confirm_mo')
+ if val and val in ['f', 'F', 'false', 'False', '0']:
+ return False
+ return True
def make_mo(self, cr, uid, ids, context=None):
""" Make Manufacturing(production) order from procurement
@@ -117,7 +124,8 @@
self.write(cr, uid, [procurement.id], {'state': 'running', 'production_id': produce_id})
bom_result = production_obj.action_compute(cr, uid,
[produce_id], properties=[x.id for x in procurement.property_ids])
- wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr)
+ if self._get_auto_confirm_mo(cr, uid, context=context):
+ wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr)
if res_id:
move_obj.write(cr, uid, [res_id],
{'location_id': procurement.location_id.id})
=== modified file 'mrp/res_config.py'
--- mrp/res_config.py 2013-08-23 09:22:31 +0000
+++ mrp/res_config.py 2013-10-03 08:16:35 +0000
@@ -27,6 +27,54 @@
_name = 'mrp.config.settings'
_inherit = 'res.config.settings'
+ def default_get(self, cr, uid, field_names, context=None):
+
+ def bool_from_string(a_string):
+ if len(a_string) < 1:
+ return False
+ if a_string in ['f', 'F', 'false', 'False', '0']:
+ return False
+ return True
+
+ defaults = super(mrp_config_settings, self).default_get(
+ cr, uid, field_names, context=context)
+ config_model = self.pool.get('ir.config_parameter')
+ # link fieldnames to conversion functions and defaults
+ field_table = {
+ 'auto_confirm_mo': (bool_from_string, True),
+ }
+ for field_name in field_names:
+ if field_name in field_table:
+ (conversion, default_value) = field_table[field_name]
+ defaults[field_name] = default_value
+ # Get values in try/catch, because they might not be
+ # present, or may not be convertable to the right type
+ try:
+ val = config_model.get_param(cr, uid, field_name)
+ if val:
+ defaults[field_name] = conversion(val)
+ except:
+ pass
+ return defaults
+
+ # use multi for function fields to get/set config parameters, even though
+ # for the moment we use only one.
+ def _get_config_parms(self, cr, uid, ids, field_names, args, context=None):
+ res = {}
+ if not len(ids):
+ return res
+ vals = self.default_get(cr, uid, field_names, context=context)
+ for wizard_id in ids: # Should be only one
+ res[wizard_id] = vals
+ return res
+
+ def _write_config_parms(
+ self, cr, uid, ids, field_name, field_value, arg, context):
+ config_model = self.pool.get('ir.config_parameter')
+ config_model.set_param(
+ cr, uid, field_name, '%s' % (field_value,))
+ return True
+
_columns = {
'module_mrp_repair': fields.boolean("Manage repairs of products ",
help="""Allows to manage all product repairs.
@@ -71,6 +119,15 @@
* Manufacturer Product Code
* Product Attributes.
This installs the module product_manufacturer."""),
+ # using function field for auto_confirm_mo prevents db change for 7.0
+ 'auto_confirm_mo': fields.function(
+ _get_config_parms,
+ fnct_inv=_write_config_parms,
+ type='boolean', method=True, store=False, multi=True,
+ string='Automatically confirm manufacturing orders',
+ help="""When set, will automatically confirm Manufacturing Orders, created for procurements.
+This will set defaults for BOM and Route, that can not be changed."""),
+
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'mrp/res_config_view.xml'
--- mrp/res_config_view.xml 2012-10-23 16:05:04 +0000
+++ mrp/res_config_view.xml 2013-10-03 08:16:35 +0000
@@ -39,6 +39,10 @@
<field name="module_stock_no_autopicking" class="oe_inline"/>
<label for="module_stock_no_autopicking" />
</div>
+ <div>
+ <field name="auto_confirm_mo" class="oe_inline"/>
+ <label for="auto_confirm_mo" />
+ </div>
</div>
</group>
<group >
Follow ups