-
Notifications
You must be signed in to change notification settings - Fork 30.2k
[FW][FIX] stock_landed_costs: avoid uom user error from valid landed cost lines #191951
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
Closed
fw-bot
wants to merge
1
commit into
odoo:saas-18.1
from
odoo-dev:saas-18.1-16.0-opw-4389366-uom_landed_cost_issue-lase-uuv8-fw
Closed
[FW][FIX] stock_landed_costs: avoid uom user error from valid landed cost lines #191951
fw-bot
wants to merge
1
commit into
odoo:saas-18.1
from
odoo-dev:saas-18.1-16.0-opw-4389366-uom_landed_cost_issue-lase-uuv8-fw
Conversation
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
… lines ***Issue 1*** Trying to validate a receipt related to a landed cost account line for a product using a uom from a different uom category will raise a userError that do not allow you to validate the receipt. Steps to reproduce: - Create a product: - real time property valuation - average cost method - on ordered quantities control policy - UOM from an other category han "Unit" e.g. kg - Create and confirm a PO for 100 k units at 1.35 each - Create an invoice for 23 k, receive 23k units and backorder - Create a landed cost on the invoice for 23k units in the company currency units - Post the invoice - Create a second invoice for 27k units and post it - Try to validate the receipt of the 27k units more units > UserError: The unit of measure Units defined on the order line doesn't > belong to the same category as the unit of measure kg defined on the > product. Cause of the issue: Since Commit 32543ce The landed_cost account lines related to a given stock move are also considered in the `_get_price_unit` call of stock moves: https://github.com/odoo/odoo/blob/1b999e4b358eabe80cb3d636cd7bc348c5b85a1b/addons/purchase_stock/models/stock_move.py#L60 https://github.com/odoo/odoo/blob/1b999e4b358eabe80cb3d636cd7bc348c5b85a1b/addons/stock_landed_costs/models/purchase.py#L11-L16 However, the uom related to the landed cost account line might not match the uom category of the product related to the move. As such, this line will raise a UserError: https://github.com/odoo/odoo/blob/da1f44c2296486c0267a7bdbbe3a314ada3aa679/addons/purchase_stock/models/stock_move.py#L70 https://github.com/odoo/odoo/blob/da1f44c2296486c0267a7bdbbe3a314ada3aa679/addons/uom/models/uom_uom.py#L223-L227 ***Issue 2*** Steps to reproduce - Create a product invoiced on ordered quantities - Create a PO and a bill for it, post the bill - Receipt half the quantity - Add a landed cost product on the PO, create a second bill for this landed cost product. Create and validate the landed cost. - Receipt the second half quantity. Issue: The valuation of the second transfer is too low Cause of the Issue 2: To get the price unit for "on ordered qty" policy, We compute the ratio of already receipt value on already invoiced value: https://github.com/odoo/odoo/blob/4f6353ec8a7306fbf63e95e8e02248d72f413aa3/addons/purchase_stock/models/stock_move.py#L84 The issue is that the receipt value is increase by the landed costs value because the receipt valuation layer is linked to the landed cost valuation layer. But the product invoice line is not linked to the landed costs invoice line. Resulting in a invoice value under valuated. This commit will ingnore the receipt values coming from landed costs so that the landed costs value will be added to the total invoiced value and not removed from the value here: https://github.com/odoo/odoo/blob/cfb7a3593c5a4b313bdfd8628fe1b0dfe7e73823/addons/purchase_stock/models/stock_move.py#L72 *if* the landed cost has it's own invoice line. Revert Commit 32543ce Authored-by: Whenrow <whe@odoo.com> Issue 1: opw-4389366 Issue 2: opw-4354498 X-original-commit: af8a314
|
This PR targets saas-18.1 and is part of the forward-port chain. Further PRs will be created up to master. More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
|
robodoo r+ |
|
@lase-odoo @adwid child PR #191952 was modified / updated and has become a normal PR. This PR (and any of its parents) will need to be merged independently as approvals won't cross. |
robodoo
pushed a commit
that referenced
this pull request
Dec 30, 2024
… lines ***Issue 1*** Trying to validate a receipt related to a landed cost account line for a product using a uom from a different uom category will raise a userError that do not allow you to validate the receipt. Steps to reproduce: - Create a product: - real time property valuation - average cost method - on ordered quantities control policy - UOM from an other category han "Unit" e.g. kg - Create and confirm a PO for 100 k units at 1.35 each - Create an invoice for 23 k, receive 23k units and backorder - Create a landed cost on the invoice for 23k units in the company currency units - Post the invoice - Create a second invoice for 27k units and post it - Try to validate the receipt of the 27k units more units > UserError: The unit of measure Units defined on the order line doesn't > belong to the same category as the unit of measure kg defined on the > product. Cause of the issue: Since Commit 32543ce The landed_cost account lines related to a given stock move are also considered in the `_get_price_unit` call of stock moves: https://github.com/odoo/odoo/blob/1b999e4b358eabe80cb3d636cd7bc348c5b85a1b/addons/purchase_stock/models/stock_move.py#L60 https://github.com/odoo/odoo/blob/1b999e4b358eabe80cb3d636cd7bc348c5b85a1b/addons/stock_landed_costs/models/purchase.py#L11-L16 However, the uom related to the landed cost account line might not match the uom category of the product related to the move. As such, this line will raise a UserError: https://github.com/odoo/odoo/blob/da1f44c2296486c0267a7bdbbe3a314ada3aa679/addons/purchase_stock/models/stock_move.py#L70 https://github.com/odoo/odoo/blob/da1f44c2296486c0267a7bdbbe3a314ada3aa679/addons/uom/models/uom_uom.py#L223-L227 ***Issue 2*** Steps to reproduce - Create a product invoiced on ordered quantities - Create a PO and a bill for it, post the bill - Receipt half the quantity - Add a landed cost product on the PO, create a second bill for this landed cost product. Create and validate the landed cost. - Receipt the second half quantity. Issue: The valuation of the second transfer is too low Cause of the Issue 2: To get the price unit for "on ordered qty" policy, We compute the ratio of already receipt value on already invoiced value: https://github.com/odoo/odoo/blob/4f6353ec8a7306fbf63e95e8e02248d72f413aa3/addons/purchase_stock/models/stock_move.py#L84 The issue is that the receipt value is increase by the landed costs value because the receipt valuation layer is linked to the landed cost valuation layer. But the product invoice line is not linked to the landed costs invoice line. Resulting in a invoice value under valuated. This commit will ingnore the receipt values coming from landed costs so that the landed costs value will be added to the total invoiced value and not removed from the value here: https://github.com/odoo/odoo/blob/cfb7a3593c5a4b313bdfd8628fe1b0dfe7e73823/addons/purchase_stock/models/stock_move.py#L72 *if* the landed cost has it's own invoice line. Revert Commit 32543ce Authored-by: Whenrow <whe@odoo.com> Issue 1: opw-4389366 Issue 2: opw-4354498 closes #191951 X-original-commit: af8a314 Signed-off-by: Adrien Widart (awt) <awt@odoo.com> Signed-off-by: Lancelot Semal (lase) <lase@odoo.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.

