Debian Codegraph @

addons/l10n_in/models/account_journal.py

raw symbols SCIP
1 from odoo import models
2
3
4 class AccountJournal(models.Model):
5 _inherit = "account.journal"
6
7 def _update_payment_method_lines(self, payment_type):
8 bank_journals = self.filtered(lambda j: j.type == "bank" and j.company_id.chart_template == "in")
9 if not bank_journals:
10 return
11
12 if payment_type == 'inbound':
13 account_xmlid = "account_journal_payment_debit_account_id"
14 else:
15 account_xmlid = "account_journal_payment_credit_account_id"
16
17 lines_to_update = bank_journals[f"{payment_type}_payment_method_line_ids"].filtered(
18 lambda l: l.payment_method_id.code == 'manual'
19 )
20 for company, lines in lines_to_update.grouped('company_id').items():
21 if account := self.env['account.chart.template'].with_company(company).ref(account_xmlid, raise_if_not_found=False):
22 lines.payment_account_id = account
23
24 def _compute_inbound_payment_method_line_ids(self):
25 super()._compute_inbound_payment_method_line_ids()
26 self._update_payment_method_lines("inbound")
27
28 def _compute_outbound_payment_method_line_ids(self):
29 super()._compute_outbound_payment_method_line_ids()
30 self._update_payment_method_lines("outbound")