[IMP]: account: l10n fullness and inheritancy:
1)Removed values given by context, 2)move ir.values updation to execute fucntion, 3)improved arguments lables and docString in generate_tax fucntion, 4)remove unnecessary arguments from generate_tax function bzr revid: ron@tinyerp.com-20110808105236-pt5f8069zwj1oz3y
This commit is contained in:
parent
cb2f70799b
commit
e2645ffa4e
|
@ -2574,7 +2574,7 @@ class account_tax_template(osv.osv):
|
||||||
}
|
}
|
||||||
_order = 'sequence'
|
_order = 'sequence'
|
||||||
|
|
||||||
def generate_tax(self, cr, uid, ids, tax_templates_load, tax_code_template_ref, company_id, context=None):
|
def generate_tax(self, cr, uid, tax_templates, tax_code_template_ref, company_id, context=None):
|
||||||
"""
|
"""
|
||||||
This method generate taxes from templates.
|
This method generate taxes from templates.
|
||||||
@param cr: A database cursor.
|
@param cr: A database cursor.
|
||||||
|
@ -2584,22 +2584,18 @@ class account_tax_template(osv.osv):
|
||||||
@param company_id: if tax generated from account multi wizard at that time company_id is wizard company_id field
|
@param company_id: if tax generated from account multi wizard at that time company_id is wizard company_id field
|
||||||
or logged user company_id.
|
or logged user company_id.
|
||||||
@param Return:
|
@param Return:
|
||||||
{'taxes_id': taxes ids
|
{'taxes_id': New generated taxes ids,
|
||||||
'account_dict': Used this reference value for Account Tax,
|
'account_dict': Used this reference value for Account Tax,
|
||||||
'tax_template_ref': Used this reference value for Fiscal Position
|
'tax_template_ref': Used this reference value for Fiscal Position
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
res = {}
|
res = {}
|
||||||
todo_dict = {}
|
todo_dict = {}
|
||||||
tax_template_ref = {}
|
tax_template_ref = {}
|
||||||
tax_template_to_tax = {}
|
tax_template_to_tax = {}
|
||||||
if not context.get('false_tax_template'):
|
for tax in tax_templates:
|
||||||
obj_multi = self.browse(cr, uid, ids[0])
|
|
||||||
ir_values_obj = self.pool.get('ir.values')
|
|
||||||
for tax in tax_templates_load:
|
|
||||||
# #create it
|
# #create it
|
||||||
vals_tax = {
|
vals_tax = {
|
||||||
'name':tax.name,
|
'name':tax.name,
|
||||||
|
@ -2635,13 +2631,6 @@ class account_tax_template(osv.osv):
|
||||||
'account_paid_id': tax.account_paid_id and tax.account_paid_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_ref[tax.id] = new_tax
|
||||||
if not context.get('false_tax_template'):
|
|
||||||
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 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]])
|
|
||||||
res.update({'taxes_id': tax_template_to_tax, 'account_dict': todo_dict, 'tax_template_ref': tax_template_ref})
|
res.update({'taxes_id': tax_template_to_tax, 'account_dict': todo_dict, 'tax_template_ref': tax_template_ref})
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -2806,6 +2795,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
analytic_journal_obj = self.pool.get('account.analytic.journal')
|
analytic_journal_obj = self.pool.get('account.analytic.journal')
|
||||||
obj_tax_code = self.pool.get('account.tax.code')
|
obj_tax_code = self.pool.get('account.tax.code')
|
||||||
obj_tax_code_template = self.pool.get('account.tax.code.template')
|
obj_tax_code_template = self.pool.get('account.tax.code.template')
|
||||||
|
ir_values_obj = self.pool.get('ir.values')
|
||||||
# Creating Account
|
# Creating Account
|
||||||
obj_acc_root = obj_multi.chart_template_id.account_root_id
|
obj_acc_root = obj_multi.chart_template_id.account_root_id
|
||||||
tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id
|
tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id
|
||||||
|
@ -2859,7 +2849,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
tax_template_to_tax = {}
|
tax_template_to_tax = {}
|
||||||
context.update({'false_tax_template': False})
|
context.update({'false_tax_template': False})
|
||||||
tax_templates = [x for x in obj_multi.chart_template_id.tax_template_ids if x.installable]
|
tax_templates = [x for x in obj_multi.chart_template_id.tax_template_ids if x.installable]
|
||||||
taxes_ids = obj_tax_temp.generate_tax(cr, uid, ids, tax_templates, tax_code_template_ref, company_id, context=context)
|
taxes_ids = obj_tax_temp.generate_tax(cr, uid, tax_templates, tax_code_template_ref, company_id, context=context)
|
||||||
#deactivate the parent_store functionnality on account_account for rapidity purpose
|
#deactivate the parent_store functionnality on account_account for rapidity purpose
|
||||||
ctx = context and context.copy() or {}
|
ctx = context and context.copy() or {}
|
||||||
ctx['defer_parent_store_computation'] = True
|
ctx['defer_parent_store_computation'] = True
|
||||||
|
@ -3134,6 +3124,12 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
'position_id': new_fp,
|
'position_id': new_fp,
|
||||||
}
|
}
|
||||||
obj_ac_fp.create(cr, uid, vals_acc)
|
obj_ac_fp.create(cr, uid, vals_acc)
|
||||||
|
if obj_multi.sale_tax and taxes_ids['taxes_id']:
|
||||||
|
ir_values_obj.set(cr, uid, key='default', key2=False, name="taxes_id", company=obj_multi.company_id.id,
|
||||||
|
models =[('product.product',False)], value=[taxes_ids['taxes_id'][obj_multi.sale_tax.id]])
|
||||||
|
if obj_multi.purchase_tax and taxes_ids['taxes_id']:
|
||||||
|
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=[taxes_ids['taxes_id'][obj_multi.purchase_tax.id]])
|
||||||
|
|
||||||
wizard_multi_charts_accounts()
|
wizard_multi_charts_accounts()
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,10 @@ class account_tax_generate(osv.osv_memory):
|
||||||
}
|
}
|
||||||
|
|
||||||
def tax_generate(self, cr, uid, ids, context=None):
|
def tax_generate(self, cr, uid, ids, context=None):
|
||||||
context.update({'false_tax_template': True})
|
|
||||||
company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
|
company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
|
||||||
obj_tax_temp = self.pool.get('account.tax.template')
|
obj_tax_temp = self.pool.get('account.tax.template')
|
||||||
tax_templates = [x for x in self.browse(cr, uid, ids, context=context)[0].template_ids]
|
tax_templates = [x for x in self.browse(cr, uid, ids, context=context)[0].template_ids]
|
||||||
taxes_ids = obj_tax_temp.generate_tax(cr, uid, ids, tax_templates, {}, company_id, context=context)
|
taxes_ids = obj_tax_temp.generate_tax(cr, uid, tax_templates, {}, company_id, context=context)
|
||||||
obj_tax_temp.write(cr, uid , taxes_ids['taxes_id'].keys(), {'installable': True})
|
obj_tax_temp.write(cr, uid , taxes_ids['taxes_id'].keys(), {'installable': True})
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue