Impacted versions: 11.0

Steps to reproduce: Inventory --> Reordering Rules --> Purchases

Current behavior: If you create new PO from Reordering Rules It is not linked to that Rule

![](https://image.prntscr.com/image/tOxQoQu6RO6gf2iE-KvEFQ.png)

Expected behavior: It should be linked to Particular Rule or Creation of Po should not be allowed from there.

Video/Screenshot link (optional):


vals = super(StockMove, self)._prepare_extra_move_vals(qty)
        vals['purchase_line_id'] = self.purchase_line_id.id
        return vals
    def _prepare_move_split_vals(self, uom_qty):
        vals = super(StockMove, self)._prepare_move_split_vals(uom_qty)
        vals['purchase_line_id'] = self.purchase_line_id.id
        return vals
    def _action_cancel(self):
        for move in self:
            if move.created_purchase_line_id:
                try:
                    activity_type_id = self.env.ref('mail.mail_activity_data_todo').id
                except ValueError:
                    activity_type_id = False
                self.env['mail.activity'].create({
                    'activity_type_id': activity_type_id,
                    'note': _('A sale order that generated this purchase order has been deleted. Check if an action is needed.'),
                    'user_id': move.created_purchase_line_id.product_id.responsible_id.id,
                    'res_id': move.created_purchase_line_id.order_id.id,
                    'res_model_id': self.env.ref('purchase.model_purchase_order').id,
                })
        return super(StockMove, self)._action_cancel()
class StockWarehouse(models.Model):
    _inherit = 'stock.warehouse'
    buy_to_resupply = fields.Boolean('Purchase to resupply this warehouse', default=True,
                                     help="When products are bought, they can be delivered to this warehouse")
    buy_pull_id = fields.Many2one('procurement.rule', 'Buy rule')
    @api.multi
    def _get_buy_pull_rule(self):