Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 407ebba230 | |||
| 970aa8553f |
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# 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': '17.0.1.0.0',
|
'version': '19.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,6 +5,20 @@ 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):
|
||||||
"""
|
"""
|
||||||
@ -101,7 +115,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._context.get('skip_account_move_synchronization'):
|
if self.env.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):
|
||||||
@ -199,21 +213,7 @@ 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
|
||||||
if pay.payment_type == 'inbound':
|
pay.outstanding_account_id = pay._get_outstanding_account(pay.payment_type)
|
||||||
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
|
||||||
if pay.payment_type == 'inbound':
|
pay.outstanding_account_id = pay._get_outstanding_account(pay.payment_type)
|
||||||
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