FIX Wrong stock valuation when MultiCompany PMP per entity is enabled - #39738
Open
hregis wants to merge 1 commit into
Open
FIX Wrong stock valuation when MultiCompany PMP per entity is enabled#39738hregis wants to merge 1 commit into
hregis wants to merge 1 commit into
Conversation
Rows in llx_product_perentity are only created on the first stock movement of a product in an entity, so a product with no row yet is the norm on an existing database, not an edge case. Product::fetch() already handles this by falling back on the global llx_product.pmp, but three other places did not, each in a different way: - Entrepot::nb_products(): inner join, so such a product was excluded from both the product count and the warehouse value. - product/stock/card.php: inner join, so such a product did not appear at all in the warehouse content list. - product/stock/list.php: left join but no fallback, so pa.pmp was NULL and the product was valued at 0. Align all three on the behaviour of Product::fetch(): left join plus an explicit COALESCE(pa.pmp, p.pmp) fallback. Behaviour is unchanged when the llx_product_perentity row exists. Also fix product/stock/card.php where the "estimated value" column mixed both sources: ppmp (displayed) used pa.pmp while svalue (its sort key) used p.pmp, so the column did not sort on the value it showed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rows in llx_product_perentity are only created on the first stock movement of a product in an entity, so a product with no row yet is the norm on an existing database, not an edge case. Product::fetch() already handles this by falling back on the global llx_product.pmp, but three other places did not, each in a different way:
Align all three on the behaviour of Product::fetch(): left join plus an explicit COALESCE(pa.pmp, p.pmp) fallback. Behaviour is unchanged when the llx_product_perentity row exists.
Also fix product/stock/card.php where the "estimated value" column mixed both sources: ppmp (displayed) used pa.pmp while svalue (its sort key) used p.pmp, so the column did not sort on the value it showed.