[MERGE] merged the dev branch with enhancement and refactoring of code to generate objects from template + l10n_multilang module

bzr revid: qdp-launchpad@openerp.com-20111209101411-ewjshwbbvp3o7yyj
This commit is contained in:
Quentin (OpenERP) 2011-12-09 11:14:11 +01:00
commit d9fcbf5946
11 changed files with 1053 additions and 509 deletions

View File

@ -104,6 +104,7 @@ module named account_voucher.
'account_invoice_view.xml',
'partner_view.xml',
'data/account_data.xml',
'data/data_account_type.xml',
'account_invoice_workflow.xml',
'project/project_view.xml',
'project/project_report.xml',

File diff suppressed because it is too large Load Diff

View File

@ -34,10 +34,6 @@
<field name="date_stop"/>
<field name="period" colspan="4"/>
</group>
<group colspan="4" attrs="{'invisible':[('charts','!=','configurable')]}">
<field name="sale_tax" on_change="on_change_tax(sale_tax)" attrs="{'required':[('charts','=','configurable')]}"/>
<field name="purchase_tax" groups="base.group_extended"/>
</group>
</group>
</group>
</data>

View File

@ -1753,18 +1753,18 @@
<field name="arch" type="xml">
<form string="Payment Term">
<group>
<group colspan="2" col="4">
<field name="name" select="1"/>
<separator string="Amount Computation" colspan="4"/>
<field name="value" colspan="4"/>
<field name="value_amount" colspan="4" attrs="{'readonly':[('value','=','balance')]}"/>
</group>
<group colspan="2" col="4">
<field name="sequence"/>
<separator string="Due Date Computation" colspan="4"/>
<field name="days" colspan="4"/>
<field name="days2" colspan="4"/>
</group>
<group colspan="2" col="4">
<field name="name" select="1"/>
<separator string="Amount Computation" colspan="4"/>
<field name="value" colspan="4"/>
<field name="value_amount" colspan="4" attrs="{'readonly':[('value','=','balance')]}"/>
</group>
<group colspan="2" col="4">
<field name="sequence"/>
<separator string="Due Date Computation" colspan="4"/>
<field name="days" colspan="4"/>
<field name="days2" colspan="4"/>
</group>
</group>
<newline/>
<separator string="Example" colspan="4"/>
@ -2114,6 +2114,7 @@
<field name="currency_id"/>
<field name="reconcile"/>
<field name="chart_template_id"/>
<separator string="Default taxes" colspan="4"/>
<field name="tax_ids" colspan="4" nolabel="1"/>
</page>
@ -2184,9 +2185,13 @@
<form string="Chart of Accounts Template">
<group>
<field name="name"/>
<field name="account_root_id"/>
<field name="bank_account_view_id"/>
<field name="tax_code_root_id"/>
<field name="account_root_id" attrs="{'required': [('parent_id', '=', False)]}"/>
<field name="bank_account_view_id" attrs="{'required': [('parent_id', '=', False)]}"/>
<field name="tax_code_root_id" attrs="{'required': [('parent_id', '=', False)]}"/>
<field name="parent_id" />
<!--<field name="code_digits" />-->
<field name="visible" />
<field name="complete_tax_set" />
</group>
<field name="tax_template_ids" colspan="4" readonly="1" nolabel="1"/>
<separator string="Properties" colspan="4"/>
@ -2270,7 +2275,9 @@
<field name="chart_template_id"/>
<field name="type"/>
<field name="type_tax_use"/>
<field name="price_include"/>
<group colspan="2" col="4">
<field name="price_include"/>
</group>
</group>
<notebook colspan="4">
<page string="Tax Definition">
@ -2437,10 +2444,13 @@
<group string="res_config_contents" position="replace">
<field name="company_id" widget="selection"/> <!-- we assume that this wizard will be run only by administrators and as this field may cause problem if hidden (because of the default company of the user removed from the selection because already configured), we simply choosed to remove the group "multi company" of it -->
<field name ="code_digits" groups="account.group_account_user"/>
<field name="chart_template_id" widget="selection" on_change="onchange_chart_template_id(chart_template_id)"/>
<field name ="seq_journal" groups="account.group_account_user"/>
<field name="sale_tax" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('sale','all'))]"/>
<field name="purchase_tax" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('purchase', 'all'))]"/>
<field name="chart_template_id" widget="selection" on_change="onchange_chart_template_id(chart_template_id)" domain="[('visible','=', True)]"/>
<field name ="seq_journal" groups="base.group_extended"/>
<field name="sale_tax" attrs="{'invisible': [('complete_tax_set', '!=', True)]}" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('sale','all'))]"/>
<field name="purchase_tax" attrs="{'invisible': [('complete_tax_set', '!=', True)]}" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('purchase', 'all'))]"/>
<field name ="sale_tax_rate" attrs="{'invisible': [('complete_tax_set', '=', True)]}"/>
<field name ="purchase_tax_rate" attrs="{'invisible': [('complete_tax_set', '=', True)]}"/>
<field name ="complete_tax_set" invisible="1"/>
<newline/> <!-- extended view because the web UI is not good for one2many -->
<field colspan="4" mode="tree" name="bank_accounts_id" nolabel="1" widget="one2many_list" groups="account.group_account_user">
<form string="Bank Information">

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record model="account.account.type" id="data_account_type_view">
<field name="name">View</field>
<field name="code">view</field>
<field name="close_method">none</field>
</record>
<record model="account.account.type" id="data_account_type_receivable">
<field name="name">Receivable</field>
<field name="code">receivable</field>
<field name="close_method">unreconciled</field>
</record>
<record model="account.account.type" id="data_account_type_payable">
<field name="name">Payable</field>
<field name="code">payable</field>
<field name="close_method">unreconciled</field>
</record>
<record model="account.account.type" id="data_account_type_bank">
<field name="name">Bank</field>
<field name="code">bank</field>
<field name="close_method">balance</field>
</record>
<record model="account.account.type" id="data_account_type_cash">
<field name="name">Cash</field>
<field name="code">cash</field>
<field name="close_method">balance</field>
</record>
<record model="account.account.type" id="data_account_type_asset">
<field name="name">Asset</field>
<field name="code">asset</field>
<field name="close_method">balance</field>
</record>
<record model="account.account.type" id="data_account_type_liability">
<field name="name">Liability</field>
<field name="code">liability</field>
<field name="close_method">balance</field>
</record>
<record model="account.account.type" id="data_account_type_income">
<field name="name">Income</field>
<field name="code">income</field>
<field name="close_method">none</field>
</record>
<record model="account.account.type" id="data_account_type_expense">
<field name="name">Expense</field>
<field name="code">expense</field>
<field name="close_method">none</field>
</record>
</data>
</openerp>

View File

@ -23,7 +23,6 @@ import logging
import time
import datetime
from dateutil.relativedelta import relativedelta
from os.path import join as opj
from operator import itemgetter
from tools.translate import _
@ -58,8 +57,6 @@ class account_installer(osv.osv_memory):
'date_start': fields.date('Start Date', required=True),
'date_stop': fields.date('End Date', required=True),
'period': fields.selection([('month', 'Monthly'), ('3months','3 Monthly')], 'Periods', required=True),
'sale_tax': fields.float('Sale Tax(%)'),
'purchase_tax': fields.float('Purchase Tax(%)'),
'company_id': fields.many2one('res.company', 'Company', required=True),
'has_default_company' : fields.boolean('Has Default Company', readonly=True),
}
@ -76,8 +73,6 @@ class account_installer(osv.osv_memory):
'date_start': lambda *a: time.strftime('%Y-01-01'),
'date_stop': lambda *a: time.strftime('%Y-12-31'),
'period': 'month',
'sale_tax': 0.0,
'purchase_tax': 0.0,
'company_id': _default_company,
'has_default_company': _default_has_default_company,
'charts': 'configurable'
@ -100,9 +95,6 @@ class account_installer(osv.osv_memory):
res['fields'][field]['selection'] = cmp_select
return res
def on_change_tax(self, cr, uid, id, tax):
return {'value': {'purchase_tax': tax}}
def on_change_start_date(self, cr, uid, id, start_date=False):
if start_date:
start_date = datetime.datetime.strptime(start_date, "%Y-%m-%d")
@ -118,92 +110,7 @@ class account_installer(osv.osv_memory):
if context is None:
context = {}
fy_obj = self.pool.get('account.fiscalyear')
mod_obj = self.pool.get('ir.model.data')
obj_acc_temp = self.pool.get('account.account.template')
obj_tax_code_temp = self.pool.get('account.tax.code.template')
obj_tax_temp = self.pool.get('account.tax.template')
obj_acc_chart_temp = self.pool.get('account.chart.template')
record = self.browse(cr, uid, ids, context=context)[0]
for res in self.read(cr, uid, ids, context=context):
if record.charts == 'configurable':
fp = tools.file_open(opj('account', 'configurable_account_chart.xml'))
tools.convert_xml_import(cr, 'account', fp, {}, 'init', True, None)
fp.close()
s_tax = (res.get('sale_tax', 0.0))/100
p_tax = (res.get('purchase_tax', 0.0))/100
pur_temp_tax = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_base_purchases')
pur_temp_tax_id = pur_temp_tax and pur_temp_tax[1] or False
pur_temp_tax_paid = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_output')
pur_temp_tax_paid_id = pur_temp_tax_paid and pur_temp_tax_paid[1] or False
sale_temp_tax = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_base_sales')
sale_temp_tax_id = sale_temp_tax and sale_temp_tax[1] or False
sale_temp_tax_paid = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_input')
sale_temp_tax_paid_id = sale_temp_tax_paid and sale_temp_tax_paid[1] or False
chart_temp_ids = obj_acc_chart_temp.search(cr, uid, [('name','=','Configurable Account Chart Template')], context=context)
chart_temp_id = chart_temp_ids and chart_temp_ids[0] or False
if s_tax * 100 > 0.0:
tax_account_ids = obj_acc_temp.search(cr, uid, [('name', '=', 'Tax Received')], context=context)
sales_tax_account_id = tax_account_ids and tax_account_ids[0] or False
vals_tax_code_temp = {
'name': _('TAX %s%%') % (s_tax*100),
'code': _('TAX %s%%') % (s_tax*100),
'parent_id': sale_temp_tax_id
}
new_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_tax_code_temp, context=context)
vals_paid_tax_code_temp = {
'name': _('TAX Received %s%%') % (s_tax*100),
'code': _('TAX Received %s%%') % (s_tax*100),
'parent_id': sale_temp_tax_paid_id
}
new_paid_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_paid_tax_code_temp, context=context)
sales_tax_temp = obj_tax_temp.create(cr, uid, {
'name': _('Sale TAX %s%%') % (s_tax*100),
'amount': s_tax,
'base_code_id': new_tax_code_temp,
'tax_code_id': new_paid_tax_code_temp,
'ref_base_code_id': new_tax_code_temp,
'ref_tax_code_id': new_paid_tax_code_temp,
'type_tax_use': 'sale',
'type': 'percent',
'sequence': 0,
'account_collected_id': sales_tax_account_id,
'account_paid_id': sales_tax_account_id,
'chart_template_id': chart_temp_id,
}, context=context)
if p_tax * 100 > 0.0:
tax_account_ids = obj_acc_temp.search(cr, uid, [('name', '=', 'Tax Paid')], context=context)
purchase_tax_account_id = tax_account_ids and tax_account_ids[0] or False
vals_tax_code_temp = {
'name': _('TAX %s%%') % (p_tax*100),
'code': _('TAX %s%%') % (p_tax*100),
'parent_id': pur_temp_tax_id
}
new_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_tax_code_temp, context=context)
vals_paid_tax_code_temp = {
'name': _('TAX Paid %s%%') % (p_tax*100),
'code': _('TAX Paid %s%%') % (p_tax*100),
'parent_id': pur_temp_tax_paid_id
}
new_paid_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_paid_tax_code_temp, context=context)
purchase_tax_temp = obj_tax_temp.create(cr, uid, {
'name': _('Purchase TAX %s%%') % (p_tax*100),
'amount': p_tax,
'base_code_id': new_tax_code_temp,
'tax_code_id': new_paid_tax_code_temp,
'ref_base_code_id': new_tax_code_temp,
'ref_tax_code_id': new_paid_tax_code_temp,
'type_tax_use': 'purchase',
'type': 'percent',
'sequence': 0,
'account_collected_id': purchase_tax_account_id,
'account_paid_id': purchase_tax_account_id,
'chart_template_id': chart_temp_id,
}, context=context)
if 'date_start' in res and 'date_stop' in res:
f_ids = fy_obj.search(cr, uid, [('date_start', '<=', res['date_start']), ('date_stop', '>=', res['date_stop']), ('company_id', '=', res['company_id'][0])], context=context)
if not f_ids:

