From 26b97bcd0223fd26c407c9af5a4532a8f2ab56a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 20 Mar 2012 16:13:50 +0100 Subject: [PATCH] [FIX] stock: fixed error in some notifications: browsing on obj but sending notofications to all records (ids). Added protection for dict accesses. bzr revid: tde@openerp.com-20120320151350-rs309a5pdpbfvqz0 --- addons/stock/stock.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 62fe91cf718..9e0aece81b9 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1364,21 +1364,21 @@ class stock_picking(osv.osv): message += state_list[pick.state] return True + # ----------------------------------------- + # OpenChatter notifications and need_action + # ----------------------------------------- - # ----------------------------- - # OpenChatter and notifications - # ----------------------------- def _get_document_type(self, type): type_dict = { 'out': 'Delivery order', 'in': 'Shipment', 'internal': 'Internal picking', } - return type_dict[type] + return type_dict.get(type, 'Stock picking') def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, ids, _('System notification'), + self.message_append_note(cr, uid, [obj.id], _('System notification'), _("""%s created.""") % (self._get_document_type(obj.type)), type='notification', context=context) @@ -1399,13 +1399,13 @@ class stock_picking(osv.osv): 'internal': 'moved', } for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, ids, _('System notification'), - _("""Product %s.""") % (type_dict[obj.type]), + self.message_append_note(cr, uid, [obj.id], _('System notification'), + _("""Product %s.""") % (type_dict.get(obj.type, 'move done')), type='notification', context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, ids, _('System notification'), + self.message_append_note(cr, uid, [obj.id], _('System notification'), _("""%s cancelled.""") % (self._get_document_type(obj.type)), type='notification', context=context)