openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #03429
[Merge] lp:~yann-papouin/ocb-addons/6.1-bug-1275722-mrp-default-locations into lp:ocb-addons/6.1
Yann Papouin has proposed merging lp:~yann-papouin/ocb-addons/6.1-bug-1275722-mrp-default-locations into lp:ocb-addons/6.1.
Requested reviews:
OpenERP Community Backports Team (ocb)
Related bugs:
Bug #1275722 in OpenERP Community Backports (Addons): "[6.1][mrp] Locations of a production order should be set from stock properties"
https://bugs.launchpad.net/ocb-addons/+bug/1275722
For more details, see:
https://code.launchpad.net/~yann-papouin/ocb-addons/6.1-bug-1275722-mrp-default-locations/+merge/204483
Backport from 7.0
--
https://code.launchpad.net/~yann-papouin/ocb-addons/6.1-bug-1275722-mrp-default-locations/+merge/204483
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~yann-papouin/ocb-addons/6.1-bug-1275722-mrp-default-locations into lp:ocb-addons/6.1.
=== modified file 'mrp/mrp.py'
--- mrp/mrp.py 2012-10-05 10:44:47 +0000
+++ mrp/mrp.py 2014-02-03 13:16:04 +0000
@@ -20,7 +20,7 @@
##############################################################################
from datetime import datetime
-from osv import osv, fields
+from osv import osv, fields, orm
import decimal_precision as dp
from tools import float_compare
from tools.translate import _
@@ -434,6 +434,22 @@
for prod in self.browse(cr, uid, ids, context=context):
result[prod.id] = prod.date_planned[:10]
return result
+
+ def _src_id_default(self, cr, uid, ids, context=None):
+ try:
+ location_model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock')
+ self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
+ except (orm.except_orm, ValueError):
+ location_id = False
+ return location_id
+
+ def _dest_id_default(self, cr, uid, ids, context=None):
+ try:
+ location_model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock')
+ self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
+ except (orm.except_orm, ValueError):
+ location_id = False
+ return location_id
_columns = {
'name': fields.char('Reference', size=64, required=True),
@@ -481,6 +497,8 @@
'state': lambda *a: 'draft',
'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'product_qty': lambda *a: 1.0,
+ 'location_src_id': _src_id_default,
+ 'location_dest_id': _dest_id_default,
'name': lambda x, y, z, c: x.pool.get('ir.sequence').get(y, z, 'mrp.production') or '/',
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.production', context=c),
}
Follow ups