View File

@ -66,7 +66,6 @@ import account_change_currency
import account_report_balance_sheet
import account_report_profit_loss
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import account
import l10n_multilang
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name" : "Multi language Chart of Accounts",
"version" : "1.1",
"author" : "OpenERP SA",
"category": 'Localization/Account Charts',
"description": """
* Multi language support for Chart of Accounts, Taxes, Tax Codes , Journals, Accounting Templates,
Analytic Chart of Accounts and Analytic Journals.
* Setup wizard changes
- Copy translations for COA, Tax, Tax Code and Fiscal Position from templates to target objects.
""",
'website': 'http://www.openerp.com',
'init_xml': [],
"depends" : ['account_accountant'],
'update_xml': [
],
'demo_xml': [
],
'installable': True,
'active': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,107 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
#in this file, we mostly add the tag translate=True on existing fields that we now want to be translated
class account_account_template(osv.osv):
_inherit = 'account.account.template'
_columns = {
'name': fields.char('Name', size=128, required=True, select=True, translate=True),
}
account_account_template()
class account_tax(osv.osv):
_inherit = 'account.tax'
_columns = {
'name': fields.char('Tax Name', size=128, required=True, select=True, translate=True),
}
account_tax()
class account_tax_template(osv.osv):
_inherit = 'account.tax.template'
_columns = {
'name': fields.char('Tax Name', size=128, required=True, select=True, translate=True),
}
account_tax_template()
class account_tax_code_template(osv.osv):
_inherit = 'account.tax.code.template'
_columns = {
'name': fields.char('Tax Case Name', size=64, required=True, translate=True),
}
account_tax_code_template()
class account_chart_template(osv.osv):
_inherit = 'account.chart.template'
_columns={
'name': fields.char('Name', size=64, required=True, translate=True),
'spoken_languages': fields.char('Spoken Languages', size=64, help="State here the languages for which the translations of templates could be loaded at the time of installation of this localization module and copied in the final object when generating them from templates. You must provide the language codes separated by ';'"),
}
_order = 'name'
account_chart_template()
class account_fiscal_position(osv.osv):
_inherit = 'account.fiscal.position'
_columns = {
'name': fields.char('Fiscal Position', size=64, required=True, translate=True),
}
account_fiscal_position()
class account_fiscal_position_template(osv.osv):
_inherit = 'account.fiscal.position.template'
_columns = {
'name': fields.char('Fiscal Position Template', size=64, required=True, translate=True),
}
account_fiscal_position_template()
class account_journal(osv.osv):
_inherit = 'account.journal'
_columns = {
'name': fields.char('Journal Name', size=64, required=True, translate=True),
}
account_journal()
class account_analytic_account(osv.osv):
_inherit = 'account.analytic.account'
_columns = {
'name': fields.char('Account Name', size=128, required=True, translate=True),
}
account_analytic_account()
class account_analytic_journal(osv.osv):
_inherit = 'account.analytic.journal'
_columns = {
'name': fields.char('Journal Name', size=64, required=True, translate=True),
}
account_analytic_journal()

View File

@ -0,0 +1,156 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
import os
from tools.translate import _
import netsvc
logger=netsvc.Logger()
class wizard_multi_charts_accounts(osv.osv_memory):
"""
Change wizard that a new account chart for a company.
* Add option to install languages during the setup
* Copy translations for COA, Tax, Tax Code and Fiscal Position from templates to target objects.
"""
_inherit = 'wizard.multi.charts.accounts'
def process_translations(self, cr, uid, langs, in_obj, in_field, in_ids, out_obj, out_ids, force_write=False, context=None):
"""
This method copies translations values of templates into new Accounts/Taxes/Journals for languages selected
:param cr: A database cursor
:param uid: ID of the user currently logged in
:param langs: List of languages to load for new records
:param in_field: Name of the translatable field of source templates
:param in_obj: Name of source object of templates.
:param in_ids: List of ids of source object
:param out_obj: Destination object for which translation is to be copied
:param out_ids: List of ids of destination object
:param force_write: boolean that depicts if we need to create a translation OR simply replace the actual value
with the translation in the uid's language by doing a write (in case it's TRUE)
:param context: usual context information. May contain the key 'lang', which is the language of the user running
the wizard, that will be used if force_write is True
:return: True
"""
if context is None:
context = {}
src = {}
xlat_obj = self.pool.get('ir.translation')
#find the source from Account Template
for x in in_obj.browse(cr, uid, in_ids):
src.update({x.id: x.name})
for lang in langs:
#find the value from Translation
value = xlat_obj._get_ids(cr, uid, in_obj._name + ',' + in_field, 'model', lang, in_ids)
for j in range(len(in_ids)):
in_id = in_ids[j]
if value[in_id]:
if not force_write:
#copy Translation from Source to Destination object
xlat_obj.create(cr, uid, {
'name': out_obj._name + ',' + in_field,
'type': 'model',
'res_id': out_ids[j],
'lang': lang,
'src': src[in_id],
'value': value[in_id],
})
else:
#replace the value in the destination object only if it's the user lang
if context.get('lang') == lang:
self.pool.get(out_obj._name).write(cr, uid, out_ids[j], {in_field: value[in_id]})
else:
logger.notifyChannel('addons.'+self._name, netsvc.LOG_WARNING,
'Language: %s. Translation from template: there is no translation available for %s!' %(lang, src[in_id]))#out_obj._name))
return True
def execute(self, cr, uid, ids, context=None):
res = super(wizard_multi_charts_accounts, self).execute(cr, uid, ids, context=context)
obj_multi = self.browse(cr, uid, ids[0], context=context)
company_id = obj_multi.company_id.id
# load languages
langs = []
res_lang_obj = self.pool.get('res.lang')
installed_lang_ids = res_lang_obj.search(cr, uid, [])
installed_langs = [x.code for x in res_lang_obj.browse(cr, uid, installed_lang_ids, context=context)]
if obj_multi.chart_template_id.spoken_languages:
for lang in obj_multi.chart_template_id.spoken_languages.split(';'):
if lang not in installed_langs:
# the language is not installed, so we don't need to load its translations
continue
else:
# the language was already installed, so the po files have been loaded at the installation time
# and now we need to copy the translations of templates to the right objects
langs.append(lang)
if langs:
# write account.account translations in the real COA
self._process_accounts_translations(cr, uid, obj_multi, company_id, langs, 'name', context=context)
# copy account.tax.code translations
self._process_tax_codes_translations(cr, uid, obj_multi, company_id, langs, 'name', context=context)
# copy account.tax translations
self._process_taxes_translations(cr, uid, obj_multi, company_id, langs, 'name', context=context)
# copy account.fiscal.position translations
self._process_fiscal_pos_translations(cr, uid, obj_multi, company_id, langs, 'name', context=context)
return res
def _process_accounts_translations(self, cr, uid, obj_multi, company_id, langs, field, context=None):
obj_acc_template = self.pool.get('account.account.template')
obj_acc = self.pool.get('account.account')
acc_template_root_id = obj_multi.chart_template_id.account_root_id.id
acc_root_id = obj_acc.search(cr, uid, [('company_id', '=', company_id), ('parent_id', '=', None)])[0]
in_ids = obj_acc_template.search(cr, uid, [('id', 'child_of', [acc_template_root_id])], order='id')[1:]
out_ids = obj_acc.search(cr, uid, [('id', 'child_of', [acc_root_id])], order='id')[1:]
return self.process_translations(cr, uid, langs, obj_acc_template, field, in_ids, obj_acc, out_ids, force_write=True, context=context)
def _process_tax_codes_translations(self, cr, uid, obj_multi, company_id, langs, field, context=None):
obj_tax_code_template = self.pool.get('account.tax.code.template')
obj_tax_code = self.pool.get('account.tax.code')
tax_code_template_root_id = obj_multi.chart_template_id.tax_code_root_id.id
tax_code_root_id = obj_tax_code.search(cr, uid, [('company_id', '=', company_id), ('parent_id', '=', None)])[0]
in_ids = obj_tax_code_template.search(cr, uid, [('id', 'child_of', [tax_code_template_root_id])], order='id')[1:]
out_ids = obj_tax_code.search(cr, uid, [('id', 'child_of', [tax_code_root_id])], order='id')[1:]
return self.process_translations(cr, uid, langs, obj_tax_code_template, field, in_ids, obj_tax_code, out_ids, force_write=False, context=context)
def _process_taxes_translations(self, cr, uid, obj_multi, company_id, langs, field, context=None):
obj_tax_template = self.pool.get('account.tax.template')
obj_tax = self.pool.get('account.tax')
in_ids = sorted([x.id for x in obj_multi.chart_template_id.tax_template_ids])
out_ids = obj_tax.search(cr, uid, [('company_id', '=', company_id)], order='id')
return self.process_translations(cr, uid, langs, obj_tax_template, field, in_ids, obj_tax, out_ids, force_write=False, context=context)
def _process_fiscal_pos_translations(self, cr, uid, obj_multi, company_id, langs, field, context=None):
obj_fiscal_position_template = self.pool.get('account.fiscal.position.template')
obj_fiscal_position = self.pool.get('account.fiscal.position')
in_ids = obj_fiscal_position_template.search(cr, uid, [('chart_template_id', '=', obj_multi.chart_template_id.id)], order='id')
out_ids = obj_fiscal_position.search(cr, uid, [('company_id', '=', company_id)], order='id')
return self.process_translations(cr, uid, langs, obj_fiscal_position_template, field, in_ids, obj_fiscal_position, out_ids, force_write=False, context=context)
wizard_multi_charts_accounts()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: