From 088e65bd0b044dc9fb148e8e80927f56d938dd84 Mon Sep 17 00:00:00 2001 From: "Jagdish Panchal (Open ERP)" Date: Tue, 5 Jun 2012 11:34:41 +0530 Subject: [PATCH] [IMP] l10n_in: Improve Usability and link account with tax bzr revid: jap@tinyerp.com-20120605060441-52p0hoksc2hr3ey6 --- addons/l10n_in/account_multi_chart_wizard.py | 46 +++++++++++++------ .../account_multi_chart_wizard_view.xml | 11 ++--- addons/l10n_in/installer.py | 2 +- .../l10n_in_private_firm_tax_template.xml | 36 +++++++-------- 4 files changed, 55 insertions(+), 40 deletions(-) diff --git a/addons/l10n_in/account_multi_chart_wizard.py b/addons/l10n_in/account_multi_chart_wizard.py index b9c242312a6..a7e018b2cdb 100644 --- a/addons/l10n_in/account_multi_chart_wizard.py +++ b/addons/l10n_in/account_multi_chart_wizard.py @@ -1,8 +1,8 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # -# Author: Nicolas Bessi. Copyright Camptocamp SA -# Donors: Hasa Sàrl, Open Net Sàrl and Prisme Solutions Informatique SA +# 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 @@ -24,7 +24,8 @@ from os.path import join as opj import tools class account_multi_charts_wizard(osv.osv_memory): - _inherit ='wizard.multi.charts.accounts' + _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'), @@ -45,57 +46,72 @@ class account_multi_charts_wizard(osv.osv_memory): elif data.name == 'India - Chart of Accounts for Partnership/Private Firm': res['value'].update({'sales_tax': True,'vat':True}) 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_code_template = self.pool.get('account.tax.code.template') obj_tax_temp = self.pool.get('account.tax.template') obj_tax = self.pool.get('account.tax') - tax_code_ref.update(obj_tax_code_template.generate_tax_code(cr, uid, template.tax_code_root_id.id, company_id, context=context)) 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')) - # 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.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) 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) 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) 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) - + 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) 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) 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) 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) 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) + 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 index 899d81fc65b..dde9e5981ca 100644 --- a/addons/l10n_in/account_multi_chart_wizard_view.xml +++ b/addons/l10n_in/account_multi_chart_wizard_view.xml @@ -9,12 +9,11 @@ - - - - - - + + + + + diff --git a/addons/l10n_in/installer.py b/addons/l10n_in/installer.py index 23d03bfc87d..7d4cb04b803 100644 --- a/addons/l10n_in/installer.py +++ b/addons/l10n_in/installer.py @@ -28,7 +28,7 @@ class l10n_installer(osv.osv_memory): _columns = { 'company_type':fields.selection([('partnership_private_company', 'Partnership/Private Firm'), ('public_company', 'Public Firm')], 'Company Type', required=True, - help='Select your company Type according to your need to install Chart Of Account'), + help='Company Type is used to install Indian chart of accounts as per your type of business.'), } _defaults = { 'company_type': 'public_company', diff --git a/addons/l10n_in/l10n_in_private_firm_tax_template.xml b/addons/l10n_in/l10n_in_private_firm_tax_template.xml index 564eb41fdfd..d3d627b54da 100644 --- a/addons/l10n_in/l10n_in_private_firm_tax_template.xml +++ b/addons/l10n_in/l10n_in_private_firm_tax_template.xml @@ -4,7 +4,7 @@ - + Sales Tax Payable 216 payable @@ -13,7 +13,7 @@ - + VAT Payable 217 payable @@ -22,7 +22,7 @@ - + Service Tax Payable 218 payable @@ -31,7 +31,7 @@ - + Exice Duty Payable 219 payable @@ -50,8 +50,8 @@ 0.15 percent sale - - + + @@ -67,8 +67,8 @@ 0.12 percent sale - - + + @@ -86,8 +86,8 @@ 0.05 percent all - - + + 1 @@ -107,8 +107,8 @@ 0.15 percent all - - + + 1 @@ -128,8 +128,8 @@ 0.8 percent all - - + + @@ -147,8 +147,8 @@ 0.10 percent sale - - + + 1 @@ -190,8 +190,8 @@ 0.12 percent - - + +