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
=== modified file 'stock/stock.py'
--- stock/stock.py 2011-09-21 18:47:20 +0000
+++ stock/stock.py 2011-09-22 15:49:29 +0000
@@ -1314,6 +1314,35 @@
1314 res[pick.id] = {'delivered_picking': delivered_pack.id or False}1314 res[pick.id] = {'delivered_picking': delivered_pack.id or False}
13151315
1316 return res1316 return res
1317
1318 def _hook_log_picking_view_list(self, cr, uid, ids, context=None, *args, **kwargs):
1319 '''
1320 modify the list of view names
1321 '''
1322 view_list = kwargs['view_list']
1323 return view_list
1324
1325 def _hook_log_picking_view_name(self, cr, uid, ids, context=None, *args, **kwargs):
1326 '''
1327 get the view name
1328 '''
1329 view_list = kwargs['view_list']
1330 pick = kwargs['pick']
1331
1332 view_name = view_list.get(pick.type, 'view_picking_form')
1333 return view_name
1334
1335 def _hook_get_module_name(self, cr, uid, ids, context=None, *args, **kwargs):
1336 '''
1337 specify module name
1338 '''
1339 return 'stock'
1340
1341 def _hook_log_picking_log_cond(self, cr, uid, ids, context=None, *args, **kwargs):
1342 '''
1343 specify if we display a log or not
1344 '''
1345 return True
13171346
1318 def log_picking(self, cr, uid, ids, context=None):1347 def log_picking(self, cr, uid, ids, context=None):
1319 """ This function will create log messages for picking.1348 """ This function will create log messages for picking.
@@ -1344,6 +1373,8 @@
1344 'in': 'view_picking_in_form',1373 'in': 'view_picking_in_form',
1345 'internal': 'view_picking_form',1374 'internal': 'view_picking_form',
1346 }1375 }
1376 # modify the list of views
1377 view_list = self._hook_log_picking_view_list(cr, uid, ids, context=context, view_list=view_list,)
1347 message = type_list.get(pick.type, _('Document')) + " '" + (pick.name or '?') + "' "1378 message = type_list.get(pick.type, _('Document')) + " '" + (pick.name or '?') + "' "
1348 if pick.min_date:1379 if pick.min_date:
1349 msg= _(' for the ')+ datetime.strptime(pick.min_date, '%Y-%m-%d %H:%M:%S').strftime(date_format)1380 msg= _(' for the ')+ datetime.strptime(pick.min_date, '%Y-%m-%d %H:%M:%S').strftime(date_format)
@@ -1354,10 +1385,16 @@
1354 'done': _('is done.'),1385 'done': _('is done.'),
1355 'draft':_('is in draft state.'),1386 'draft':_('is in draft state.'),
1356 }1387 }
1357 res = data_obj.get_object_reference(cr, uid, 'stock', view_list.get(pick.type, 'view_picking_form'))1388 # select view name
1389 view_name = self._hook_log_picking_view_name(cr, uid, ids, context=context, view_list=view_list, pick=pick,)
1390 # module name
1391 module_name = self._hook_get_module_name(cr, uid, ids, context=context,)
1392 res = data_obj.get_object_reference(cr, uid, module_name, view_name)
1358 context.update({'view_id': res and res[1] or False})1393 context.update({'view_id': res and res[1] or False})
1359 message += state_list[pick.state]1394 message += state_list[pick.state]
1360 self.log(cr, uid, pick.id, message, context=context)1395 # conditional test for message log
1396 if self._hook_log_picking_log_cond(cr, uid, ids, context=context, pick=pick,):
1397 self.log(cr, uid, pick.id, message, context=context)
1361 return True1398 return True
13621399
1363stock_picking()1400stock_picking()

Subscribers

People subscribed via source and target branches

to all changes: