When we get the existing tags to append them a new id, we don't get a list of id but a list of tuple with one id, this only append if you have more than one accounting of these country installed, as the first time it will return an empty list. So the command sent to the ORM, is not built correctly. To fix this we just append commands '4' that will be append in a list.
24 lines
1.0 KiB
Python
24 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo import api, models
|
|
|
|
|
|
class AccountChartTemplate(models.Model):
|
|
_inherit = 'account.chart.template'
|
|
|
|
@api.model
|
|
def _prepare_transfer_account_for_direct_creation(self, name, company):
|
|
res = super(AccountChartTemplate, self)._prepare_transfer_account_for_direct_creation(name, company)
|
|
xml_id = self.env.ref('l10n_de.tag_de_asset_bs_B_III_2').id
|
|
res.setdefault('tag_ids', [])
|
|
res['tag_ids'].append((4, xml_id))
|
|
return res
|
|
|
|
# Write paperformat and report template used on company
|
|
def load_for_current_company(self, sale_tax_rate, purchase_tax_rate):
|
|
res = super(AccountChartTemplate, self).load_for_current_company(sale_tax_rate, purchase_tax_rate)
|
|
company = self.env.user.company_id
|
|
if company.country_id.code == 'DE':
|
|
company.write({'external_report_layout': self.env.ref('l10n_de.external_layout_din5008').id,
|
|
'paperformat_id': self.env.ref('l10n_de.paperformat_euro_din').id})
|
|
return res
|