Files
account_do/account.py
T

36 lines
1.4 KiB
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool, PoolMeta
class CreateChart(metaclass=PoolMeta):
__name__ = 'account.create_chart'
def default_properties(self, fields):
pool = Pool()
ModelData = pool.get('ir.model.data')
defaults = super().default_properties(fields)
chart_defaults = {}
for root, accounts in [
('account_do.do_account_root_en', (
'account_do.do_account_110201_en',
'account_do.do_account_210101_en')),
('account_do.do_account_root_es_419', (
'account_do.do_account_110201_es_419',
'account_do.do_account_210101_es_419')),
]:
try:
chart_defaults[ModelData.get_id(root)] = accounts
except KeyError:
# Language-scoped chart data is not loaded for this database.
pass
account_template = self.account.account_template.id
if account_template in chart_defaults:
receivable, payable = chart_defaults[account_template]
defaults['account_receivable'] = self.get_account(
receivable)
defaults['account_payable'] = self.get_account(
payable)
return defaults