diff options
| author | Laurent Smet <las@odoo.com> | 2020-10-30 14:19:26 +0000 |
|---|---|---|
| committer | Laurent Smet <las@odoo.com> | 2020-11-04 07:06:09 +0000 |
| commit | 2b472fd59e8eebbc2cf1f592cf6e657f2ae9e778 (patch) | |
| tree | d25948fb596b12a5aa296210683f3bd048a73cf5 | |
| parent | c1f43707c6e9efc7321b71120df45f2e2cf7ee82 (diff) | |
[IMP] account: Allow skipping statement line on payments
A classic payment uses the outstanding account to create the line that needs to be matched later with a statement line.
In some cases, the user doesn't want to encode twice the same transaction, e.g. when encoding a cash payment, and want to create directly a payment impacting the cash account to skip the 'statement line' step.
| -rw-r--r-- | addons/account/models/account_journal.py | 11 | ||||
| -rw-r--r-- | addons/account/models/account_payment.py | 9 |
2 files changed, 15 insertions, 5 deletions
diff --git a/addons/account/models/account_journal.py b/addons/account/models/account_journal.py index f4d9180e617..1d14252f7b3 100644 --- a/addons/account/models/account_journal.py +++ b/addons/account/models/account_journal.py @@ -77,7 +77,7 @@ class AccountJournal(models.Model): "receivable account.", string='Outstanding Receipts Account', domain=lambda self: "[('deprecated', '=', False), ('company_id', '=', company_id), \ ('user_type_id.type', 'not in', ('receivable', 'payable')), \ - ('user_type_id', '=', %s)]" % self.env.ref('account.data_account_type_current_assets').id) + '|', ('user_type_id', '=', %s), ('id', '=', default_account_id)]" % self.env.ref('account.data_account_type_current_assets').id) payment_credit_account_id = fields.Many2one( comodel_name='account.account', check_company=True, copy=False, ondelete='restrict', help="Outgoing payments entries triggered by bills/credit notes will be posted on the Outstanding Payments Account " @@ -86,7 +86,7 @@ class AccountJournal(models.Model): "payable account.", string='Outstanding Payments Account', domain=lambda self: "[('deprecated', '=', False), ('company_id', '=', company_id), \ ('user_type_id.type', 'not in', ('receivable', 'payable')), \ - ('user_type_id', '=', %s)]" % self.env.ref('account.data_account_type_current_assets').id) + '|', ('user_type_id', '=', %s), ('id', '=', default_account_id)]" % self.env.ref('account.data_account_type_current_assets').id) suspense_account_id = fields.Many2one( comodel_name='account.account', check_company=True, ondelete='restrict', readonly=False, store=True, compute='_compute_suspense_account_id', @@ -731,7 +731,12 @@ class AccountJournal(models.Model): accounts = self.payment_debit_account_id + self.payment_credit_account_id if not accounts: - return 0.0 + return 0.0, 0 + + # Allow user managing payments without any statement lines. + # In that case, the user manages transactions only using the register payment wizard. + if self.default_account_id in accounts: + return 0.0, 0 domain = (domain or []) + [ ('account_id', 'in', tuple(accounts.ids)), diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 9bf7a5aa02a..8a26d5d8eec 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -285,11 +285,16 @@ class AccountPayment(models.Model): pay.is_reconciled = True pay.is_matched = True else: - # The journal entry seems reconciled. residual_field = 'amount_residual' if pay.currency_id == pay.company_id.currency_id else 'amount_residual_currency' + if pay.journal_id.default_account_id and pay.journal_id.default_account_id in liquidity_lines.account_id: + # Allow user managing payments without any statement lines by using the bank account directly. + # In that case, the user manages transactions only using the register payment wizard. + pay.is_matched = True + else: + pay.is_matched = pay.currency_id.is_zero(sum(liquidity_lines.mapped(residual_field))) + reconcile_lines = (counterpart_lines + writeoff_lines).filtered(lambda line: line.account_id.reconcile) pay.is_reconciled = pay.currency_id.is_zero(sum(reconcile_lines.mapped(residual_field))) - pay.is_matched = pay.currency_id.is_zero(sum(liquidity_lines.mapped(residual_field))) @api.model def _get_method_codes_using_bank_account(self): |
