From a5db806929c6265eb891b6017746ae04bcedb194 Mon Sep 17 00:00:00 2001 From: "Jagdish Panchal (Open ERP)" Date: Fri, 8 Jun 2012 18:36:38 +0530 Subject: [PATCH 1/2] [IMP] l10n_in: Improve code bzr revid: jap@tinyerp.com-20120608130638-0zii119hfa340wgv --- addons/l10n_in/account_multi_chart_wizard.py | 49 ++++++------------- .../account_multi_chart_wizard_view.xml | 11 +++-- 2 files changed, 20 insertions(+), 40 deletions(-) diff --git a/addons/l10n_in/account_multi_chart_wizard.py b/addons/l10n_in/account_multi_chart_wizard.py index a7e018b2cdb..78fa5fe23da 100644 --- a/addons/l10n_in/account_multi_chart_wizard.py +++ b/addons/l10n_in/account_multi_chart_wizard.py @@ -44,7 +44,7 @@ class account_multi_charts_wizard(osv.osv_memory): if data.name == 'India - Chart of Accounts for Public Firm': res['value'].update({'sales_tax': True,'vat':True, 'service_tax':True, 'excise_duty': True}) elif data.name == 'India - Chart of Accounts for Partnership/Private Firm': - res['value'].update({'sales_tax': True,'vat':True}) + res['value'].update({'sales_tax': True,'vat':True, 'service_tax':False, 'excise_duty': False}) return res def _load_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, account_ref={}, taxes_ref={}, tax_code_ref={}, context=None): @@ -52,58 +52,37 @@ class account_multi_charts_wizard(osv.osv_memory): template = self.pool.get('account.chart.template').browse(cr, uid, template_id, context=context) obj_tax_temp = self.pool.get('account.tax.template') obj_tax = self.pool.get('account.tax') - if obj_wizard.sales_tax == False and obj_wizard.excise_duty == False and obj_wizard.vat == False and obj_wizard.service_tax == False: - raise osv.except_osv(_('Error !'), _('Select Tax to Install')) + tax_temp_ids = [] if obj_wizard.chart_template_id.name == 'India - Chart of Accounts for Public Firm': # Unlink the Tax for current company tax_ids = obj_tax.search(cr, uid, [('company_id','=',company_id)], context=context) obj_tax.unlink(cr, uid, tax_ids, context=context) #Create new Tax as per selected from wizard if obj_wizard.sales_tax: - tax_temp_ids = obj_tax_temp.search(cr, uid, [('name','in',['Sale Tax - 15%','Sale Tax - 12%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context) - tax_temp_data = obj_tax_temp.browse(cr, uid, tax_temp_ids, context=context) - taxes_ref = obj_tax_temp._generate_tax(cr, uid, tax_temp_data, tax_code_ref, company_id, context=context) - self._tax_account(cr, uid, account_ref, taxes_ref, context=context) + tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Sale Tax - 15%','Sale Tax - 12%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) if obj_wizard.vat: - tax_temp_ids = obj_tax_temp.search(cr, uid, [('name','in',['VAT - 5%','VAT - 15%','VAT - 8%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context) - tax_temp_data = obj_tax_temp.browse(cr, uid, tax_temp_ids, context=context) - taxes_ref = obj_tax_temp._generate_tax(cr, uid, tax_temp_data, tax_code_ref, company_id, context=context) - self._tax_account(cr, uid, account_ref, taxes_ref, context=context) + tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['VAT - 5%','VAT - 15%','VAT - 8%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) if obj_wizard.service_tax: - tax_temp_ids = obj_tax_temp.search(cr, uid, [('name','in',['Service Tax','Service Tax - %2','Service Tax - %1']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context) - tax_temp_data = obj_tax_temp.browse(cr, uid, tax_temp_ids, context=context) - taxes_ref = obj_tax_temp._generate_tax(cr, uid, tax_temp_data, tax_code_ref, company_id, context=context) - self._tax_account(cr, uid, account_ref, taxes_ref, context=context) + tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Service Tax', 'Service Tax - %2', 'Service Tax - %1']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) if obj_wizard.excise_duty: - tax_temp_ids = obj_tax_temp.search(cr, uid, [('name','in',['Excise Duty','Excise Duty - %2','Excise Duty - 1%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context) - tax_temp_data = obj_tax_temp.browse(cr, uid, tax_temp_ids, context=context) - taxes_ref = obj_tax_temp._generate_tax(cr, uid, tax_temp_data, tax_code_ref, company_id, context=context) - self._tax_account(cr, uid, account_ref, taxes_ref, context=context) + tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Excise Duty', 'Excise Duty - %2', 'Excise Duty - 1%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) elif obj_wizard.chart_template_id.name == 'India - Chart of Accounts for Partnership/Private Firm': # Unlink the Tax for current company tax_ids = obj_tax.search(cr, uid, [('company_id','=',company_id)], context=context) obj_tax.unlink(cr, uid, tax_ids, context=context) #Create new Tax as per selected from wizard if obj_wizard.sales_tax: - tax_temp_ids = obj_tax_temp.search(cr, uid, [('name','in',['Sale Tax - 15%','Sale Tax - 12%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context) - tax_temp_data = obj_tax_temp.browse(cr, uid, tax_temp_ids, context=context) - taxes_ref = obj_tax_temp._generate_tax(cr, uid, tax_temp_data, tax_code_ref, company_id, context=context) - self._tax_account(cr, uid, account_ref, taxes_ref, context=context) + tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Sale Tax - 15%','Sale Tax - 12%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) if obj_wizard.vat: - tax_temp_ids = obj_tax_temp.search(cr, uid, [('name','in',['VAT - 5%','VAT - 15%','VAT - 8%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context) - tax_temp_data = obj_tax_temp.browse(cr, uid, tax_temp_ids, context=context) - taxes_ref = obj_tax_temp._generate_tax(cr, uid, tax_temp_data, tax_code_ref, company_id, context=context) - self._tax_account(cr, uid, account_ref, taxes_ref, context=context) + tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['VAT - 5%','VAT - 15%','VAT - 8%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) if obj_wizard.service_tax: - tax_temp_ids = obj_tax_temp.search(cr, uid, [('name','in',['Service Tax', 'Service Tax - %2', 'Service Tax - %1']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context) - tax_temp_data = obj_tax_temp.browse(cr, uid, tax_temp_ids, context=context) - taxes_ref = obj_tax_temp._generate_tax(cr, uid, tax_temp_data, tax_code_ref, company_id, context=context) - self._tax_account(cr, uid, account_ref, taxes_ref, context=context) + tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Service Tax', 'Service Tax - %2', 'Service Tax - %1']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) if obj_wizard.excise_duty: - tax_temp_ids = obj_tax_temp.search(cr, uid, [('name','in',['Excise Duty', 'Excise Duty - %2', 'Excise Duty - 1%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context) - tax_temp_data = obj_tax_temp.browse(cr, uid, tax_temp_ids, context=context) - taxes_ref = obj_tax_temp._generate_tax(cr, uid, tax_temp_data, tax_code_ref, company_id, context=context) - self._tax_account(cr, uid, account_ref, taxes_ref, context=context) + tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Excise Duty', 'Excise Duty - %2', 'Excise Duty - 1%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) + for temp in tax_temp_ids: + tax_temp_data = obj_tax_temp.browse(cr, uid, temp, context=context) + taxes_ref = obj_tax_temp._generate_tax(cr, uid, tax_temp_data, tax_code_ref, company_id, context=context) + self._tax_account(cr, uid, account_ref, taxes_ref, context=context) return account_ref, taxes_ref, tax_code_ref def _tax_account(self, cr, uid, account_ref, taxes_ref, context=None): diff --git a/addons/l10n_in/account_multi_chart_wizard_view.xml b/addons/l10n_in/account_multi_chart_wizard_view.xml index dde9e5981ca..d864a01a3a8 100644 --- a/addons/l10n_in/account_multi_chart_wizard_view.xml +++ b/addons/l10n_in/account_multi_chart_wizard_view.xml @@ -9,11 +9,12 @@ - - - - - + + + + + + From 96333130201c0db03f284fe85cf29d9d6d55defb Mon Sep 17 00:00:00 2001 From: "Jagdish Panchal (Open ERP)" Date: Tue, 12 Jun 2012 12:17:12 +0530 Subject: [PATCH 2/2] [IMP] l10n_in: Remove file l10n_in/account_multi_chart_wizard.py and l10n_in/account_multi_chart_wizard_view.xml bzr revid: jap@tinyerp.com-20120612064712-tviq139uo8yyd1zs --- addons/l10n_in/__init__.py | 1 - addons/l10n_in/__openerp__.py | 1 - addons/l10n_in/account_multi_chart_wizard.py | 96 ------------------- .../account_multi_chart_wizard_view.xml | 22 ----- 4 files changed, 120 deletions(-) delete mode 100644 addons/l10n_in/account_multi_chart_wizard.py delete mode 100644 addons/l10n_in/account_multi_chart_wizard_view.xml diff --git a/addons/l10n_in/__init__.py b/addons/l10n_in/__init__.py index db0c795ae73..f97bda7fb89 100644 --- a/addons/l10n_in/__init__.py +++ b/addons/l10n_in/__init__.py @@ -28,6 +28,5 @@ ############################################################################## import installer -import account_multi_chart_wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_in/__openerp__.py b/addons/l10n_in/__openerp__.py index cbacb5e5ac3..630d99ca8db 100644 --- a/addons/l10n_in/__openerp__.py +++ b/addons/l10n_in/__openerp__.py @@ -37,7 +37,6 @@ Indian accounting chart and localization. "demo_xml": [], "update_xml": [ "account_tax_code_template.xml", - "account_multi_chart_wizard_view.xml", "l10n_in_wizard.xml", "installer_view.xml", ], diff --git a/addons/l10n_in/account_multi_chart_wizard.py b/addons/l10n_in/account_multi_chart_wizard.py deleted file mode 100644 index 78fa5fe23da..00000000000 --- a/addons/l10n_in/account_multi_chart_wizard.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Business Applications -# Copyright (C) 2004-2012 OpenERP S.A. (). -# -# 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 tools.translate import _ -from osv import fields, osv -from os.path import join as opj -import tools - -class account_multi_charts_wizard(osv.osv_memory): - _name = 'wizard.multi.charts.accounts' - _inherit = 'wizard.multi.charts.accounts' - _columns = { - 'sales_tax': fields.boolean('Sales Tax', help='If this field is true it allows you install Sales Tax'), - 'vat': fields.boolean('VAT', help='If this field is true it allows install use VAT'), - 'service_tax': fields.boolean('Service Tax', help='If this field is true it allows you install Service tax'), - 'excise_duty': fields.boolean('Excise Duty', help='If this field is true it allows you install Excise duty'), - 'is_indian_chart': fields.boolean('Indian Chart?') - } - - def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None): - res = super(account_multi_charts_wizard, self).onchange_chart_template_id(cr, uid, ids, chart_template_id, context=context) - data = self.pool.get('account.chart.template').browse(cr, uid, chart_template_id, context=context) - if data.name in ('India - Chart of Accounts for Public Firm', 'India - Chart of Accounts for Partnership/Private Firm'): - res['value'].update({'is_indian_chart': True}) - else: - res['value'].update({'is_indian_chart': False}) - if data.name == 'India - Chart of Accounts for Public Firm': - res['value'].update({'sales_tax': True,'vat':True, 'service_tax':True, 'excise_duty': True}) - elif data.name == 'India - Chart of Accounts for Partnership/Private Firm': - res['value'].update({'sales_tax': True,'vat':True, 'service_tax':False, 'excise_duty': False}) - return res - - def _load_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, account_ref={}, taxes_ref={}, tax_code_ref={}, context=None): - res = super(account_multi_charts_wizard, self)._load_template(cr, uid, template_id, company_id, code_digits, obj_wizard, account_ref, taxes_ref, tax_code_ref, context=context) - template = self.pool.get('account.chart.template').browse(cr, uid, template_id, context=context) - obj_tax_temp = self.pool.get('account.tax.template') - obj_tax = self.pool.get('account.tax') - tax_temp_ids = [] - if obj_wizard.chart_template_id.name == 'India - Chart of Accounts for Public Firm': - # Unlink the Tax for current company - tax_ids = obj_tax.search(cr, uid, [('company_id','=',company_id)], context=context) - obj_tax.unlink(cr, uid, tax_ids, context=context) - #Create new Tax as per selected from wizard - if obj_wizard.sales_tax: - tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Sale Tax - 15%','Sale Tax - 12%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) - if obj_wizard.vat: - tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['VAT - 5%','VAT - 15%','VAT - 8%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) - if obj_wizard.service_tax: - tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Service Tax', 'Service Tax - %2', 'Service Tax - %1']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) - if obj_wizard.excise_duty: - tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Excise Duty', 'Excise Duty - %2', 'Excise Duty - 1%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) - elif obj_wizard.chart_template_id.name == 'India - Chart of Accounts for Partnership/Private Firm': - # Unlink the Tax for current company - tax_ids = obj_tax.search(cr, uid, [('company_id','=',company_id)], context=context) - obj_tax.unlink(cr, uid, tax_ids, context=context) - #Create new Tax as per selected from wizard - if obj_wizard.sales_tax: - tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Sale Tax - 15%','Sale Tax - 12%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) - if obj_wizard.vat: - tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['VAT - 5%','VAT - 15%','VAT - 8%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) - if obj_wizard.service_tax: - tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Service Tax', 'Service Tax - %2', 'Service Tax - %1']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) - if obj_wizard.excise_duty: - tax_temp_ids.append(obj_tax_temp.search(cr, uid, [('name','in',['Excise Duty', 'Excise Duty - %2', 'Excise Duty - 1%']),('chart_template_id','=',obj_wizard.chart_template_id.id)], context=context)) - for temp in tax_temp_ids: - tax_temp_data = obj_tax_temp.browse(cr, uid, temp, context=context) - taxes_ref = obj_tax_temp._generate_tax(cr, uid, tax_temp_data, tax_code_ref, company_id, context=context) - self._tax_account(cr, uid, account_ref, taxes_ref, context=context) - return account_ref, taxes_ref, tax_code_ref - - def _tax_account(self, cr, uid, account_ref, taxes_ref, context=None): - obj_tax = self.pool.get('account.tax') - for key,value in taxes_ref['account_dict'].items(): - obj_tax.write(cr, uid, [key], { 'account_collected_id': account_ref.get(value['account_collected_id'], False), 'account_paid_id': account_ref.get(value['account_paid_id'], False),}) - return True - -account_multi_charts_wizard() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_in/account_multi_chart_wizard_view.xml b/addons/l10n_in/account_multi_chart_wizard_view.xml deleted file mode 100644 index d864a01a3a8..00000000000 --- a/addons/l10n_in/account_multi_chart_wizard_view.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - Generate Chart of Accounts from a Chart Template - wizard.multi.charts.accounts - form - - - - - - - - - - - - - - -