Seems really odd that the maintainer would say that this was impossible and a fringe case.
Seems to me like this is a very normal use case, in fact one that we use on every single Ubercart site we have in production. I actually thought this was a setting in the module config page and was surprised to see that it wasn't.
Anyway, here's what I did. I disabled the included rule because I despise rules and added this code to my module:
/**
* Implements hook_commerce_checkout_complete().
*/
function MYMODULE_commerce_checkout_complete($order) {
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$line_items = $order_wrapper->commerce_line_items->value();
if (is_array($line_items)) {
foreach ($line_items as $line_item) {
if (in_array($line_item->type, commerce_product_line_item_types())) {
$product = commerce_product_load_by_sku($line_item->line_item_label);
// Subtract the sold amount from the available stock level.
$qty = (int) $line_item->quantity;
module_load_include('inc', 'commerce_stock', 'commerce_stock.rules');
commerce_stock_adjust($product, -$qty);
// Disable the product if we have no stock left
$product_wrapper = entity_metadata_wrapper('commerce_product', $product);
if ($product_wrapper->commerce_stock->value() <= 0) {
$product_wrapper->status->set(0);
$result = $product_wrapper->save();
if ($result) {
watchdog('commerce_stock', 'Product %sku stock level reached 0, status set to 0.', array('%sku' => $product->sku));
}
else {
watchdog('commerce_stock', 'Failed attempt to disable product %sku', array('%sku' => $product->sku), WATCHDOG_ERROR);
}
}
}
}
}
}
It's just a copy of the default rule that ships with the module with the extra code for disabling the product added in.
I guess you could leave the default rule active and remove the 3 lines that adjust the stock level in my example, but then I'm not sure what would be called first, the rule or my hook so you would have to test that yourself.