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

[12.0] [REF] Account payment return: invoice returned vals #310

Merged

Conversation

qgroulard
Copy link

For better extensibility, notify the invoice that a payment return has arrived and let it do what it implies for itself.

@qgroulard qgroulard force-pushed the 12.0-ref_account_payment_invoice_return_vals-qgr branch from 7270724 to df567a2 Compare February 6, 2020 13:21
@pedrobaeza pedrobaeza added this to the 12.0 milestone Feb 7, 2020
@@ -228,8 +227,10 @@ def action_confirm(self):
# returned_moves: debit on customer account (from invoice move)
returned_moves = move_line.matched_debit_ids.mapped(
'debit_move_id')
returned_moves.mapped('invoice_id')._payment_returned(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this return more than one invoice and thus give singleton error?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may return more than one invoice when a payment reconciled with several invoices is returned.
_payment_returned is api.multi, it should not be problematic.

@qgroulard qgroulard force-pushed the 12.0-ref_account_payment_invoice_return_vals-qgr branch from 6473e58 to 630a0c2 Compare February 7, 2020 15:04
Copy link
Member

@sbidoul sbidoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _payment_returned event method is now on account.move.line which is more flexible.

Still LGTM.

@pedrobaeza ok for you? This small refactoring is the basis for the new features in the other PRs.

@pedrobaeza
Copy link
Member

Seems a bit weird that you have the trigger but call a prepare method in other model. Also there seems to be now 2 _prepare_invoice_returned_vals.

@qgroulard
Copy link
Author

Seems a bit weird that you have the trigger but call a prepare method in other model. Also there seems to be now 2 _prepare_invoice_returned_vals.

Indeed it's a bit weird but we kept the method on payment.return to ensure compatibility with previous versions of the code.

Moreover, some data useful for the computation of invoice returned vals are stored on payment.return.line and not on payment.return (e.g. the return reason code).
Thus we have added a 2nd prep method on payment.return.line.

@sbidoul
Copy link
Member

sbidoul commented Feb 11, 2020

@pedrobaeza to me it looks clean. You can see an example usage this PR enables in cf983bf

@pedrobaeza
Copy link
Member

I think we should keep then both _payment_returned for retro-compatibility as well.

@sbidoul
Copy link
Member

sbidoul commented Feb 12, 2020

I think we should keep then both _payment_returned for retro-compatibility as well.

@pedrobaeza I don't understand: _payment_returned is present on move.line and account.invoice, and it is new in this PR, so there is no compatibility issue.

@pedrobaeza
Copy link
Member

Yeah, sorry, I mixed things as I was seeing only one commit diff. Please squash both commits in one and I'll merge.

@qgroulard qgroulard force-pushed the 12.0-ref_account_payment_invoice_return_vals-qgr branch from 630a0c2 to f88699b Compare February 17, 2020 14:10
@qgroulard
Copy link
Author

@pedrobaeza Commits squashed.

@pedrobaeza
Copy link
Member

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 12.0-ocabot-merge-pr-310-by-pedrobaeza-bump-patch, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Feb 17, 2020
Signed-off-by pedrobaeza
@OCA-git-bot OCA-git-bot merged commit f88699b into OCA:12.0 Feb 17, 2020
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 2577c02. 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