[ADD] stock_exception: when to run the exception (confirm/validate) #2046
+79
−11
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.
When we were testing the model, in case we choose 'stock.picking' as the model where we wanted to apply the exception, we noticed that the exception also ran when we confirmed sale orders.
This happens because, by confirming sale orders, the action confirm creates the respective records in stock.picking (IN/OUT, depending on the configuration you have) and run the exception.
What we want is to have the decision when to run the exception, if at the creation of the stock.picking record or if at the validation of the stock.picking record.
Due to this desire, we created two new boolean fields in the stock.exception class (check_on_validate and check_on_confirm) in order to indicate when to run the exception. If you select check_on_confirm, it will run the exception when you create the stock.picking record. If you select check_on_validate, it will run the exception when you validate the stock.picking record.