Compare commits
No commits in common. "19.0" and "main" have entirely different histories.
15
.gitignore
vendored
15
.gitignore
vendored
@ -1,15 +0,0 @@
|
|||||||
# Python
|
|
||||||
*.py[cod]
|
|
||||||
__pycache__/
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Odoo
|
|
||||||
*.po~
|
|
||||||
*.pot~
|
|
||||||
|
|
||||||
# Editor / System
|
|
||||||
.DS_Store
|
|
||||||
.vscode/
|
|
||||||
*.swp
|
|
||||||
*.swo
|
|
||||||
*~
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
'name': 'Vendor Payment with Misc Journals',
|
'name': 'Vendor Payment with Misc Journals',
|
||||||
'version': '19.0.1.0.0',
|
'version': '17.0.1.0.0',
|
||||||
'category': 'Accounting',
|
'category': 'Accounting',
|
||||||
'summary': 'Allow using misc journals for vendor bill payments',
|
'summary': 'Allow using misc journals for vendor bill payments',
|
||||||
'description': """
|
'description': """
|
||||||
|
|||||||
@ -5,20 +5,6 @@ from odoo.exceptions import UserError
|
|||||||
class AccountPayment(models.Model):
|
class AccountPayment(models.Model):
|
||||||
_inherit = 'account.payment'
|
_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')
|
@api.depends('payment_type', 'partner_type')
|
||||||
def _compute_available_journal_ids(self):
|
def _compute_available_journal_ids(self):
|
||||||
"""
|
"""
|
||||||
@ -115,7 +101,7 @@ class AccountPayment(models.Model):
|
|||||||
Override to allow general journals for payments
|
Override to allow general journals for payments
|
||||||
"""
|
"""
|
||||||
# Remove the check that restricts journals to only bank/cash types
|
# Remove the check that restricts journals to only bank/cash types
|
||||||
if self.env.context.get('skip_account_move_synchronization'):
|
if self._context.get('skip_account_move_synchronization'):
|
||||||
return
|
return
|
||||||
|
|
||||||
for pay in self.with_context(skip_account_move_synchronization=True):
|
for pay in self.with_context(skip_account_move_synchronization=True):
|
||||||
@ -213,7 +199,21 @@ class AccountPayment(models.Model):
|
|||||||
pay.outstanding_account_id = pay.journal_id.default_account_id
|
pay.outstanding_account_id = pay.journal_id.default_account_id
|
||||||
else:
|
else:
|
||||||
# Fallback to the original logic if no default account is set
|
# Fallback to the original logic if no default account is set
|
||||||
pay.outstanding_account_id = pay._get_outstanding_account(pay.payment_type)
|
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
|
||||||
else:
|
else:
|
||||||
# For bank/cash journals, use the original logic
|
# For bank/cash journals, use the original logic
|
||||||
pay.outstanding_account_id = pay._get_outstanding_account(pay.payment_type)
|
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
|
||||||
Loading…
Reference in New Issue
Block a user