From 3161713bea39e3dc1458ab1a869b9a956494f2af Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 15 Jul 2011 18:12:38 +0530 Subject: [PATCH 001/115] [ADD]l10n_multilang:One of the existing problem of localization modules is that it doesnot allow you to translate the objects name So Add the tags translate=True on journal name, account name, account type ,account Tax, Templates.. bzr revid: ron@tinyerp.com-20110715124238-0pm6xakc7io3p3mg --- addons/l10n_multilang/__init__.py | 24 ++++++ addons/l10n_multilang/__openerp__.py | 49 +++++++++++ addons/l10n_multilang/account.py | 117 +++++++++++++++++++++++++++ 3 files changed, 190 insertions(+) create mode 100644 addons/l10n_multilang/__init__.py create mode 100644 addons/l10n_multilang/__openerp__.py create mode 100644 addons/l10n_multilang/account.py diff --git a/addons/l10n_multilang/__init__.py b/addons/l10n_multilang/__init__.py new file mode 100644 index 00000000000..0aea333e9a9 --- /dev/null +++ b/addons/l10n_multilang/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import account + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/l10n_multilang/__openerp__.py b/addons/l10n_multilang/__openerp__.py new file mode 100644 index 00000000000..e854aab8221 --- /dev/null +++ b/addons/l10n_multilang/__openerp__.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +{ + "name" : "Belgium - Multi language Chart of Accounts (en/nl/fr)", + "version" : "1.1", + "author" : "OpenERP SA", + "category": 'Localization/Account Charts', + "description": """ + Belgian localisation (on top of l10n_be): + * Multilanguage support (en/nl/fr) for Chart of Accounts, Taxes, Tax Codes and Journals + * Multilingual accounting templates + * Multilanguage support Analytic Chart of Accounts and Analytic Journals + * Update partner titles for commonly used legal entities + * Add constraint to ensure unique Tax Code per Company + * Setup wizard changes + - Copy translations for CoA, Tax, Tax Code and Fiscal Position from templates to target objects + - Add options to install the nl and fr languages during the setup + - Generate Financial Journals from the templates + """, + 'website': 'http://www.openerp.com', + 'init_xml': [], + "depends" : ['account_accountant','l10n_be'], + 'update_xml': [ + ], + 'demo_xml': [ + ], + 'installable': True, + 'active': False, +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_multilang/account.py b/addons/l10n_multilang/account.py new file mode 100644 index 00000000000..46e5a2d63e7 --- /dev/null +++ b/addons/l10n_multilang/account.py @@ -0,0 +1,117 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + + +from osv import fields, osv +from tools.translate import _ + + +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_account(osv.osv): + _inherit = 'account.account' + _columns = { + 'name': fields.char('Name', size=128, required=True, select=True, translate=True), + } +account_account() + + +class account_tax_code(osv.osv): + _inherit = 'account.tax.code' + _sql_constraints = [ + ('code_company_uniq', 'unique (code,company_id)', 'The code of the Tax Case must be unique per company !') + ] +account_tax_code() + + +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), + 'bank_from_template':fields.boolean('Banks/Cash from Template', help="Generate Bank/Cash accounts and journals from the Templates."), + } + _defaults = { + 'bank_from_template': False, + } + _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() From 57507520a1ad208e7fe17fdba6cc09143bbc9176 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 18 Jul 2011 10:02:59 +0530 Subject: [PATCH 002/115] [IMP]Account:remove Account code unique constraint bzr revid: ron@tinyerp.com-20110718043259-0o9qvuv9sj3hiceu --- addons/l10n_multilang/account.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/addons/l10n_multilang/account.py b/addons/l10n_multilang/account.py index 46e5a2d63e7..f0583c13b53 100644 --- a/addons/l10n_multilang/account.py +++ b/addons/l10n_multilang/account.py @@ -40,14 +40,6 @@ class account_account(osv.osv): account_account() -class account_tax_code(osv.osv): - _inherit = 'account.tax.code' - _sql_constraints = [ - ('code_company_uniq', 'unique (code,company_id)', 'The code of the Tax Case must be unique per company !') - ] -account_tax_code() - - class account_tax_template(osv.osv): _inherit = 'account.tax.template' _columns = { From 6c4c1c78fd5aaf7eea441d0054b1021e96ac02e9 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 18 Jul 2011 18:17:15 +0530 Subject: [PATCH 003/115] [IMP]Account:Fixed=>Module name and description,remove dependency of l10n_be,remove unnessasary variable,missing object bzr revid: ron@tinyerp.com-20110718124715-b4rwn30rh3mphef0 --- addons/l10n_multilang/__openerp__.py | 8 ++++---- addons/l10n_multilang/account.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/l10n_multilang/__openerp__.py b/addons/l10n_multilang/__openerp__.py index e854aab8221..b2b4c563dde 100644 --- a/addons/l10n_multilang/__openerp__.py +++ b/addons/l10n_multilang/__openerp__.py @@ -20,25 +20,25 @@ ############################################################################## { - "name" : "Belgium - Multi language Chart of Accounts (en/nl/fr)", + "name" : "Belgium - Multi language Chart of Accounts", "version" : "1.1", "author" : "OpenERP SA", "category": 'Localization/Account Charts', "description": """ Belgian localisation (on top of l10n_be): - * Multilanguage support (en/nl/fr) for Chart of Accounts, Taxes, Tax Codes and Journals + * Multilanguage support for Chart of Accounts, Taxes, Tax Codes and Journals * Multilingual accounting templates * Multilanguage support Analytic Chart of Accounts and Analytic Journals * Update partner titles for commonly used legal entities * Add constraint to ensure unique Tax Code per Company * Setup wizard changes - Copy translations for CoA, Tax, Tax Code and Fiscal Position from templates to target objects - - Add options to install the nl and fr languages during the setup + - Add options to install languages during the setup - Generate Financial Journals from the templates """, 'website': 'http://www.openerp.com', 'init_xml': [], - "depends" : ['account_accountant','l10n_be'], + "depends" : ['account_accountant'], 'update_xml': [ ], 'demo_xml': [ diff --git a/addons/l10n_multilang/account.py b/addons/l10n_multilang/account.py index f0583c13b53..f4d2c1bb78d 100644 --- a/addons/l10n_multilang/account.py +++ b/addons/l10n_multilang/account.py @@ -40,6 +40,14 @@ class account_account(osv.osv): account_account() +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 = { @@ -60,10 +68,6 @@ class account_chart_template(osv.osv): _inherit = 'account.chart.template' _columns={ 'name': fields.char('Name', size=64, required=True, translate=True), - 'bank_from_template':fields.boolean('Banks/Cash from Template', help="Generate Bank/Cash accounts and journals from the Templates."), - } - _defaults = { - 'bank_from_template': False, } _order = 'name' account_chart_template() From 2ca78132ea89f7b0502a75056988981ecd93d344 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 18 Jul 2011 18:55:29 +0530 Subject: [PATCH 004/115] [IMP]Account:Improvement in Desription bzr revid: ron@tinyerp.com-20110718132529-9o3vusrrjzqtmn9q --- addons/l10n_multilang/__openerp__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/l10n_multilang/__openerp__.py b/addons/l10n_multilang/__openerp__.py index b2b4c563dde..b4391e2c8f0 100644 --- a/addons/l10n_multilang/__openerp__.py +++ b/addons/l10n_multilang/__openerp__.py @@ -25,16 +25,12 @@ "author" : "OpenERP SA", "category": 'Localization/Account Charts', "description": """ - Belgian localisation (on top of l10n_be): * Multilanguage support for Chart of Accounts, Taxes, Tax Codes and Journals - * Multilingual accounting templates + * Multilanguage accounting templates * Multilanguage support Analytic Chart of Accounts and Analytic Journals - * Update partner titles for commonly used legal entities - * Add constraint to ensure unique Tax Code per Company * Setup wizard changes - Copy translations for CoA, Tax, Tax Code and Fiscal Position from templates to target objects - Add options to install languages during the setup - - Generate Financial Journals from the templates """, 'website': 'http://www.openerp.com', 'init_xml': [], From d6b0a13e14070d92cc2ce36958c1e8e4e16d0b28 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 18 Jul 2011 19:08:22 +0530 Subject: [PATCH 005/115] [IMP]Account:Improvments in Description bzr revid: ron@tinyerp.com-20110718133822-fgz05pasp03im1jz --- addons/l10n_multilang/__openerp__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/l10n_multilang/__openerp__.py b/addons/l10n_multilang/__openerp__.py index b4391e2c8f0..a63e853ae10 100644 --- a/addons/l10n_multilang/__openerp__.py +++ b/addons/l10n_multilang/__openerp__.py @@ -20,16 +20,15 @@ ############################################################################## { - "name" : "Belgium - Multi language Chart of Accounts", + "name" : "Multi language Chart of Accounts", "version" : "1.1", "author" : "OpenERP SA", "category": 'Localization/Account Charts', "description": """ - * Multilanguage support for Chart of Accounts, Taxes, Tax Codes and Journals - * Multilanguage accounting templates - * Multilanguage support Analytic Chart of Accounts and Analytic Journals + * Multilanguage 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 + - Copy translations for COA, Tax, Tax Code and Fiscal Position from templates to target objects - Add options to install languages during the setup """, 'website': 'http://www.openerp.com', From 028375c83f11186961a75ca0d88dbb55f0cc9942 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 20 Jul 2011 11:09:06 +0530 Subject: [PATCH 006/115] [IMP]Account:Improvement in wizard.multi.charts.accounts all fields have default used that is converted to default_get method bzr revid: ron@tinyerp.com-20110720053906-px9u1o3sfz4phq4q --- addons/account/account.py | 62 +++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index aced4041f13..a44ca2a8b5b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2650,44 +2650,36 @@ class wizard_multi_charts_accounts(osv.osv_memory): res['value']["purchase_tax"] = purchase_tax_ids and purchase_tax_ids[0] or False return res - def _get_purchase_tax(self, cr, uid, context=None): + + def default_get(self, cr, uid, fields, context=None): + res = super(wizard_multi_charts_accounts, self).default_get(cr, uid, fields, context=context) + tax_templ_obj = self.pool.get('account.tax.template') + + if 'bank_accounts_id' in fields: + res.update({'bank_accounts_id': [{'acc_name': _('Current'), 'account_type': 'bank'}, + {'acc_name': _('Deposit'), 'account_type': 'bank'}, + {'acc_name': _('Cash'), 'account_type': 'cash'}]}) + if 'company_id' in fields: + res.update({'company_id': self.pool.get('res.users').browse(cr, uid, [uid], context=context)[0].company_id.id}) + if 'code_digits' in fields: + res.update({'code_digits': 6}) + if 'seq_journal' in fields: + res.update({'seq_journal': True}) + ids = self.pool.get('account.chart.template').search(cr, uid, [], context=context) if ids: - chart_template_id = ids[0] - purchase_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" - , "=", chart_template_id), ('type_tax_use', 'in', ('purchase','all'))], order="sequence") - return purchase_tax_ids and purchase_tax_ids[0] or False - return False + sale_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id" + , "=", ids[0]), ('type_tax_use', 'in', ('sale','all'))], order="sequence") + purchase_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id" + , "=", ids[0]), ('type_tax_use', 'in', ('purchase','all'))], order="sequence") + if 'chart_template_id' in fields: + res.update({'chart_template_id':ids[0]}) + if 'sale_tax' in fields: + res.update({'sale_tax': sale_tax_ids and sale_tax_ids[0] or False}) + if 'purchase_tax' in fields: + res.update({'purchase_tax': purchase_tax_ids and purchase_tax_ids[0] or False}) - def _get_sale_tax(self, cr, uid, context=None): - ids = self.pool.get('account.chart.template').search(cr, uid, [], context=context) - if ids: - chart_template_id = ids[0] - sale_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" - , "=", chart_template_id), ('type_tax_use', 'in', ('sale','all'))], order="sequence") - return sale_tax_ids and sale_tax_ids[0] or False - return False - - def _get_chart(self, cr, uid, context=None): - ids = self.pool.get('account.chart.template').search(cr, uid, [], context=context) - if ids: - return ids[0] - return False - - def _get_default_accounts(self, cr, uid, context=None): - return [{'acc_name': _('Current'),'account_type':'bank'}, - {'acc_name': _('Deposit'),'account_type':'bank'}, - {'acc_name': _('Cash'),'account_type':'cash'}] - - _defaults = { - 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, [uid], c)[0].company_id.id, - 'chart_template_id': _get_chart, - 'bank_accounts_id': _get_default_accounts, - 'sale_tax': _get_sale_tax, - 'purchase_tax': _get_purchase_tax, - 'code_digits': 6, - 'seq_journal': True - } + return res def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(wizard_multi_charts_accounts, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) From d07923239f01f8d745ec092b3050485968beea17 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 20 Jul 2011 11:54:43 +0530 Subject: [PATCH 007/115] [IMP]Account:optimize code of default_get method bzr revid: ron@tinyerp.com-20110720062443-cn65ey46czpd8v54 --- addons/account/account.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index a44ca2a8b5b..7e413f7a333 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2668,15 +2668,15 @@ class wizard_multi_charts_accounts(osv.osv_memory): ids = self.pool.get('account.chart.template').search(cr, uid, [], context=context) if ids: - sale_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id" - , "=", ids[0]), ('type_tax_use', 'in', ('sale','all'))], order="sequence") - purchase_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id" - , "=", ids[0]), ('type_tax_use', 'in', ('purchase','all'))], order="sequence") if 'chart_template_id' in fields: - res.update({'chart_template_id':ids[0]}) + res.update({'chart_template_id': ids[0]}) if 'sale_tax' in fields: + sale_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id" + , "=", ids[0]), ('type_tax_use', 'in', ('sale','all'))], order="sequence") res.update({'sale_tax': sale_tax_ids and sale_tax_ids[0] or False}) if 'purchase_tax' in fields: + purchase_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id" + , "=", ids[0]), ('type_tax_use', 'in', ('purchase','all'))], order="sequence") res.update({'purchase_tax': purchase_tax_ids and purchase_tax_ids[0] or False}) return res From 7daeb8c47ef60c94dbc7c557dda8d92efa360f4b Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Thu, 21 Jul 2011 18:19:11 +0530 Subject: [PATCH 008/115] [IMP]l10n_multilang:Change the Multi wizard configuaration view and Add Language Field on wizard bzr revid: ron@tinyerp.com-20110721124911-h5tyniz8nufsqu1c --- addons/l10n_multilang/__init__.py | 4 +- addons/l10n_multilang/__openerp__.py | 8 +- addons/l10n_multilang/l10n_multilang.py | 44 +++++ addons/l10n_multilang/l10n_multilang.xml | 32 ++++ addons/l10n_multilang/l10n_multilang_test.xml | 161 ++++++++++++++++++ 5 files changed, 244 insertions(+), 5 deletions(-) create mode 100644 addons/l10n_multilang/l10n_multilang.py create mode 100644 addons/l10n_multilang/l10n_multilang.xml create mode 100644 addons/l10n_multilang/l10n_multilang_test.xml diff --git a/addons/l10n_multilang/__init__.py b/addons/l10n_multilang/__init__.py index 0aea333e9a9..446f3beb668 100644 --- a/addons/l10n_multilang/__init__.py +++ b/addons/l10n_multilang/__init__.py @@ -20,5 +20,5 @@ ############################################################################## import account - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +import l10n_multilang +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_multilang/__openerp__.py b/addons/l10n_multilang/__openerp__.py index e2c754adb4b..481abb1bf65 100644 --- a/addons/l10n_multilang/__openerp__.py +++ b/addons/l10n_multilang/__openerp__.py @@ -25,16 +25,18 @@ "author" : "OpenERP SA", "category": 'Localization/Account Charts', "description": """ - * Multilanguage support for Chart of Accounts, Taxes, Tax Codes , Journals, Accounting Templates, - Analytic Chart of Accounts and Analytic Journals + * 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 + - Copy translations for COA, Tax, Tax Code and Fiscal Position from templates to target objects. - Add option to install languages during the setup. """, 'website': 'http://www.openerp.com', 'init_xml': [], "depends" : ['account_accountant'], 'update_xml': [ + 'l10n_multilang.xml', + 'l10n_multilang_test.xml' ], 'demo_xml': [ ], diff --git a/addons/l10n_multilang/l10n_multilang.py b/addons/l10n_multilang/l10n_multilang.py new file mode 100644 index 00000000000..f9fab08c216 --- /dev/null +++ b/addons/l10n_multilang/l10n_multilang.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + + +from osv import fields, osv + + +class wizard_multi_charts_accounts(osv.osv_memory): + """ + Change wizard that a new account chart for a company. + * load Default languages + * Replace creation of financial accounts by copy from template. + This change results in adherence to Belgian MAR numbering scheme for cash accounts. + * Create financial journals for each account of type liquidity + """ + _inherit = 'wizard.multi.charts.accounts' + + _columns = { + 'lang_ids': fields.many2many('res.lang', 'res_lang_type_rel', 'wizard_id', 'lang_id', 'Language'), + 'bank_from_template': fields.boolean('Banks/Cash from Template', + help="If True then Generate Bank/Cash accounts and journals from the Templates.", readonly=True), + } + +wizard_multi_charts_accounts() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_multilang/l10n_multilang.xml b/addons/l10n_multilang/l10n_multilang.xml new file mode 100644 index 00000000000..990407f9462 --- /dev/null +++ b/addons/l10n_multilang/l10n_multilang.xml @@ -0,0 +1,32 @@ + + + + + + 25 + onskip + + + + view.wizard.multi.chart + wizard.multi.charts.accounts + + + + + + + + + + + + {'invisible': [('bank_from_template', '=', False)]} + + + + + + + + diff --git a/addons/l10n_multilang/l10n_multilang_test.xml b/addons/l10n_multilang/l10n_multilang_test.xml new file mode 100644 index 00000000000..b91405cf27f --- /dev/null +++ b/addons/l10n_multilang/l10n_multilang_test.xml @@ -0,0 +1,161 @@ + + + + + + + + + special + + + + + + + Receivable + receivable + income + unreconciled + + + + Payable + payable + expense + unreconciled + + + + Asset View + asset + asset + + + + View + view + none + + + + Liability View + liability + liability + + + + Asset View + asset + asset + + + + + + Chart of Account A + 0 + view + + + + + + Balance Sheet + A00 + view + + + + + + + Profit and Loss + A01 + view + + + + + + + A0011 + Bank Account + + view + + + + + + Tax Template Root A + + + + Tax 001 A + + + + + Tax 002 A + + + + + + + Assets B + B00012 + view + + + + + + + Liabilities B + B00014 + view + + + + + + + Income B + B00021 + view + + + + + + + Expense B + B00024 + view + + + + + + + + + Demo Chart A + + + + + + + Demo Chart B + + + + + + + + + From a21478fde26e953e1ef84fa50a7925c698e63132 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 22 Jul 2011 12:37:41 +0530 Subject: [PATCH 009/115] [IMP]Account:Add parent_id field in Account.chart.template and Bank Account,Root Account ,Root Tax required when there is no parent bzr revid: ron@tinyerp.com-20110722070741-dxfzs55wlhgoq4wz --- addons/account/account.py | 1 + addons/account/account_view.xml | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 7e413f7a333..216c48ddb1b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2475,6 +2475,7 @@ class account_chart_template(osv.osv): _columns={ 'name': fields.char('Name', size=64, required=True), + 'parent_id': fields.many2one('account.chart.template', 'Parent Chart Template'), 'account_root_id': fields.many2one('account.account.template','Root Account',required=True,domain=[('parent_id','=',False)]), 'tax_code_root_id': fields.many2one('account.tax.code.template','Root Tax Code',required=True,domain=[('parent_id','=',False)]), 'tax_template_ids': fields.one2many('account.tax.template', 'chart_template_id', 'Tax Template List', help='List of all the taxes that have to be installed by the wizard'), diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index d3d54a51918..aa0c7ae0c87 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -2141,9 +2141,10 @@
- - - + + + + From b5f41c1cc7e8b645d86e0accc4ac6f4d86d262f9 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 22 Jul 2011 14:04:14 +0530 Subject: [PATCH 010/115] [IMP] account: l10n_multilang: 1)Get Default language on Language field 2)onchange on Template at that time languages change accordingly bzr revid: ron@tinyerp.com-20110722083414-8qzizw2fe1a8rxol --- addons/l10n_multilang/l10n_multilang.py | 32 ++++++++++++++++++++++++ addons/l10n_multilang/l10n_multilang.xml | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/addons/l10n_multilang/l10n_multilang.py b/addons/l10n_multilang/l10n_multilang.py index f9fab08c216..0c66ca387d6 100644 --- a/addons/l10n_multilang/l10n_multilang.py +++ b/addons/l10n_multilang/l10n_multilang.py @@ -33,6 +33,38 @@ class wizard_multi_charts_accounts(osv.osv_memory): """ _inherit = 'wizard.multi.charts.accounts' + def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None): + res = super(wizard_multi_charts_accounts, self).onchange_chart_template_id(cr, uid, ids, chart_template_id, context=context) + installed_lang = self.get_lang(cr, uid, chart_template_id, context=context) + res['value'].update({'lang_ids': installed_lang}) + return res + + def get_lang(self, cr, uid, template_id=False, context=None): + installed_lang = [] + if template_id: + cr.execute("SELECT module from ir_model_data where model='account.chart.template' and res_id=%s" % (template_id)) + modulename = cr.fetchone() + modulename = modulename and modulename[0] or False + if modulename: + import os + module_obj = self.pool.get('ir.module.module') + module_id = module_obj.search(cr, uid, [('name', '=', modulename)], context=context) + module = module_obj.browse(cr, uid, module_id, context=context)[0] + dirpath = module_obj._translations_subdir(module) + if dirpath: + po_files = os.listdir(dirpath) + for po in po_files: + lang_id = self.pool.get('res.lang').search(cr, uid, [('code', 'ilike', '%s' % (po.split('.')[0])), ('translatable', '=', True)], context=context) + if lang_id: + installed_lang.append(lang_id[0]) + return installed_lang + + def default_get(self, cr, uid, fields, context=None): + res = super(wizard_multi_charts_accounts, self).default_get(cr, uid, fields, context=context) + installed_lang = self.get_lang(cr, uid, res.get('chart_template_id'), context=context) + res.update({'lang_ids': installed_lang, 'bank_accounts_id': []}) + return res + _columns = { 'lang_ids': fields.many2many('res.lang', 'res_lang_type_rel', 'wizard_id', 'lang_id', 'Language'), 'bank_from_template': fields.boolean('Banks/Cash from Template', diff --git a/addons/l10n_multilang/l10n_multilang.xml b/addons/l10n_multilang/l10n_multilang.xml index 990407f9462..7affdb46323 100644 --- a/addons/l10n_multilang/l10n_multilang.xml +++ b/addons/l10n_multilang/l10n_multilang.xml @@ -14,7 +14,7 @@ - + From 4d882e63e19df8558f65f1bc42399d0d1671b8e1 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 22 Jul 2011 14:29:17 +0530 Subject: [PATCH 011/115] [IMP]: account: l10n fullness and inheritancy:Remove required=True from account_root_id,bank_account_view_id,tax_code_root_id and also optimize the code bzr revid: ron@tinyerp.com-20110722085917-rfnb8w8ycz0otuer --- addons/account/account.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 216c48ddb1b..09e61a8325a 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2476,19 +2476,19 @@ class account_chart_template(osv.osv): _columns={ 'name': fields.char('Name', size=64, required=True), 'parent_id': fields.many2one('account.chart.template', 'Parent Chart Template'), - 'account_root_id': fields.many2one('account.account.template','Root Account',required=True,domain=[('parent_id','=',False)]), - 'tax_code_root_id': fields.many2one('account.tax.code.template','Root Tax Code',required=True,domain=[('parent_id','=',False)]), + 'account_root_id': fields.many2one('account.account.template', 'Root Account', domain=[('parent_id','=',False)]), + 'tax_code_root_id': fields.many2one('account.tax.code.template', 'Root Tax Code', domain=[('parent_id','=',False)]), 'tax_template_ids': fields.one2many('account.tax.template', 'chart_template_id', 'Tax Template List', help='List of all the taxes that have to be installed by the wizard'), - 'bank_account_view_id': fields.many2one('account.account.template','Bank Account',required=True), - 'property_account_receivable': fields.many2one('account.account.template','Receivable Account'), - 'property_account_payable': fields.many2one('account.account.template','Payable Account'), - 'property_account_expense_categ': fields.many2one('account.account.template','Expense Category Account'), - 'property_account_income_categ': fields.many2one('account.account.template','Income Category Account'), - 'property_account_expense': fields.many2one('account.account.template','Expense Account on Product Template'), - 'property_account_income': fields.many2one('account.account.template','Income Account on Product Template'), + 'bank_account_view_id': fields.many2one('account.account.template', 'Bank Account'), + 'property_account_receivable': fields.many2one('account.account.template', 'Receivable Account'), + 'property_account_payable': fields.many2one('account.account.template', 'Payable Account'), + 'property_account_expense_categ': fields.many2one('account.account.template', 'Expense Category Account'), + 'property_account_income_categ': fields.many2one('account.account.template', 'Income Category Account'), + 'property_account_expense': fields.many2one('account.account.template', 'Expense Account on Product Template'), + 'property_account_income': fields.many2one('account.account.template', 'Income Account on Product Template'), 'property_reserve_and_surplus_account': fields.many2one('account.account.template', 'Reserve and Profit/Loss Account', domain=[('type', '=', 'payable')], help='This Account is used for transferring Profit/Loss(If It is Profit: Amount will be added, Loss: Amount will be deducted.), Which is calculated from Profilt & Loss Report'), - 'property_account_income_opening': fields.many2one('account.account.template','Opening Entries Income Account'), - 'property_account_expense_opening': fields.many2one('account.account.template','Opening Entries Expense Account'), + 'property_account_income_opening': fields.many2one('account.account.template', 'Opening Entries Income Account'), + 'property_account_expense_opening': fields.many2one('account.account.template', 'Opening Entries Expense Account'), } account_chart_template() From aa245d62fa3fc461ecc7dcc0fa5241a7f69b5920 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Fri, 22 Jul 2011 16:24:04 +0530 Subject: [PATCH 012/115] [REM]: l10n_multilang: Removed undefined onchange on COA template wizard bzr revid: rpa@tinyerp.com-20110722105404-4cxq8vn97atmu0jm --- addons/l10n_multilang/l10n_multilang.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_multilang/l10n_multilang.xml b/addons/l10n_multilang/l10n_multilang.xml index e4809aaa27f..7ad10f487db 100644 --- a/addons/l10n_multilang/l10n_multilang.xml +++ b/addons/l10n_multilang/l10n_multilang.xml @@ -9,7 +9,7 @@ - + From f9826a7f3c6c6afdaf9bc8a1c0d9d9ffd27af387 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 25 Jul 2011 11:09:34 +0530 Subject: [PATCH 013/115] [IMP] account: l10n_multilang: Copy Translation from Account Template to Destination object bzr revid: ron@tinyerp.com-20110725053934-zcbki8m3wyt4ilux --- addons/l10n_multilang/l10n_multilang.py | 77 ++++++++++++++++++++++++ addons/l10n_multilang/l10n_multilang.xml | 5 ++ 2 files changed, 82 insertions(+) diff --git a/addons/l10n_multilang/l10n_multilang.py b/addons/l10n_multilang/l10n_multilang.py index 85a19c9fd08..e8e700bd1f6 100644 --- a/addons/l10n_multilang/l10n_multilang.py +++ b/addons/l10n_multilang/l10n_multilang.py @@ -21,6 +21,9 @@ from osv import fields, osv import os +import netsvc + +logger=netsvc.Logger() class wizard_multi_charts_accounts(osv.osv_memory): """ @@ -32,6 +35,80 @@ class wizard_multi_charts_accounts(osv.osv_memory): """ _inherit = 'wizard.multi.charts.accounts' + def copy_translation(self, cr, uid, langs, in_obj, in_field, in_ids, out_obj, out_ids): + done = False + error = False + xlat_obj = self.pool.get('ir.translation') + while not done: + #compare template with Accounts + if len(in_ids) != len(out_ids): + logger.notifyChannel('addons.'+self._name, netsvc.LOG_ERROR, + 'generate translations from template for %s failed (error 1)!' % out_obj._name) + error = True + break + #copy Translation from Source to Destination object + for lang in langs: + cr.execute("SELECT src, value FROM ir_translation " \ + "WHERE name=%s AND type='model' AND lang=%s AND res_id IN %s " \ + "ORDER by res_id", + (in_obj._name + ',' + in_field, lang, tuple(in_ids))) + xlats = cr.fetchall() + #IF there is no Translation Available or missing some Translation + if len(xlats) != len(out_ids): + logger.notifyChannel('addons.'+self._name, netsvc.LOG_ERROR, + 'There is no Translation available for template %s !' % out_obj._name) + error = True + break + for i in range(len(out_ids)): + src = xlats[i][0] + value = xlats[i][1] + out_record = out_obj.browse(cr, uid, out_ids[i]) + #compare with source to destination object name + if getattr(out_record, in_field) != src: + logger.notifyChannel('addons.'+self._name, netsvc.LOG_ERROR, + 'generate translations from template for %s failed (error 3)!' % out_obj._name) + error = True + break + #Copy Translation + xlat_obj.create(cr, uid, { + 'name': out_obj._name + ',' + in_field, + 'type': 'model', + 'res_id': out_record.id, + 'lang': lang, + 'src': src, + 'value': value, + }) + done = True + if error: + raise osv.except_osv(_('Warning!'), + _('The generation of translations from the template for %s failed!' % out_obj._name)) + + def execute(self, cr, uid, ids, context=None): + super(wizard_multi_charts_accounts, self).execute(cr, uid, ids, context=context) + obj_multi = self.browse(cr, uid, ids[0], context=context) + obj_mod = self.pool.get('ir.module.module') + obj_acc_template = self.pool.get('account.account.template') + obj_acc = self.pool.get('account.account') + obj_data = self.pool.get('ir.model.data') + + company_id = obj_multi.company_id.id + 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] + + # load languages + langs = [] + for lang in obj_multi.lang_ids: + langs.append(lang.code) + installed_mids = obj_mod.search(cr, uid, [('state', '=', 'installed')]) + for lang in langs: + obj_mod.update_translations(cr, uid, installed_mids, lang) + + # copy account.account translations + in_field = 'name' + 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:] + self.copy_translation(cr, uid, langs, obj_acc_template, in_field, in_ids, obj_acc, out_ids) + def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None): res = super(wizard_multi_charts_accounts, self).onchange_chart_template_id(cr, uid, ids, chart_template_id, context=context) installed_lang = self.get_lang(cr, uid, chart_template_id, context=context) diff --git a/addons/l10n_multilang/l10n_multilang.xml b/addons/l10n_multilang/l10n_multilang.xml index 7ad10f487db..71563ce526c 100644 --- a/addons/l10n_multilang/l10n_multilang.xml +++ b/addons/l10n_multilang/l10n_multilang.xml @@ -1,6 +1,11 @@ + + + 25 + onskip + view.wizard.multi.chart From 06726846c4c819cfeafacf6acd9764c153afce2d Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Tue, 26 Jul 2011 15:25:18 +0530 Subject: [PATCH 014/115] [ADD] account: l10n_multilang: 1)Add wizard=>to saw warning message 2)Optimize code of copy_translation method 3)checked indentation problems 4)remove Unused variable 5)Improved docstring bzr revid: ron@tinyerp.com-20110726095518-1irmhd3xr8mwfaui --- addons/l10n_multilang/l10n_multilang.py | 141 +++++++++++++---------- addons/l10n_multilang/l10n_multilang.xml | 19 ++- 2 files changed, 101 insertions(+), 59 deletions(-) diff --git a/addons/l10n_multilang/l10n_multilang.py b/addons/l10n_multilang/l10n_multilang.py index e8e700bd1f6..1e7ed1fef87 100644 --- a/addons/l10n_multilang/l10n_multilang.py +++ b/addons/l10n_multilang/l10n_multilang.py @@ -21,70 +21,94 @@ from osv import fields, osv import os -import netsvc +from tools.translate import _ + + +class translate_message(osv.osv_memory): + _name = "translate.message" + _description = "Give Message After Translation completed" + + def default_get(self, cr, uid, fields, context=None): + """ Get default values + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for default value + @param context: A standard dictionary + @return: Default values of fields + """ + if context is None: + context = {} + res ={} + if context.get('warning'): + if 'message' in fields: + res.update({'message': _(context.get('warning'))}) + return res + + _columns = { + 'message' : fields.text('Message', size=64, readonly=True), + } + +translate_message() -logger=netsvc.Logger() class wizard_multi_charts_accounts(osv.osv_memory): """ Change wizard that a new account chart for a company. - * load Default languages - * Replace creation of financial accounts by copy from template. - This change results in adherence to Belgian MAR numbering scheme for cash accounts. - * Create financial journals for each account of type liquidity + * 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 copy_translation(self, cr, uid, langs, in_obj, in_field, in_ids, out_obj, out_ids): - done = False - error = False + def copy_translations(self, cr, uid, langs, in_obj, in_field, in_ids, out_obj, out_ids, context): + result = {} + if context is None: + context = {} xlat_obj = self.pool.get('ir.translation') - while not done: - #compare template with Accounts - if len(in_ids) != len(out_ids): - logger.notifyChannel('addons.'+self._name, netsvc.LOG_ERROR, - 'generate translations from template for %s failed (error 1)!' % out_obj._name) - error = True - break - #copy Translation from Source to Destination object - for lang in langs: - cr.execute("SELECT src, value FROM ir_translation " \ - "WHERE name=%s AND type='model' AND lang=%s AND res_id IN %s " \ - "ORDER by res_id", - (in_obj._name + ',' + in_field, lang, tuple(in_ids))) - xlats = cr.fetchall() - #IF there is no Translation Available or missing some Translation - if len(xlats) != len(out_ids): - logger.notifyChannel('addons.'+self._name, netsvc.LOG_ERROR, - 'There is no Translation available for template %s !' % out_obj._name) - error = True - break - for i in range(len(out_ids)): - src = xlats[i][0] - value = xlats[i][1] - out_record = out_obj.browse(cr, uid, out_ids[i]) - #compare with source to destination object name - if getattr(out_record, in_field) != src: - logger.notifyChannel('addons.'+self._name, netsvc.LOG_ERROR, - 'generate translations from template for %s failed (error 3)!' % out_obj._name) - error = True - break - #Copy Translation + #find the source from Account Template + result = [(x.id, x.name) for x in in_obj.browse(cr, uid, in_ids)] + src = dict(result) + message = '' + for lang in langs: + notdone = [] + #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 not value[in_id]: + # if source have no translation available + notdone.append(src[in_id]) + else: + #copy Translation from Source to Destination object xlat_obj.create(cr, uid, { - 'name': out_obj._name + ',' + in_field, - 'type': 'model', - 'res_id': out_record.id, - 'lang': lang, - 'src': src, - 'value': value, - }) - done = True - if error: - raise osv.except_osv(_('Warning!'), - _('The generation of translations from the template for %s failed!' % out_obj._name)) - + 'name': out_obj._name + ',' + in_field, + 'type': 'model', + 'res_id': out_ids[j], + 'lang': lang, + 'src': src[in_id], + 'value': value, + }) + if notdone: + message += '\nLanguage:-%s \n\tThere is no translation available for following accounts: \n\t%s '\ + % (lang, '\n\t'.join(notdone)) + else: + message += '\nLanguage:-%s \n\tTranslation successfully done.' % (lang) + resource_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'l10n_multilang', 'view_translate_message_wizard') + #open new wizard its for saw warning message + if message: + context.update({'warning': message}) + return { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'translate.message', + 'views': [(resource_id and resource_id[1] or False,'form')], + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': context + } + def execute(self, cr, uid, ids, context=None): - super(wizard_multi_charts_accounts, self).execute(cr, uid, ids, context=context) + res = super(wizard_multi_charts_accounts, self).execute(cr, uid, ids, context=context) obj_multi = self.browse(cr, uid, ids[0], context=context) obj_mod = self.pool.get('ir.module.module') obj_acc_template = self.pool.get('account.account.template') @@ -97,17 +121,18 @@ class wizard_multi_charts_accounts(osv.osv_memory): # load languages langs = [] + installed_mids = obj_mod.search(cr, uid, [('state', '=', 'installed')]) for lang in obj_multi.lang_ids: langs.append(lang.code) - installed_mids = obj_mod.search(cr, uid, [('state', '=', 'installed')]) - for lang in langs: - obj_mod.update_translations(cr, uid, installed_mids, lang) + obj_mod.update_translations(cr, uid, installed_mids, lang.code) # copy account.account translations - in_field = 'name' 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:] - self.copy_translation(cr, uid, langs, obj_acc_template, in_field, in_ids, obj_acc, out_ids) + result = self.copy_translations(cr, uid, langs, obj_acc_template, 'name', in_ids, obj_acc, out_ids, context) + if result: + return result + return {} def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None): res = super(wizard_multi_charts_accounts, self).onchange_chart_template_id(cr, uid, ids, chart_template_id, context=context) diff --git a/addons/l10n_multilang/l10n_multilang.xml b/addons/l10n_multilang/l10n_multilang.xml index 71563ce526c..02b06a9147d 100644 --- a/addons/l10n_multilang/l10n_multilang.xml +++ b/addons/l10n_multilang/l10n_multilang.xml @@ -1,7 +1,7 @@ - + 25 onskip @@ -27,6 +27,23 @@ + + + Translation Process + translate.message + form + + + + + + + +