Ravi Gadhia (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-social-shipment-rga into 
lp:~openerp-dev/openobject-addons/trunk-social-tde.

Requested reviews:
  Thibault Delavallée (OpenERP) (tde-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-social-shipment-rga/+merge/97345

Added social chatter notification messages for incoming shipments
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-social-shipment-rga/+merge/97345
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-social-tde.
=== modified file 'stock/stock.py'
--- stock/stock.py	2012-02-28 14:08:16 +0000
+++ stock/stock.py	2012-03-14 05:51:18 +0000
@@ -536,6 +536,7 @@
 #----------------------------------------------------------
 class stock_picking(osv.osv):
     _name = "stock.picking"
+    _inherit = 'mail.thread'
     _description = "Picking List"
 
     def _set_maximum_date(self, cr, uid, ids, name, value, arg, context=None):
@@ -610,6 +611,8 @@
             seq_obj_name =  'stock.picking.' + vals['type']
             vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name)
         new_id = super(stock_picking, self).create(cr, user, vals, context)
+        if new_id:
+            self.create_notificate(cr, user, [new_id], context=context)
         return new_id
 
     _columns = {
@@ -723,7 +726,6 @@
                 if r.state == 'draft':
                     todo.append(r.id)
 
-        self.log_picking(cr, uid, ids, context=context)
 
         todo = self.action_explode(cr, uid, todo, context)
         if len(todo):
@@ -789,6 +791,7 @@
             move_ids = [x.id for x in pick.move_lines]
             self.pool.get('stock.move').cancel_assign(cr, uid, move_ids)
             wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
+            print 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'
         return True
 
     def action_assign_wkf(self, cr, uid, ids, context=None):
@@ -796,7 +799,6 @@
         @return: True
         """
         self.write(cr, uid, ids, {'state': 'assigned'})
-        self.log_picking(cr, uid, ids, context=context)
         return True
 
     def test_finished(self, cr, uid, ids):
@@ -837,7 +839,7 @@
             ids2 = [move.id for move in pick.move_lines]
             self.pool.get('stock.move').action_cancel(cr, uid, ids2, context)
         self.write(cr, uid, ids, {'state': 'cancel', 'invoice_state': 'none'})
-        self.log_picking(cr, uid, ids, context=context)
+        self.ship_cancel_notificate(cr, uid, ids, context)
         return True
 
     #
@@ -1310,14 +1312,17 @@
                 wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_done', cr)
                 wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
                 delivered_pack_id = new_picking
+                back_order_name = self.browse(cr, uid, delivered_pack_id, context=context).name
+                self.back_order_notificate(cr, uid, ids, back_order_name, context)
             else:
                 self.action_move(cr, uid, [pick.id])
                 wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr)
                 delivered_pack_id = pick.id
+                self.ship_done_notificate(cr, uid, ids, context)
 
             delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context)
             res[pick.id] = {'delivered_picking': delivered_pack.id or False}
-
+            
         return res
 
     def log_picking(self, cr, uid, ids, context=None):
@@ -1358,8 +1363,38 @@
             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})
             message += state_list[pick.state]
-            self.log(cr, uid, pick.id, message, context=context)
         return True
+    
+    
+    # -----------------------------
+    # OpenChatter and notifications
+    # -----------------------------
+    def create_notificate(self, cr, uid, ids, context=None):
+        self.message_append_note(cr, uid, ids, _('System notification'),
+                    _("""Shipment <b>created</b>."""),
+                      type='notification', context=context)
+    
+    def scrap_notificate(self, cr, uid, ids, quantity, name, context=None):
+        self.message_append_note(cr, uid, ids, _('System notification'),
+                    _("""%s  %s <b>moved to</b> scrap.""")
+                    % (quantity, name), type='notification', context=context)
+    
+    def back_order_notificate(self, cr, uid, ids, back_name, context=None):
+        self.message_append_note(cr, uid, ids, _('System notification'),
+                    _("""Back order <em>%s</em> <b>created</b>.""")
+                    % (back_name), type='notification', context=context)
+    
+    
+    def ship_done_notificate(self, cr, uid, ids, context=None):
+        self.message_append_note(cr, uid, ids, _('System notification'),
+                    _("""Product <b>received</b>.""")
+                     ,type='notification', context=context)
+    
+    def ship_cancel_notificate(self, cr, uid, ids, context=None):
+        self.message_append_note(cr, uid, ids, _('System notification'),
+                    _("""Shipment <b>cancelled</b>.""")
+                     ,type='notification', context=context)
+        
 
 stock_picking()
 
@@ -2361,7 +2396,7 @@
             res += [new_move]
             product_obj = self.pool.get('product.product')
             for (id, name) in product_obj.name_get(cr, uid, [move.product_id.id]):
-                self.log(cr, uid, move.id, "%s x %s %s" % (quantity, name, _("were scrapped")))
+                move.picking_id.scrap_notificate(quantity, name)
 
         self.action_done(cr, uid, res, context=context)
         return res
@@ -2483,11 +2518,6 @@
                 }
                 self.write(cr, uid, [move.id], update_val)
 
-            product_obj = self.pool.get('product.product')
-            for new_move in self.browse(cr, uid, res, context=context):
-                for (id, name) in product_obj.name_get(cr, uid, [new_move.product_id.id]):
-                    message = _("Product  '%s' is consumed with '%s' quantity.") %(name, new_move.product_qty)
-                    self.log(cr, uid, new_move.id, message)
         self.action_done(cr, uid, res, context=context)
 
         return res
@@ -2697,8 +2727,6 @@
                             'location_dest_id': location_id,
                         })
                     move_ids.append(self._inventory_line_hook(cr, uid, line, value))
-            message = _("Inventory '%s' is done.") %(inv.name)
-            self.log(cr, uid, inv.id, message)
             self.write(cr, uid, [inv.id], {'state': 'confirm', 'move_ids': [(6, 0, move_ids)]})
             self.pool.get('stock.move').action_confirm(cr, uid, move_ids, context=context)
         return True

=== modified file 'stock/stock_view.xml'
--- stock/stock_view.xml	2012-02-13 15:27:55 +0000
+++ stock/stock_view.xml	2012-03-14 05:51:18 +0000
@@ -1227,6 +1227,7 @@
                             <field colspan="4" name="note" nolabel="1"/>
                         </page>
                     </notebook>
+                    <field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
                 </form>
             </field>
         </record>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to