[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.

X-original-commit: 2b472fd59e8eebbc2cf1f592cf6e657f2ae9e778
This commit is contained in:
Laurent Smet
2020-11-04 14:47:29 +00:00
parent fef82f3c97
commit a498497962
2 changed files with 15 additions and 5 deletions
+8 -3
View File
@@ -87,7 +87,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 "
@@ -96,7 +96,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',
@@ -761,7 +761,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)),
+7 -2
View File
@@ -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):