Name: [FIX] stock_account: let a product without stock change category without valuation access

State: Killed finished in 209m

PR State: open

PR Author: Roy Le

PR Author Email:

PR: #1289

Committer: Roy Le

Committer Email: roy.le@viindoo.com

Commit: b1a5ec123b0a13347f66794a0e79766afab44774

Description:

                                            [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.
                                            

Branch: 18.0

Age:

Up-time: