Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] stock_account: handle neg. quant valuation #165179

Open
wants to merge 1 commit into
base: 15.0
Choose a base branch
from

Conversation

ethanrobv
Copy link
Contributor

Current behavior:
Switching from manual to automated valuation on a product that has a negative quantity will create entries in the valuation journal with incorrect debit/credit figures.

Expected behavior:
The lines generated in this manner should look like ones created when the valuation is generated for a product that was already valuated with the automated option.

Steps to reproduce:

  1. Create a product category with the default manual valuation method, create a storable product that belongs to it

  2. Sell some quantity of the new product without adding any on-hand quantity (so that the qty is negative), confirm the order and generate the invoice

  3. Swap to automated valuation in the product category that was created in step 1

  4. In the entries for the stock valuation journal, observe that:
    A) the stock valuation account is getting debited instead of credited, and

    B) the other entry generated is for the stock input account
    instead of stock output, and

    C) the debit/credit amounts should be swapped here as well

Cause of the issue:
The negative quantity case is not considered when we do the empty/replenish sequence on valuation method change.

Fix:
Add an explicit check for negative quantity in the replenish step of changing valuation method.

opw-3810779

@robodoo
Copy link
Contributor

robodoo commented May 13, 2024

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label May 13, 2024
Copy link
Contributor

@adwid adwid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the fix
Just few changes required in the test

addons/stock_account/models/product.py Outdated Show resolved Hide resolved
addons/stock_account/tests/test_account_move.py Outdated Show resolved Hide resolved
addons/stock_account/tests/test_account_move.py Outdated Show resolved Hide resolved
addons/stock_account/tests/test_account_move.py Outdated Show resolved Hide resolved
addons/stock_account/tests/test_account_move.py Outdated Show resolved Hide resolved
**Current behavior:**
Switching from manual to automated valuation on a product that
has a negative quantity will create entries in the valuation
journal with incorrect debit/credit figures.

**Expected behavior:**
The lines generated in this manner should look like ones created
when the valuation is generated for a product that was already
valuated with the automated option.

**Steps to reproduce:**
1. Create a product category with the default manual valuation
     method, create a storable product that belongs to it

2. Sell some quantity of the new product without adding any
     on-hand quantity (so that the qty is negative), confirm the
     order and generate the invoice

3. Swap to automated valuation in the product category that was
     created in step 1

4. In the entries for the stock valuation journal, observe that:
     A) the stock valuation account is getting *debited* instead
          of credited, and

     B) the other entry generated is for the stock input account
          instead of stock output, and

     C) the debit/credit amounts should be swapped here as well

**Cause of the issue:**
The negative quantity case is not considered when we do the
empty/replenish sequence on valuation method change.

**Fix:**
Add an explicit check for negative quantity in the replenish
step of changing valuation method.

opw-3810779
@ethanrobv ethanrobv force-pushed the 15.0-opw-3810779-valuation-method-change-negative-on-hand-qty-etvi branch from 9cb5383 to 8314cea Compare May 16, 2024 08:31
@ethanrobv ethanrobv marked this pull request as ready for review May 16, 2024 08:33
@C3POdoo C3POdoo requested a review from a team May 16, 2024 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants