Merge lp:~unifield-team/unifield-addons/modification-of-stock-for-shipment into lp:unifield-addons

Proposed by Patrick Amstutz
Status: Merged
Merged at revision: 4497
Proposed branch: lp:~unifield-team/unifield-addons/modification-of-stock-for-shipment
Merge into: lp:unifield-addons
Diff against target: 67 lines (+39/-2)
1 file modified
stock/stock.py (+39/-2)
To merge this branch: bzr merge lp:~unifield-team/unifield-addons/modification-of-stock-for-shipment
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+76605@code.launchpad.net

Description of the change

stock loging hooks

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/stock.py'
2--- stock/stock.py 2011-09-21 18:47:20 +0000
3+++ stock/stock.py 2011-09-22 15:49:29 +0000
4@@ -1314,6 +1314,35 @@
5 res[pick.id] = {'delivered_picking': delivered_pack.id or False}
6
7 return res
8+
9+ def _hook_log_picking_view_list(self, cr, uid, ids, context=None, *args, **kwargs):
10+ '''
11+ modify the list of view names
12+ '''
13+ view_list = kwargs['view_list']
14+ return view_list
15+
16+ def _hook_log_picking_view_name(self, cr, uid, ids, context=None, *args, **kwargs):
17+ '''
18+ get the view name
19+ '''
20+ view_list = kwargs['view_list']
21+ pick = kwargs['pick']
22+
23+ view_name = view_list.get(pick.type, 'view_picking_form')
24+ return view_name
25+
26+ def _hook_get_module_name(self, cr, uid, ids, context=None, *args, **kwargs):
27+ '''
28+ specify module name
29+ '''
30+ return 'stock'
31+
32+ def _hook_log_picking_log_cond(self, cr, uid, ids, context=None, *args, **kwargs):
33+ '''
34+ specify if we display a log or not
35+ '''
36+ return True
37
38 def log_picking(self, cr, uid, ids, context=None):
39 """ This function will create log messages for picking.
40@@ -1344,6 +1373,8 @@
41 'in': 'view_picking_in_form',
42 'internal': 'view_picking_form',
43 }
44+ # modify the list of views
45+ view_list = self._hook_log_picking_view_list(cr, uid, ids, context=context, view_list=view_list,)
46 message = type_list.get(pick.type, _('Document')) + " '" + (pick.name or '?') + "' "
47 if pick.min_date:
48 msg= _(' for the ')+ datetime.strptime(pick.min_date, '%Y-%m-%d %H:%M:%S').strftime(date_format)
49@@ -1354,10 +1385,16 @@
50 'done': _('is done.'),
51 'draft':_('is in draft state.'),
52 }
53- res = data_obj.get_object_reference(cr, uid, 'stock', view_list.get(pick.type, 'view_picking_form'))
54+ # select view name
55+ view_name = self._hook_log_picking_view_name(cr, uid, ids, context=context, view_list=view_list, pick=pick,)
56+ # module name
57+ module_name = self._hook_get_module_name(cr, uid, ids, context=context,)
58+ res = data_obj.get_object_reference(cr, uid, module_name, view_name)
59 context.update({'view_id': res and res[1] or False})
60 message += state_list[pick.state]
61- self.log(cr, uid, pick.id, message, context=context)
62+ # conditional test for message log
63+ if self._hook_log_picking_log_cond(cr, uid, ids, context=context, pick=pick,):
64+ self.log(cr, uid, pick.id, message, context=context)
65 return True
66
67 stock_picking()

Subscribers

People subscribed via source and target branches

to all changes: