2026-08-09 13:44:20 -04:00
|
|
|
# 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)
|
2026-08-10 00:08:55 -04:00
|
|
|
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]
|
2026-08-09 13:44:20 -04:00
|
|
|
defaults['account_receivable'] = self.get_account(
|
2026-08-10 00:08:55 -04:00
|
|
|
receivable)
|
2026-08-09 13:44:20 -04:00
|
|
|
defaults['account_payable'] = self.get_account(
|
2026-08-10 00:08:55 -04:00
|
|
|
payable)
|
2026-08-09 13:44:20 -04:00
|
|
|
return defaults
|