[IMP]: account: l10n fullness and inheritancy: flexible code to load/create taxes based on value of Complete Set Of Tax

bzr revid: ron@tinyerp.com-20110803062549-95hi97dclowu01ev
This commit is contained in:
ron@tinyerp.com
2011-08-03 11:55:49 +05:30
parent 38a47ab93e
commit 5ad2f2dbb3
+4 -47
View File
@@ -23,7 +23,6 @@ import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
from operator import itemgetter
from os.path import join as opj
import netsvc
import pooler
@@ -2741,39 +2740,13 @@ class wizard_multi_charts_accounts(osv.osv_memory):
# create tax templates and real taxes from purchase_tax_rate,sale_tax_rate fields
if not obj_multi.complete_tax:
fp = tools.file_open(opj('account', 'configurable_account_chart.xml'))
tools.convert_xml_import(cr, 'account', fp, {}, 'init', True, None)
fp.close()
s_tax = (obj_multi.sale_tax_rate/100)
p_tax = (obj_multi.purchase_tax_rate/100)
pur_temp_tax = obj_data.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 = obj_data.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 = obj_data.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 = obj_data.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_id = obj_multi.chart_template_id.id or False
if s_tax * 100 > 0.0:
tax_account_ids = obj_acc_template.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_template.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_template.create(cr, uid, vals_paid_tax_code_temp, context=context)
new_tax_code_temp = obj_tax_code_template.create(cr, uid, {'name': _('TAX %s%%') % (s_tax*100), 'code': _('TAX %s%%') % (s_tax*100)}, context=context)
new_paid_tax_code_temp = obj_tax_code_template.create(cr, uid, {'name': _('TAX Received %s%%') % (s_tax*100), 'code': _('TAX Received %s%%') % (s_tax*100)}, context=context)
sales_tax_temp = obj_tax_temp.create(cr, uid, {
'name': _('TAX %s%%') % (s_tax*100),
'description': _('TAX %s%%') % (s_tax*100),
@@ -2785,25 +2758,11 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'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_template.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_template.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_template.create(cr, uid, vals_paid_tax_code_temp, context=context)
new_tax_code_temp = obj_tax_code_template.create(cr, uid, {'name': _('TAX %s%%') % (p_tax*100), 'code': _('TAX %s%%') % (p_tax*100)}, context=context)
new_paid_tax_code_temp = obj_tax_code_template.create(cr, uid, {'name': _('TAX Paid %s%%') % (p_tax*100), 'code': _('TAX Paid %s%%') % (p_tax*100)}, context=context)
purchase_tax_temp = obj_tax_temp.create(cr, uid, {
'name': _('TAX %s%%') % (p_tax*100),
'description': _('TAX %s%%') % (p_tax*100),
@@ -2815,8 +2774,6 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'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)