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

[FW][FIX] sale: avoid crash when posting move linked to multiple SO #111366

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Jan 30, 2023

Because of the M2M relation, an account.move.line can be linked to several sale.order.lines, making the cardinality of sale_line_ids superior to 1.
Even if it is not possible to obtain this result with standard code, a custom module could create this situation and posting the invoice would result in a "ValueError: Expected singleton" exception.

This commit prevents this exception by checking whether the line is linked to at least one downpayment SO line in the method action_post. The test also checks that the methods button_draft and button_cancel
behave properly (spoiler alert: they will fail too in 16.0).

Closes #77195
Fixes #77028

Forward-Port-Of: #110633
Forward-Port-Of: #110560

@robodoo
Copy link
Contributor

robodoo commented Jan 30, 2023

@fw-bot
Copy link
Contributor Author

fw-bot commented Jan 30, 2023

This PR targets saas-16.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

@fw-bot
Copy link
Contributor Author

fw-bot commented Jan 30, 2023

@madprog ci/runbot failed on this forward-port PR

@robodoo robodoo added the forwardport This PR was created by @fw-bot label Jan 30, 2023
@C3POdoo C3POdoo added the RD research & development, internal work label Jan 30, 2023
Because of the M2M relation, an account.move.line can be linked to
several sale.order.lines, making the cardinality of sale_line_ids
superior to 1.
Even if it is not possible to obtain this result with standard code,
a custom module could create this situation and posting the invoice
would result in a "ValueError: Expected singleton" exception.

This commit prevents this exception by checking whether the line is
linked to at least one downpayment SO line in the method action_post.
The test also checks that the methods button_draft and button_cancel
behave properly (spoiler alert: they will fail too in 16.0).

X-original-commit: e1060eb
@madprog madprog force-pushed the saas-16.1-14.0-avoid_crash_multiple_so_per_invoice-pmo-SxLZ-fw branch from a88050f to 17a269a Compare January 31, 2023 08:39
@fw-bot
Copy link
Contributor Author

fw-bot commented Jan 31, 2023

@madprog this PR was modified / updated and has become a normal PR. It should be merged the normal way (via @robodoo)

@madprog
Copy link
Contributor

madprog commented Feb 1, 2023

@Feyensv Sorry to disturb you again with this, but could you r+ this? 🙏 Thanks!

@Feyensv
Copy link
Contributor

Feyensv commented Feb 2, 2023

@robodoo r+

robodoo pushed a commit that referenced this pull request Feb 2, 2023
Because of the M2M relation, an account.move.line can be linked to
several sale.order.lines, making the cardinality of sale_line_ids
superior to 1.
Even if it is not possible to obtain this result with standard code,
a custom module could create this situation and posting the invoice
would result in a "ValueError: Expected singleton" exception.

This commit prevents this exception by checking whether the line is
linked to at least one downpayment SO line in the method action_post.
The test also checks that the methods button_draft and button_cancel
behave properly (spoiler alert: they will fail too in 16.0).

closes #111366

X-original-commit: e1060eb
Signed-off-by: Paul Morelle (pmo) <pmo@odoo.com>
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
@robodoo robodoo temporarily deployed to merge February 2, 2023 12:28 Inactive
@robodoo robodoo closed this Feb 2, 2023
@fw-bot fw-bot deleted the saas-16.1-14.0-avoid_crash_multiple_so_per_invoice-pmo-SxLZ-fw branch February 16, 2023 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwardport This PR was created by @fw-bot RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants