This commit changes the mechanism to get the transfer account. As the bank/cash accounts, the transfer account is now created automatically based on a prefix. -task: https://www.odoo.com/web#id=35857&action=333&active_id=967&model=project.task&view_type=form&menu_id=4720
55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
# coding: utf-8
|
|
# Copyright 2016 Vauxoo (https://www.vauxoo.com) <info@vauxoo.com>
|
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
|
|
|
from odoo import models, api, _
|
|
|
|
|
|
class AccountChartTemplate(models.Model):
|
|
_inherit = "account.chart.template"
|
|
|
|
@api.model
|
|
def generate_journals(self, acc_template_ref, company, journals_dict=None):
|
|
"""Set the tax_cash_basis_journal_id on the company"""
|
|
res = super(AccountChartTemplate, self).generate_journals(
|
|
acc_template_ref, company, journals_dict=journals_dict)
|
|
if not self == self.env.ref('l10n_mx.mx_coa'):
|
|
return res
|
|
journal_basis = self.env['account.journal'].search([
|
|
('company_id', '=', company.id),
|
|
('type', '=', 'general'),
|
|
('code', '=', 'CBMX')], limit=1)
|
|
company.write({'tax_cash_basis_journal_id': journal_basis.id})
|
|
return res
|
|
|
|
@api.multi
|
|
def _prepare_all_journals(self, acc_template_ref, company, journals_dict=None):
|
|
"""Create the tax_cash_basis_journal_id"""
|
|
res = super(AccountChartTemplate, self)._prepare_all_journals(
|
|
acc_template_ref, company, journals_dict=journals_dict)
|
|
if not self == self.env.ref('l10n_mx.mx_coa'):
|
|
return res
|
|
account = acc_template_ref.get(self.env.ref('l10n_mx.cuenta118_01').id)
|
|
res.append({
|
|
'type': 'general',
|
|
'name': _('Effectively Paid'),
|
|
'code': 'CBMX',
|
|
'company_id': company.id,
|
|
'default_credit_account_id': account,
|
|
'default_debit_account_id': account,
|
|
'show_on_dashboard': True,
|
|
})
|
|
return res
|
|
|
|
|
|
class WizardMultiChartsAccounts(models.TransientModel):
|
|
_inherit = 'wizard.multi.charts.accounts'
|
|
|
|
@api.model
|
|
def _prepare_transfer_account(self, name, company):
|
|
res = super(WizardMultiChartsAccounts, self)._prepare_transfer_account(name, company)
|
|
xml_id = self.env.ref('l10n_mx.account_tag_102_01').id
|
|
existing_tags = [x[-1:] for x in res.get('tag_ids', [])]
|
|
res['tag_ids'] = [(6, 0, existing_tags + [xml_id])]
|
|
return res
|