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):


addons/purchase/models/stock.py
res = super(StockWarehouse, self).create_routes() 
        if self.buy_to_resupply:
            buy_pull_vals = self._get_buy_pull_rule()
            buy_pull = self.env['procurement.rule'].create(buy_pull_vals)
            res['buy_pull_id'] = buy_pull.id
        return res
    @api.multi
    def write(self, vals):
        if 'buy_to_resupply' in vals:
            if vals.get("buy_to_resupply"):
                for warehouse in self:
                    if not warehouse.buy_pull_id:
                        buy_pull_vals = self._get_buy_pull_rule()
                        buy_pull = self.env['procurement.rule'].create(buy_pull_vals)
                        vals['buy_pull_id'] = buy_pull.id
            else:
                for warehouse in self:
                    if warehouse.buy_pull_id:
                        warehouse.buy_pull_id.unlink()
        return super(StockWarehouse, self).write(vals)
    @api.multi
    def _get_all_routes(self):
        routes = super(StockWarehouse, self).get_all_routes_for_wh()
        routes |= self.filtered(lambda self: self.buy_to_resupply and self.buy_pull_id and self.buy_pull_id.route_id).mapped('buy_pull_id').mapped('route_id')
        return routes
    @api.multi
    def _update_name_and_code(self, name=False, code=False):