Skip to content

[FW][FIX] product: Warning when setting a UOM more precise than Decimal A…#58173

Closed
fw-bot wants to merge 1 commit intoodoo:12.0from
odoo-dev:12.0-11.0-stock-product_uom-unreserve-fah-qugT-fw
Closed

[FW][FIX] product: Warning when setting a UOM more precise than Decimal A…#58173
fw-bot wants to merge 1 commit intoodoo:12.0from
odoo-dev:12.0-11.0-stock-product_uom-unreserve-fah-qugT-fw

Conversation

@fw-bot
Copy link
Copy Markdown
Contributor

@fw-bot fw-bot commented Sep 22, 2020

…ccuracy

One can set a Unit of Measure precision rounding more
precise than the overall Decimal Accuracy. This can trigger the error
'It is not possible to unreserve more products', as there will be
inconsistencies on reserved quantities due to decimal roundings.
We add a warning, so that the users who make the change are aware of the
impact of modifying their UOM precision.

opw 2171541
opw 2221227
opw 2233937
opw 2198775
and many more

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #58126
Forward-Port-Of: #54935

@robodoo robodoo added conflict There was an error while creating this forward-port PR forwardport This PR was created by @fw-bot seen 🙂 labels Sep 22, 2020
@fw-bot
Copy link
Copy Markdown
Contributor Author

fw-bot commented Sep 22, 2020

Ping @fah-odoo, @amoyaux
Cherrypicking 5535110 of source #54935 failed

stderr:

error: could not apply 5535110d3c4... [FIX] product, decimal_precision, stock, mrp: Prevent quant reservation issue
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

In the former case, you may want to edit this PR message as well.

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Sep 22, 2020
@fah-mili fah-mili force-pushed the 12.0-11.0-stock-product_uom-unreserve-fah-qugT-fw branch from bc0bdc0 to f9a0191 Compare September 22, 2020 14:15
@robodoo robodoo added ☐ legal/cla CI 🤖 Robodoo has seen passing statuses and removed ☑ legal/cla labels Sep 22, 2020
@fah-mili
Copy link
Copy Markdown

@amoyaux won't have time to check carefully before Thursday, but I tried to solve the conflicts

@fah-mili fah-mili force-pushed the 12.0-11.0-stock-product_uom-unreserve-fah-qugT-fw branch from f9a0191 to 16e4ab8 Compare September 24, 2020 10:56
@robodoo robodoo added ☐ ci/runbot and removed CI 🤖 Robodoo has seen passing statuses ☑ ci/runbot labels Sep 24, 2020
…on issue

One can set a Unit of Measure precision rounding more
precise than the overall Decimal Accuracy. This can trigger the error
'It is not possible to unreserve more products', as there will be
inconsistencies on reserved quantities due to decimal roundings.
We add 2 warnings on Units of Measure and Decimal Accuracy.
Therefore, users are warned when their UOM/decimal changes can
cause inconsistencies in quants reservation.

Also, we want to prevent the issue at the root by ensuring that both the move
and the quant have the same reserved quantity.
The contrary can happen e.g. when a product is defined in Liters (rounding .001)
but used in an operation in ml (rounding .01, so e.g. 187.5ml).
The conversions between the 2 UOM can cause the differences of reservations.

In _prepare_move_line_vals we make sure uom_quantity_back_to_product_uom
is not more precise than the overall Decimal Accuracy. That way, if
the reserved quantity changes between UOM conversions, the move line created
is in the quant/product UOM, and we do not have move line's reserved quantity >
quantity in stock.
We do the same for _update_reserved_quantity (stock.move), when updating
a move line.

In _generate_consumed_move_line, because of UOM conversions, new_quantity_done
can differ from ml.product_uom_qty, which triggers the creation of an extra
move line, leading to reserved quantity > quantity in stock. To prevent
that, we compare the reserved quantities in the product UOM.

opw 2206902 (Example 1)
opw 2171541
opw 2221227
opw 2233937
opw 2198775
and many more

X-original-commit: 2e5c1ba
@fah-mili fah-mili force-pushed the 12.0-11.0-stock-product_uom-unreserve-fah-qugT-fw branch from 9ad17d4 to 0857457 Compare September 28, 2020 08:58
@robodoo robodoo added ☐ ci/runbot and removed CI 🤖 Robodoo has seen passing statuses ☑ ci/runbot labels Sep 28, 2020

