[FIX] stock: add origin to the chatter when creating a picking from a sale order
Before v11, the picking origin was added to the chatter, which is a useful feature. We add it back. opw 1874379
This commit is contained in:
@@ -43,6 +43,14 @@ class StockMove(models.Model):
|
||||
line.qty_delivered = line._get_delivered_qty()
|
||||
return res
|
||||
|
||||
def _assign_picking_post_process(self, new=False):
|
||||
super(StockMove, self)._assign_picking_post_process(new=new)
|
||||
if new and self.sale_line_id and self.sale_line_id.order_id:
|
||||
self.picking_id.message_post_with_view(
|
||||
'mail.message_origin_link',
|
||||
values={'self': self.picking_id, 'origin': self.sale_line_id.order_id},
|
||||
subtype_id=self.env.ref('mail.mt_note').id)
|
||||
|
||||
|
||||
class ProcurementGroup(models.Model):
|
||||
_inherit = 'procurement.group'
|
||||
|
||||
@@ -704,7 +704,7 @@ class StockMove(models.Model):
|
||||
recompute = True
|
||||
picking = Picking.create(move._get_new_picking_values())
|
||||
move.write({'picking_id': picking.id})
|
||||
|
||||
move._assign_picking_post_process(new=recompute)
|
||||
# If this method is called in batch by a write on a one2many and
|
||||
# at some point had to create a picking, some next iterations could
|
||||
# try to find back the created picking. As we look for it by searching
|
||||
@@ -714,6 +714,9 @@ class StockMove(models.Model):
|
||||
move.recompute()
|
||||
return True
|
||||
|
||||
def _assign_picking_post_process(self, new=False):
|
||||
pass
|
||||
|
||||
def _get_new_picking_values(self):
|
||||
""" Prepares a new picking for this move as it could not be assigned to
|
||||
another picking. This method is designed to be inherited. """
|
||||
|
||||
Reference in New Issue
Block a user