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

[FIX] sale_order_type: Incompatibility with l10n_latam_check module #3557

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from

Conversation

maq-adhoc
Copy link

@maq-adhoc maq-adhoc commented Jan 31, 2025

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

  • A third-party check payment is created.
  • The l10n_latam_check_issuer_vat field is modified.
  • The form is saved.
  • The l10n_latam_check_issuer_vat field is recomputed to its default value, losing the modified value.

Behavior after the PR

  • A third-party check payment is created.
  • The l10n_latam_check_issuer_vat field is modified.
  • The form is saved.
  • The l10n_latam_check_issuer_vat field retains the loaded value

This is a work-in-progress PR and is not yet finished.

When adding a dependency to the _compute_journal_id method, it breaks the functionality of the l10n_latam_check module when calculating the l10n_latam_check_issuer_vat field during the creation of a third-party check payment.

Steps to reproduce:

Create a payment.
Choose a third-party check journal.
Modify the l10n_latam_check_issuer_vat issuer.
Save the payment.
The l10n_latam_check_issuer_vat field is recomputed.
@rov-adhoc
Copy link

rov-adhoc commented Jan 31, 2025

This PR resolve the same error of the PR #3159

@maq-adhoc maq-adhoc marked this pull request as ready for review February 4, 2025 11:19
@maq-adhoc
Copy link
Author

Hi @rousseldenis I see that you analyzed the problem that @rov-adhoc raised in the PR.
This is a similar problem and also fixes that issue in a more elegant way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants