res[pick.id] = {'delivered_picking': delivered_pack.id or False}
return res
+
+ # views associated to each picking type
+ _VIEW_LIST = {
+ 'out': 'view_picking_out_form',
+ 'in': 'view_picking_in_form',
+ 'internal': 'view_picking_form',
+ }
+ def _get_view_id(self, cr, uid, type):
+ """Get the view id suiting the given type
+
+ @param type: the picking type as a string
+ @return: view i, or False if no view found
+ """
+ res = self.pool.get('ir.model.data').get_object_reference(cr, uid,
+ 'stock', self._VIEW_LIST.get(type, 'view_picking_form'))
+ return res and res[1] or False
def log_picking(self, cr, uid, ids, context=None):
""" This function will create log messages for picking.
"""
if context is None:
context = {}
- data_obj = self.pool.get('ir.model.data')
for pick in self.browse(cr, uid, ids, context=context):
msg=''
if pick.auto_picking:
'in':_('Reception'),
'internal': _('Internal picking'),
}
- view_list = {
- 'out': 'view_picking_out_form',
- 'in': 'view_picking_in_form',
- 'internal': 'view_picking_form',
- }
message = type_list.get(pick.type, _('Document')) + " '" + (pick.name or '?') + "' "
if pick.min_date:
msg= _(' for the ')+ datetime.strptime(pick.min_date, '%Y-%m-%d %H:%M:%S').strftime('%m/%d/%Y')
'auto': _('is waiting.'),
'draft': _('is in draft state.'),
}
- res = data_obj.get_object_reference(cr, uid, 'stock', view_list.get(pick.type, 'view_picking_form'))
- context.update({'view_id': res and res[1] or False})
+ context['view_id'] = self._get_view_id(cr, uid, pick.type)
message += state_list[pick.state]
self.log(cr, uid, pick.id, message, context=context)
return True