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
1=== modified file 'mrp/mrp.py'
2--- mrp/mrp.py 2012-10-05 10:44:47 +0000
3+++ mrp/mrp.py 2014-02-03 13:16:04 +0000
4@@ -20,7 +20,7 @@
5 ##############################################################################
6
7 from datetime import datetime
8-from osv import osv, fields
9+from osv import osv, fields, orm
10 import decimal_precision as dp
11 from tools import float_compare
12 from tools.translate import _
13@@ -434,6 +434,22 @@
14 for prod in self.browse(cr, uid, ids, context=context):
15 result[prod.id] = prod.date_planned[:10]
16 return result
17+
18+ def _src_id_default(self, cr, uid, ids, context=None):
19+ try:
20+ location_model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock')
21+ self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
22+ except (orm.except_orm, ValueError):
23+ location_id = False
24+ return location_id
25+
26+ def _dest_id_default(self, cr, uid, ids, context=None):
27+ try:
28+ location_model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock')
29+ self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
30+ except (orm.except_orm, ValueError):
31+ location_id = False
32+ return location_id
33
34 _columns = {
35 'name': fields.char('Reference', size=64, required=True),
36@@ -481,6 +497,8 @@
37 'state': lambda *a: 'draft',
38 'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
39 'product_qty': lambda *a: 1.0,
40+ 'location_src_id': _src_id_default,
41+ 'location_dest_id': _dest_id_default,
42 'name': lambda x, y, z, c: x.pool.get('ir.sequence').get(y, z, 'mrp.production') or '/',
43 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.production', context=c),
44 }

Subscribers

People subscribed via source and target branches