'First find a rule among the ones defined on the procurement order
group; then try on the routes defined for the product; finally fallback
on the default behavior'

def _search_suitable_rule(self, domain):

    if self.warehouse_id:
        domain = expression.AND([['|', ('warehouse_id', '=', self.warehouse_id.id), ('warehouse_id', '=', False)], domain])
    Pull = self.env['procurement.rule']
    res = self.env['procurement.rule']
    if self.route_ids:
        res = Pull.search(expression.AND([[('route_id', 'in', self.route_ids.ids)], domain]), order='route_sequence,    sequence', limit=1)
    if (not res):
        product_routes = (self.product_id.route_ids | self.product_id.categ_id.total_route_ids)
        if product_routes:
            res = Pull.search(expression.AND([[('route_id', 'in', product_routes.ids)], domain]), order='route_sequence,    sequence', limit=1)
    if (not res):
        warehouse_routes = self.warehouse_id.route_ids
        if warehouse_routes:
            res = Pull.search(expression.AND([[('route_id', 'in', warehouse_routes.ids)], domain]), order='route_sequence,    sequence', limit=1)
    if (not res):
        res = Pull.search(expression.AND([[('route_id', '=', False)], domain]), order='sequence', limit=1)
    return res
