From bd6d058fbc81e5e885c75834ced3f96ec386c77b Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Thu, 4 Aug 2011 12:38:56 +0530 Subject: [PATCH 1/2] [ADD]: account: l10n fullness and inheritancy: 1) Add installable field on account.tax.template 2)Real tax object will create only from tax template when installable field has been true 3)Give default value True of installable field 4)Improved code of tax store in ir.values bzr revid: ron@tinyerp.com-20110804070856-6mjxo8d22inrfqfh --- addons/account/account.py | 80 +++++++++++++++++---------------- addons/account/account_view.xml | 5 ++- 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index ca8d7538213..ab9c72ed522 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2538,6 +2538,7 @@ class account_tax_template(osv.osv): 'description': fields.char('Internal Name', size=32), 'type_tax_use': fields.selection([('sale','Sale'),('purchase','Purchase'),('all','All')], 'Tax Use In', required=True,), 'price_include': fields.boolean('Tax Included in Price', help="Check this if the price you use on the product and invoices includes this tax."), + 'installable': fields.boolean('Should be Installed', help="Set this to False if you do not want to create real tax object from this template.") } def name_get(self, cr, uid, ids, context=None): @@ -2569,6 +2570,7 @@ class account_tax_template(osv.osv): 'include_base_amount': False, 'type_tax_use': 'all', 'price_include': 0, + 'installable': True } _order = 'sequence' @@ -2760,6 +2762,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'ref_base_code_id': new_tax_code_temp, 'ref_tax_code_id': new_paid_tax_code_temp, 'type_tax_use': tax_type, + 'installable': True, 'type': 'percent', 'sequence': 0, 'chart_template_id': obj_multi.chart_template_id.id or False, @@ -2784,41 +2787,43 @@ class wizard_multi_charts_accounts(osv.osv_memory): #create all the tax tax_template_to_tax = {} for tax in obj_multi.chart_template_id.tax_template_ids: - #create it - vals_tax = { - 'name':tax.name, - 'sequence': tax.sequence, - 'amount':tax.amount, - 'type':tax.type, - 'applicable_type': tax.applicable_type, - 'domain':tax.domain, - 'parent_id': tax.parent_id and ((tax.parent_id.id in tax_template_ref) and tax_template_ref[tax.parent_id.id]) or False, - 'child_depend': tax.child_depend, - 'python_compute': tax.python_compute, - 'python_compute_inv': tax.python_compute_inv, - 'python_applicable': tax.python_applicable, - 'base_code_id': tax.base_code_id and ((tax.base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.base_code_id.id]) or False, - 'tax_code_id': tax.tax_code_id and ((tax.tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.tax_code_id.id]) or False, - 'base_sign': tax.base_sign, - 'tax_sign': tax.tax_sign, - 'ref_base_code_id': tax.ref_base_code_id and ((tax.ref_base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_base_code_id.id]) or False, - 'ref_tax_code_id': tax.ref_tax_code_id and ((tax.ref_tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_tax_code_id.id]) or False, - 'ref_base_sign': tax.ref_base_sign, - 'ref_tax_sign': tax.ref_tax_sign, - 'include_base_amount': tax.include_base_amount, - 'description':tax.description, - 'company_id': company_id, - 'type_tax_use': tax.type_tax_use, - 'price_include': tax.price_include - } - new_tax = obj_acc_tax.create(cr, uid, vals_tax) - tax_template_to_tax[tax.id] = new_tax - #as the accounts have not been created yet, we have to wait before filling these fields - todo_dict[new_tax] = { - 'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False, - 'account_paid_id': tax.account_paid_id and tax.account_paid_id.id or False, - } - tax_template_ref[tax.id] = new_tax + #Tax template must be installable True to create Tax object + if tax.installable: + #create it + vals_tax = { + 'name':tax.name, + 'sequence': tax.sequence, + 'amount':tax.amount, + 'type':tax.type, + 'applicable_type': tax.applicable_type, + 'domain':tax.domain, + 'parent_id': tax.parent_id and ((tax.parent_id.id in tax_template_ref) and tax_template_ref[tax.parent_id.id]) or False, + 'child_depend': tax.child_depend, + 'python_compute': tax.python_compute, + 'python_compute_inv': tax.python_compute_inv, + 'python_applicable': tax.python_applicable, + 'base_code_id': tax.base_code_id and ((tax.base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.base_code_id.id]) or False, + 'tax_code_id': tax.tax_code_id and ((tax.tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.tax_code_id.id]) or False, + 'base_sign': tax.base_sign, + 'tax_sign': tax.tax_sign, + 'ref_base_code_id': tax.ref_base_code_id and ((tax.ref_base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_base_code_id.id]) or False, + 'ref_tax_code_id': tax.ref_tax_code_id and ((tax.ref_tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_tax_code_id.id]) or False, + 'ref_base_sign': tax.ref_base_sign, + 'ref_tax_sign': tax.ref_tax_sign, + 'include_base_amount': tax.include_base_amount, + 'description':tax.description, + 'company_id': company_id, + 'type_tax_use': tax.type_tax_use, + 'price_include': tax.price_include + } + new_tax = obj_acc_tax.create(cr, uid, vals_tax) + tax_template_to_tax[tax.id] = new_tax + #as the accounts have not been created yet, we have to wait before filling these fields + todo_dict[new_tax] = { + 'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False, + 'account_paid_id': tax.account_paid_id and tax.account_paid_id.id or False, + } + tax_template_ref[tax.id] = new_tax #deactivate the parent_store functionnality on account_account for rapidity purpose ctx = context and context.copy() or {} ctx['defer_parent_store_computation'] = True @@ -3093,11 +3098,10 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'position_id': new_fp, } obj_ac_fp.create(cr, uid, vals_acc) - - if obj_multi.sale_tax: + if obj_multi.sale_tax and tax_template_to_tax: ir_values_obj.set(cr, uid, key='default', key2=False, name="taxes_id", company=obj_multi.company_id.id, models =[('product.product',False)], value=[tax_template_to_tax[obj_multi.sale_tax.id]]) - if obj_multi.purchase_tax: + if obj_multi.purchase_tax and tax_template_to_tax: ir_values_obj.set(cr, uid, key='default', key2=False, name="supplier_taxes_id", company=obj_multi.company_id.id, models =[('product.product',False)], value=[tax_template_to_tax[obj_multi.purchase_tax.id]]) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 70d59c569e9..8986be2be5a 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -2230,7 +2230,10 @@ - + + + + From 4ec5a06323df78f66f4beaf7a9fbf0a1c81c273d Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Thu, 4 Aug 2011 16:41:06 +0530 Subject: [PATCH 2/2] [ADD]: account: l10n fullness and inheritancy: combined for and If loop bzr revid: ron@tinyerp.com-20110804111106-vuyy9k02nu701syf --- addons/account/account.py | 76 +++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index ab9c72ed522..f7301e0b983 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2786,44 +2786,44 @@ class wizard_multi_charts_accounts(osv.osv_memory): #create all the tax tax_template_to_tax = {} - for tax in obj_multi.chart_template_id.tax_template_ids: - #Tax template must be installable True to create Tax object - if tax.installable: - #create it - vals_tax = { - 'name':tax.name, - 'sequence': tax.sequence, - 'amount':tax.amount, - 'type':tax.type, - 'applicable_type': tax.applicable_type, - 'domain':tax.domain, - 'parent_id': tax.parent_id and ((tax.parent_id.id in tax_template_ref) and tax_template_ref[tax.parent_id.id]) or False, - 'child_depend': tax.child_depend, - 'python_compute': tax.python_compute, - 'python_compute_inv': tax.python_compute_inv, - 'python_applicable': tax.python_applicable, - 'base_code_id': tax.base_code_id and ((tax.base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.base_code_id.id]) or False, - 'tax_code_id': tax.tax_code_id and ((tax.tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.tax_code_id.id]) or False, - 'base_sign': tax.base_sign, - 'tax_sign': tax.tax_sign, - 'ref_base_code_id': tax.ref_base_code_id and ((tax.ref_base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_base_code_id.id]) or False, - 'ref_tax_code_id': tax.ref_tax_code_id and ((tax.ref_tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_tax_code_id.id]) or False, - 'ref_base_sign': tax.ref_base_sign, - 'ref_tax_sign': tax.ref_tax_sign, - 'include_base_amount': tax.include_base_amount, - 'description':tax.description, - 'company_id': company_id, - 'type_tax_use': tax.type_tax_use, - 'price_include': tax.price_include - } - new_tax = obj_acc_tax.create(cr, uid, vals_tax) - tax_template_to_tax[tax.id] = new_tax - #as the accounts have not been created yet, we have to wait before filling these fields - todo_dict[new_tax] = { - 'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False, - 'account_paid_id': tax.account_paid_id and tax.account_paid_id.id or False, - } - tax_template_ref[tax.id] = new_tax + tax_templates_load = [x for x in obj_multi.chart_template_id.tax_template_ids if x.installable] + #Tax template must be installable True to create Tax object + for tax in tax_templates_load: + #create it + vals_tax = { + 'name':tax.name, + 'sequence': tax.sequence, + 'amount':tax.amount, + 'type':tax.type, + 'applicable_type': tax.applicable_type, + 'domain':tax.domain, + 'parent_id': tax.parent_id and ((tax.parent_id.id in tax_template_ref) and tax_template_ref[tax.parent_id.id]) or False, + 'child_depend': tax.child_depend, + 'python_compute': tax.python_compute, + 'python_compute_inv': tax.python_compute_inv, + 'python_applicable': tax.python_applicable, + 'base_code_id': tax.base_code_id and ((tax.base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.base_code_id.id]) or False, + 'tax_code_id': tax.tax_code_id and ((tax.tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.tax_code_id.id]) or False, + 'base_sign': tax.base_sign, + 'tax_sign': tax.tax_sign, + 'ref_base_code_id': tax.ref_base_code_id and ((tax.ref_base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_base_code_id.id]) or False, + 'ref_tax_code_id': tax.ref_tax_code_id and ((tax.ref_tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_tax_code_id.id]) or False, + 'ref_base_sign': tax.ref_base_sign, + 'ref_tax_sign': tax.ref_tax_sign, + 'include_base_amount': tax.include_base_amount, + 'description':tax.description, + 'company_id': company_id, + 'type_tax_use': tax.type_tax_use, + 'price_include': tax.price_include + } + new_tax = obj_acc_tax.create(cr, uid, vals_tax) + tax_template_to_tax[tax.id] = new_tax + #as the accounts have not been created yet, we have to wait before filling these fields + todo_dict[new_tax] = { + 'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False, + 'account_paid_id': tax.account_paid_id and tax.account_paid_id.id or False, + } + tax_template_ref[tax.id] = new_tax #deactivate the parent_store functionnality on account_account for rapidity purpose ctx = context and context.copy() or {} ctx['defer_parent_store_computation'] = True