From 9f1534ee8cbc92897b46cf75dc81bfa66037c423 Mon Sep 17 00:00:00 2001 From: len-odoo Date: Fri, 17 Aug 2018 10:52:12 +0200 Subject: [PATCH] [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 --- addons/sale_stock/models/stock.py | 8 ++++++++ addons/stock/models/stock_move.py | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/addons/sale_stock/models/stock.py b/addons/sale_stock/models/stock.py index b13e71d6c6f..0253ea70381 100644 --- a/addons/sale_stock/models/stock.py +++ b/addons/sale_stock/models/stock.py @@ -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' diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 7b5ee057159..0dac3ad176d 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -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. """