[18.0][FIX] account_payment_return: 'memo' field in account.payment #882
Approved these changes.
lgtm 👍🏿
:+1:
ref = line_id.memo if hasattr(line_id, "memo") and line_id.memo else line_id.ref
If
memo is empty, let's fill with ref.I don't think that will work, since if line_id has the memo field (so hasattr(line_id, "memo") returns True), the record won't have the ref field. If we try to fill it with ref we might get an error.
AFAIK memo is a multi-line field, so it can't be used.
@pedrobaeza memo in (at least in the account.payment model) is a char field, so the same field type as ref for account.move.line, see source.
ifline_idhas thememofield, the record won't have thereffield
Why?
If we try to fill it with ref we might get an error.
Why?
(I don't know, I am just asking to know it better)
/ocabot merge patch
On my way to merge this fine PR!
Prepared branch 18.0-ocabot-merge-pr-882-by-pedrobaeza-bump-patch, awaiting test results.
Check the initial comment in the PR with the explanation: https://github.com/OCA/account-payment/pull/882#issue-3444296421
Because the line_id parameter in this method can be, either a record of the account.payment model, or a record of the account.move.line model.
If line_id is an account.payment, then it will have the memo field, and id won't have the ref field. That's why trying to get the ref field in that case will throw an error, since the attribute does not exist for that record or model.
However, if line_id is an account.move.line, then it won't have the memo field, but it will have ref. So that covers the other scenario.
Hope it is clear now!! :)
Congratulations, your PR was merged at 32e1305c83eb3edb55c735151a7c6aa033656574. Thanks a lot for contributing to OCA. ❤️
AlexPForgeFlow
LauraCForgeFlow
Model
account.paymentdoes not have areffield anymore, it has been substituted bymemo.Since
line_idinprepare_values_returned_widgetcan be either anaccount.paymentor anaccount.move.lineinstance, we check whether we need to use thememoor thereffield.