[FIX] sale_order_type: Incompatibility with l10n_latam_check module #3557
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.
This PR corrects an error that occurs in the core's l10n_latam_check module when creating third-party checks, when the sale_order_type module is installed.
The error comes up when adding the sale_type_id dependency to the _compute_journal_id method of the account.move model.
While adding the dependency is technically correct, it creates a problem due to the relationship between the account.move and account.payment models, both during the creation of payments from the backend and during import.
The modification proposed in this PR solves the problem in the following ways:
The sale_type_id dependency in _compute_journal_id is removed and replaced by the calculation in _search_default_journal. This avoids the conflict in the relationship between account.move and account.payment.
An onchange is added for the order_type_id field in the form. This ensures that the journal is recalculated correctly when the order type is modified.
It is validated that the journal is present in suitable_journal_ids. This prevents the user from selecting a journal to which they do not have access.
Behavior before the PR
Behavior after the PR