diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index d1ca9683..04f99fe1 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -508,7 +508,7 @@ class PurchaseOrder(models.Model): result['context'] = {} pick_ids = self.mapped('picking_ids') #choose the view_mode accordingly - if len(pick_ids) > 1: + if not pick_ids or len(pick_ids) > 1: result['domain'] = "[('id','in',%s)]" % (pick_ids.ids) elif len(pick_ids) == 1: res = self.env.ref('stock.view_picking_form', False) diff --git a/addons/purchase/models/stock.py b/addons/purchase/models/stock.py index 33df8d2d..fd884df4 100644 --- a/addons/purchase/models/stock.py +++ b/addons/purchase/models/stock.py @@ -11,17 +11,6 @@ class StockPicking(models.Model): purchase_id = fields.Many2one('purchase.order', related='move_lines.purchase_line_id.order_id', string="Purchase Orders", readonly=True) - @api.model - def _create_backorder(self, backorder_moves=[]): - res = super(StockPicking, self)._create_backorder(backorder_moves) - for picking in self: - if picking.picking_type_id.code == 'incoming': - for backorder in self.search([('backorder_id', '=', picking.id)]): - backorder.message_post_with_view('mail.message_origin_link', - values={'self': backorder, 'origin': backorder.purchase_id}, - subtype_id=self.env.ref('mail.mt_note').id) - return res - class StockMove(models.Model): _inherit = 'stock.move'