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

[15.0][OU-FIX] account: fill payment_method_line_id #4537

Merged
merged 1 commit into from
Aug 9, 2024

Conversation

remytms
Copy link
Contributor

@remytms remytms commented Aug 8, 2024

The payment_method_line_id field is a stored field and should be filled during migration. Here is a proposal to fill it with python code in post-migration.py.

@pedrobaeza pedrobaeza added this to the 15.0 milestone Aug 8, 2024
@pedrobaeza
Copy link
Member

This is already filled in end-migration:

def _fast_fill_account_payment_payment_method_line_id(env):

Maybe the comment in the analysis work file is needed, but nothing more.

@remytms
Copy link
Contributor Author

remytms commented Aug 8, 2024

Indeed, I did not look at the right place, with updated comment it will be easier.

I did this commit because I have a case where payment_method_line_id is not set with the actual migration script. But is correctly filled with the python code I posted.

E.g.:

=> select id, move_id, payment_method_id, payment_method_line_id from account_payment where id = 146;
 id  | move_id | payment_method_id | payment_method_line_id 
-----+---------+-------------------+------------------------
 146 |    1310 |                 4 |                       
(1 ligne)

=> UPDATE account_payment ap
        SET payment_method_line_id = apml.id
        FROM account_move am
        JOIN account_payment_method_line apml ON apml.journal_id = am.journal_id
        WHERE ap.move_id = am.id AND ap.payment_method_id = apml.payment_method_id;
UPDATE 31

=> select id, move_id, payment_method_id, payment_method_line_id from account_payment where id = 146;
 id  | move_id | payment_method_id | payment_method_line_id 
-----+---------+-------------------+------------------------
 146 |    1310 |                 4 |                       
(1 ligne)

With python code I ended with:

=> select id, move_id, payment_method_id, payment_method_line_id from account_payment where id = 146;
 id  | move_id | payment_method_id | payment_method_line_id 
-----+---------+-------------------+------------------------
 146 |    1310 |                 2 |                      4
(1 row)

I will look at the existing SQL command to see why it does not fill payment_method_line_id correctly in all cases.

@remytms
Copy link
Contributor Author

remytms commented Aug 8, 2024

We see in my previous comment that when using the python code (the same as compute method) it changes the payment_method_id. That is because in 16.0 payment_method_id is the one found in payment_method_line_id.

The SQL command in the OU script does not update the line because there is no such payment_method_line that match the condition.

=> select * from account_payment as ap join account_move as am on ap.move_id = am.id join account_payment_method_line apml ON apml.journal_id = am.journal_id  where move_id = 1310 AND ap.payment_method_id = apml.payment_method_id;
-> return 0 records

@remytms remytms force-pushed the 15.0-fix-account-account_payment branch from ff1363a to f59f036 Compare August 8, 2024 16:07
@remytms
Copy link
Contributor Author

remytms commented Aug 8, 2024

In fact, I think the problem comes from the fact that inbound/outbount_payment_method were not correctly ported from 14.0 to 15.0.

I have an account.journal like that in 14.0:

image

Using the account_banking_sepa_credit_transfer module.

And in 16.0:

image

The sepa_credit_transfer method is removed when migrating because of this line. It creates payment_method_line_ids only for "manual" payment method.

Is there a reason for that ?

@pedrobaeza
Copy link
Member

Not all payment methods should generate payment method lines. That's why this is only handling manual ones, but I think for SEPA DD/SCT may be correct to generate them.

@remytms remytms force-pushed the 15.0-fix-account-account_payment branch from f59f036 to 34e7128 Compare August 9, 2024 08:53
@remytms
Copy link
Contributor Author

remytms commented Aug 9, 2024

Thanks @pedrobaeza I will submit a correction for SEPA method in another PR. And for this PR I just left the improved comment in the analysis file.

remytms added a commit to coopiteasy/OpenUpgrade that referenced this pull request Aug 9, 2024
Not all payment_method should generate payment_method_line, but SEPA
method from module account_banking_sepa_credit_transfer should generate
one.

See comments in OCA#4537
@legalsylvain
Copy link
Contributor

Thanks !

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 15.0-ocabot-merge-pr-4537-by-legalsylvain-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit e09e5e4 into OCA:15.0 Aug 9, 2024
2 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at e09e5e4. Thanks a lot for contributing to OCA. ❤️

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

Successfully merging this pull request may close these issues.

4 participants