Merge lp:~yann-papouin/ocb-addons/6.1-bug-1275722-mrp-default-locations into lp:ocb-addons/6.1

Proposed by Yann Papouin
Status: Merged
Merged at revision: 6836
Proposed branch: lp:~yann-papouin/ocb-addons/6.1-bug-1275722-mrp-default-locations
Merge into: lp:ocb-addons/6.1
Diff against target: 44 lines (+19/-1)
1 file modified
mrp/mrp.py (+19/-1)
To merge this branch: bzr merge lp:~yann-papouin/ocb-addons/6.1-bug-1275722-mrp-default-locations
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Pedro Manuel Baeza Approve
Review via email: mp+204483@code.launchpad.net

Description of the change

Backport from 7.0

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

LGTM. I already noted that this has been fixed on v7, but not on v6.1.

Regards.

review: Approve
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

verified that's a backport of the relevant code from 7.0

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
20##############################################################################20##############################################################################
2121
22from datetime import datetime22from datetime import datetime
23from osv import osv, fields23from osv import osv, fields, orm
24import decimal_precision as dp24import decimal_precision as dp
25from tools import float_compare25from tools import float_compare
26from tools.translate import _26from tools.translate import _
@@ -434,6 +434,22 @@
434 for prod in self.browse(cr, uid, ids, context=context):434 for prod in self.browse(cr, uid, ids, context=context):
435 result[prod.id] = prod.date_planned[:10]435 result[prod.id] = prod.date_planned[:10]
436 return result436 return result
437
438 def _src_id_default(self, cr, uid, ids, context=None):
439 try:
440 location_model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock')
441 self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
442 except (orm.except_orm, ValueError):
443 location_id = False
444 return location_id
445
446 def _dest_id_default(self, cr, uid, ids, context=None):
447 try:
448 location_model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock')
449 self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
450 except (orm.except_orm, ValueError):
451 location_id = False
452 return location_id
437453
438 _columns = {454 _columns = {
439 'name': fields.char('Reference', size=64, required=True),455 'name': fields.char('Reference', size=64, required=True),
@@ -481,6 +497,8 @@
481 'state': lambda *a: 'draft',497 'state': lambda *a: 'draft',
482 'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),498 'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
483 'product_qty': lambda *a: 1.0,499 'product_qty': lambda *a: 1.0,
500 'location_src_id': _src_id_default,
501 'location_dest_id': _dest_id_default,
484 'name': lambda x, y, z, c: x.pool.get('ir.sequence').get(y, z, 'mrp.production') or '/',502 'name': lambda x, y, z, c: x.pool.get('ir.sequence').get(y, z, 'mrp.production') or '/',
485 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.production', context=c),503 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.production', context=c),
486 }504 }

Subscribers

People subscribed via source and target branches