Issue 1
Trying to validate a receipt related to a landed cost account line for
a product using a uom from a different uom category will raise a
userError that do not allow you to validate the receipt.
Steps to reproduce:
Cause of the issue:
Since Commit 32543ce The landed_cost account lines related to a given stock move are also considered in the
_get_price_unitcall of stock moves:odoo/addons/purchase_stock/models/stock_move.py
Line 60 in 1b999e4
odoo/addons/stock_landed_costs/models/purchase.py
Lines 11 to 16 in 1b999e4
However, the uom related to the landed cost account line might not match the uom category of the product related to the move. As such, this line will raise a UserError:
odoo/addons/purchase_stock/models/stock_move.py
Line 70 in da1f44c
odoo/addons/uom/models/uom_uom.py
Lines 223 to 227 in da1f44c
Issue 2
Steps to reproduce
Issue:
The valuation of the second transfer is too low
Cause of the Issue 2:
To get the price unit for "on ordered qty" policy, We compute the ratio of already receipt value on already invoiced value:
odoo/addons/purchase_stock/models/stock_move.py
Line 84 in 4f6353e
The issue is the receipt value is increase by the landed costs value because the receipt valuation layer is linked to the landed cost valuation layer. But the product invoice line is not linked to the landed costs invoice line. Resulting in a invoice value under valuated.
This commit will ingnore the receipt values coming from landed costs so that the landed costs value will be added to the total invoiced value and not removed from the value here:
odoo/addons/purchase_stock/models/stock_move.py
Line 72 in cfb7a35
if the landed cost has it's own invoice line.
Revert Commit 32543ce
Authored-by: Whenrow whe@odoo.com
Issue 1: opw-4389366
Issue 2: opw-4354498
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Forward-Port-Of: #191943
Forward-Port-Of: #191225