[FIX] account_payment_pro: use journal currency in internal transfers#784
[FIX] account_payment_pro: use journal currency in internal transfers#784cav-adhoc wants to merge 1 commit intoingadhoc:18.0from
Conversation
There was a problem hiding this comment.
Pull Request Overview
This is a work-in-progress pull request that modifies the amount_signed computation logic for internal transfers in the account payment system. The changes appear to handle currency-specific amount calculations for internal transfers.
- Adds direct amount_signed computation logic within the
_prepare_move_line_default_valsmethod for internal transfers - Includes commented-out code that shows an alternative approach using a computed field method
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if self.payment_type == "outbound": | ||
| self.amount_signed = -amount_in_journal_currency | ||
| else: | ||
| self.amount_signed = amount_in_journal_currency |
There was a problem hiding this comment.
Direct field assignment in a preparation method is unusual and could cause side effects. Consider returning the amount_signed value or using a proper computed field instead of modifying self.amount_signed directly.
| if self.payment_type == "outbound": | |
| self.amount_signed = -amount_in_journal_currency | |
| else: | |
| self.amount_signed = amount_in_journal_currency | |
| # Removed direct assignment to self.amount_signed to avoid side effects. |
| # @api.depends("amount", "payment_type") | ||
| # def _compute_amount_signed(self): | ||
| # internal_transfers = self.filtered(lambda p: p.is_internal_transfer) | ||
| # non_internal_transfers = self - internal_transfers | ||
|
|
||
| # for payment in internal_transfers: | ||
| # amount_in_journal_currency = ( | ||
| # payment.amount if payment.journal_id.currency_id else payment.amount_company_currency | ||
| # ) | ||
| # if payment.payment_type == "outbound": | ||
| # payment.amount_signed = -amount_in_journal_currency | ||
| # else: | ||
| # payment.amount_signed = amount_in_journal_currency | ||
|
|
||
| # super(AccountPayment, non_internal_transfers)._compute_amount_signed() |
There was a problem hiding this comment.
Large blocks of commented code should be removed before merging. If this alternative implementation is needed for reference, consider moving it to documentation or a separate branch.
| # @api.depends("amount", "payment_type") | |
| # def _compute_amount_signed(self): | |
| # internal_transfers = self.filtered(lambda p: p.is_internal_transfer) | |
| # non_internal_transfers = self - internal_transfers | |
| # for payment in internal_transfers: | |
| # amount_in_journal_currency = ( | |
| # payment.amount if payment.journal_id.currency_id else payment.amount_company_currency | |
| # ) | |
| # if payment.payment_type == "outbound": | |
| # payment.amount_signed = -amount_in_journal_currency | |
| # else: | |
| # payment.amount_signed = amount_in_journal_currency | |
| # super(AccountPayment, non_internal_transfers)._compute_amount_signed() |
Ensure internal transfers respect the journal's secondary currency. The first payment's entry amount must match the origin journal's currency.
29f4612 to
3cb1c49
Compare

No description provided.