Compare commits

..

2 Commits
main ... 19.0

3 changed files with 235 additions and 220 deletions

15
.gitignore vendored Normal file
View File

@ -0,0 +1,15 @@
# Python
*.py[cod]
__pycache__/
*.so
# Odoo
*.po~
*.pot~
# Editor / System
.DS_Store
.vscode/
*.swp
*.swo
*~

View File

@ -1,6 +1,6 @@
{
'name': 'Vendor Payment with Misc Journals',
'version': '17.0.1.0.0',
'version': '19.0.1.0.0',
'category': 'Accounting',
'summary': 'Allow using misc journals for vendor bill payments',
'description': """

View File

@ -5,6 +5,20 @@ from odoo.exceptions import UserError
class AccountPayment(models.Model):
_inherit = 'account.payment'
def _get_outstanding_account(self, payment_type):
"""Get the outstanding account for the given payment type"""
account_ref = 'account_journal_payment_debit_account_id' if payment_type == 'inbound' else 'account_journal_payment_credit_account_id'
chart_template = self.with_context(allowed_company_ids=self.company_id.root_id.ids).env['account.chart.template']
outstanding_account = (
chart_template.ref(account_ref, raise_if_not_found=False)
or self.company_id.transfer_account_id
)
if not outstanding_account:
# If no outstanding account found, try to use payment method account
if self.payment_method_line_id.payment_account_id:
outstanding_account = self.payment_method_line_id.payment_account_id
return outstanding_account
@api.depends('payment_type', 'partner_type')
def _compute_available_journal_ids(self):
"""
@ -101,7 +115,7 @@ class AccountPayment(models.Model):
Override to allow general journals for payments
"""
# Remove the check that restricts journals to only bank/cash types
if self._context.get('skip_account_move_synchronization'):
if self.env.context.get('skip_account_move_synchronization'):
return
for pay in self.with_context(skip_account_move_synchronization=True):
@ -199,21 +213,7 @@ class AccountPayment(models.Model):
pay.outstanding_account_id = pay.journal_id.default_account_id
else:
# Fallback to the original logic if no default account is set
if pay.payment_type == 'inbound':
pay.outstanding_account_id = (pay.payment_method_line_id.payment_account_id
or pay.journal_id.company_id.account_journal_payment_debit_account_id)
elif pay.payment_type == 'outbound':
pay.outstanding_account_id = (pay.payment_method_line_id.payment_account_id
or pay.journal_id.company_id.account_journal_payment_credit_account_id)
else:
pay.outstanding_account_id = False
pay.outstanding_account_id = pay._get_outstanding_account(pay.payment_type)
else:
# For bank/cash journals, use the original logic
if pay.payment_type == 'inbound':
pay.outstanding_account_id = (pay.payment_method_line_id.payment_account_id
or pay.journal_id.company_id.account_journal_payment_debit_account_id)
elif pay.payment_type == 'outbound':
pay.outstanding_account_id = (pay.payment_method_line_id.payment_account_id
or pay.journal_id.company_id.account_journal_payment_credit_account_id)
else:
pay.outstanding_account_id = False
pay.outstanding_account_id = pay._get_outstanding_account(pay.payment_type)