# produce
context = {"active_ids": [mo_product_final.id], "active_id": mo_product_final.id}
produce_form = Form(self.env['mrp.product.produce'].with_context(context))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@amoyaux Thanks for your comment, I changed it.

@robodoo robodoo added ☑ ci/template CI 🤖 Robodoo has seen passing statuses and removed ☐ ci/template labels Sep 28, 2020
@amoyaux
Copy link
Copy Markdown
Contributor

amoyaux commented Sep 29, 2020

robodoo r+

robodoo pushed a commit that referenced this pull request Sep 29, 2020
…on issue

One can set a Unit of Measure precision rounding more
precise than the overall Decimal Accuracy. This can trigger the error
'It is not possible to unreserve more products', as there will be
inconsistencies on reserved quantities due to decimal roundings.
We add 2 warnings on Units of Measure and Decimal Accuracy.
Therefore, users are warned when their UOM/decimal changes can
cause inconsistencies in quants reservation.

Also, we want to prevent the issue at the root by ensuring that both the move
and the quant have the same reserved quantity.
The contrary can happen e.g. when a product is defined in Liters (rounding .001)
but used in an operation in ml (rounding .01, so e.g. 187.5ml).
The conversions between the 2 UOM can cause the differences of reservations.

In _prepare_move_line_vals we make sure uom_quantity_back_to_product_uom
is not more precise than the overall Decimal Accuracy. That way, if
the reserved quantity changes between UOM conversions, the move line created
is in the quant/product UOM, and we do not have move line's reserved quantity >
quantity in stock.
We do the same for _update_reserved_quantity (stock.move), when updating
a move line.

In _generate_consumed_move_line, because of UOM conversions, new_quantity_done
can differ from ml.product_uom_qty, which triggers the creation of an extra
move line, leading to reserved quantity > quantity in stock. To prevent
that, we compare the reserved quantities in the product UOM.

opw 2206902 (Example 1)
opw 2171541
opw 2221227
opw 2233937
opw 2198775
and many more

closes #58173

X-original-commit: 2e5c1ba
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
@robodoo robodoo closed this Sep 29, 2020
@robodoo robodoo temporarily deployed to merge September 29, 2020 08:20 Inactive
@fw-bot fw-bot deleted the 12.0-11.0-stock-product_uom-unreserve-fah-qugT-fw branch October 13, 2020 08:46
AdriaGForgeFlow pushed a commit to ForgeFlow/odoo that referenced this pull request Jan 28, 2021
…on issue

One can set a Unit of Measure precision rounding more
precise than the overall Decimal Accuracy. This can trigger the error
'It is not possible to unreserve more products', as there will be
inconsistencies on reserved quantities due to decimal roundings.
We add 2 warnings on Units of Measure and Decimal Accuracy.
Therefore, users are warned when their UOM/decimal changes can
cause inconsistencies in quants reservation.

Also, we want to prevent the issue at the root by ensuring that both the move
and the quant have the same reserved quantity.
The contrary can happen e.g. when a product is defined in Liters (rounding .001)
but used in an operation in ml (rounding .01, so e.g. 187.5ml).
The conversions between the 2 UOM can cause the differences of reservations.

In _prepare_move_line_vals we make sure uom_quantity_back_to_product_uom
is not more precise than the overall Decimal Accuracy. That way, if
the reserved quantity changes between UOM conversions, the move line created
is in the quant/product UOM, and we do not have move line's reserved quantity >
quantity in stock.
We do the same for _update_reserved_quantity (stock.move), when updating
a move line.

In _generate_consumed_move_line, because of UOM conversions, new_quantity_done
can differ from ml.product_uom_qty, which triggers the creation of an extra
move line, leading to reserved quantity > quantity in stock. To prevent
that, we compare the reserved quantities in the product UOM.

opw 2206902 (Example 1)
opw 2171541
opw 2221227
opw 2233937
opw 2198775
and many more

closes odoo#58173

X-original-commit: 2e5c1ba
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI 🤖 Robodoo has seen passing statuses conflict There was an error while creating this forward-port PR forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants