[FIX] stock_account: let a product without stock change category without valuation access
Killed
209m
open
Commit message
[FIX] stock_account: let a product without stock change category without
valuation access
Changing the category of a product to one with another cost method or
valuation empties and replenishes its valuation layers. Since
61782d7163be ("[PERF] stock_account: prevent MemoryError in
_svl_empty_stock"), `_svl_empty_stock()` reads `stock.valuation.layer`
up front for every impacted product to collect the lots of lot-valuated
ones, even when no product holds any stock. Users allowed to edit
products but not Inventory/Administrator (every other manager group)
therefore got "You are not allowed to access 'Stock Valuation Layer'"
right after creating a product and changing its category.
Return early when no impacted product holds stock, and only collect lots
of lot-valuated products holding stock, the only ones whose lots are
used. A product with stock still creates layers, and that stays refused
for those users, exactly as before.