From 94ec14e8b9ad55f5cb342f6efc0cb9122dc8e1f9 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Tue, 16 Aug 2011 11:28:47 +0530 Subject: [PATCH] [IMP]: account: l10n_multilang : 1)Improved params of generate_account(), 2)Improved return values, 3)Improved references where passed this return values, 4)Improved in ctx bzr revid: ron@tinyerp.com-20110816055847-5vb3g33kfang0nc8 --- addons/account/account.py | 46 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 1c8f43f03d4..c2d6ee58a1b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2385,7 +2385,7 @@ class account_account_template(osv.osv): @param tax_template_ref: Taxes templates reference for write taxes_id in account_account. @param code_digits: Digit getting from wizard.multi.charts.accounts.,this is use for account code. @param company_id: company_id selected from wizard.multi.charts.accounts. - @return :{acc_template_ref : Pass acconting_ids for reference purpose} + @return : return acc_template_ref for reference purpose. """ if context is None: @@ -2393,9 +2393,9 @@ class account_account_template(osv.osv): obj_acc = self.pool.get('account.account') acc_template_ref = {} #deactivate the parent_store functionnality on account_account for rapidity purpose - ctx = context and context.copy() or {} + ctx = context.copy() ctx['defer_parent_store_computation'] = True - children_acc_template = self.search(cr, uid, [('parent_id','child_of', account_root_id),('nocreate','!=',True)]) + children_acc_template = self.search(cr, uid, [('parent_id','child_of', [account_root_id]),('nocreate','!=',True)]) children_acc_template.sort() for account_template in self.browse(cr, uid, children_acc_template, context=context): @@ -2408,7 +2408,7 @@ class account_account_template(osv.osv): if code_main > 0 and code_main <= code_digits and account_template.type != 'view': code_acc = str(code_acc) + (str('0'*(code_digits-code_main))) vals={ - 'name': (account_root_id[0] == account_template.id) and company_id.name or account_template.name, + 'name': (account_root_id == account_template.id) and company_id.name or account_template.name, 'currency_id': account_template.currency_id and account_template.currency_id.id or False, 'code': code_acc, 'type': account_template.type, @@ -2425,7 +2425,7 @@ class account_account_template(osv.osv): #reactivate the parent_store functionnality on account_account obj_acc._parent_store_compute(cr) - return {'acc_template_ref': acc_template_ref} + return acc_template_ref account_account_template() @@ -2928,15 +2928,15 @@ class wizard_multi_charts_accounts(osv.osv_memory): #create all the tax tax_template_to_tax = {} tax_templates = [x for x in obj_multi.chart_template_id.tax_template_ids if x.installable] + #This method use for generating Taxes from templates. taxes_ids = obj_tax_temp.generate_tax(cr, uid, tax_templates, tax_code_template_ref, company_id, context=context) - - acc_ids = obj_acc_template.generate_account(cr, uid, [obj_acc_root.id], taxes_ids['tax_template_ref'], obj_multi.code_digits, obj_multi.company_id, context=context) - + #This method use for generating Accounts from templates. + acc_template_ref = obj_acc_template.generate_account(cr, uid, obj_acc_root.id, taxes_ids['tax_template_ref'], obj_multi.code_digits, obj_multi.company_id, context=context) for key,value in taxes_ids['account_dict'].items(): if value['account_collected_id'] or value['account_paid_id']: obj_acc_tax.write(cr, uid, [key], { - 'account_collected_id': acc_ids['acc_template_ref'].get(value['account_collected_id'], False), - 'account_paid_id': acc_ids['acc_template_ref'].get(value['account_paid_id'], False), + 'account_collected_id': acc_template_ref.get(value['account_collected_id'], False), + 'account_paid_id': acc_template_ref.get(value['account_paid_id'], False), }) # Creating Journals @@ -2958,8 +2958,8 @@ class wizard_multi_charts_accounts(osv.osv_memory): } if obj_multi.chart_template_id.property_account_receivable: - vals_journal['default_credit_account_id'] = acc_ids['acc_template_ref'][obj_multi.chart_template_id.property_account_income_categ.id] - vals_journal['default_debit_account_id'] = acc_ids['acc_template_ref'][obj_multi.chart_template_id.property_account_income_categ.id] + vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id] + vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id] obj_journal.create(cr,uid,vals_journal) @@ -2977,8 +2977,8 @@ class wizard_multi_charts_accounts(osv.osv_memory): } if obj_multi.chart_template_id.property_account_payable: - vals_journal['default_credit_account_id'] = acc_ids['acc_template_ref'][obj_multi.chart_template_id.property_account_expense_categ.id] - vals_journal['default_debit_account_id'] = acc_ids['acc_template_ref'][obj_multi.chart_template_id.property_account_expense_categ.id] + vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id] + vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id] obj_journal.create(cr,uid,vals_journal) # Creating Journals Sales Refund and Purchase Refund @@ -2997,8 +2997,8 @@ class wizard_multi_charts_accounts(osv.osv_memory): } if obj_multi.chart_template_id.property_account_receivable: - vals_journal['default_credit_account_id'] = acc_ids['acc_template_ref'][obj_multi.chart_template_id.property_account_income_categ.id] - vals_journal['default_debit_account_id'] = acc_ids['acc_template_ref'][obj_multi.chart_template_id.property_account_income_categ.id] + vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id] + vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id] obj_journal.create(cr, uid, vals_journal, context=context) @@ -3013,8 +3013,8 @@ class wizard_multi_charts_accounts(osv.osv_memory): } if obj_multi.chart_template_id.property_account_payable: - vals_journal['default_credit_account_id'] = acc_ids['acc_template_ref'][obj_multi.chart_template_id.property_account_expense_categ.id] - vals_journal['default_debit_account_id'] = acc_ids['acc_template_ref'][obj_multi.chart_template_id.property_account_expense_categ.id] + vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id] + vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id] obj_journal.create(cr, uid, vals_journal, context=context) @@ -3046,8 +3046,8 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'view_id': view_id, 'company_id': company_id, 'centralisation': True, - 'default_credit_account_id': acc_ids['acc_template_ref'][obj_multi.chart_template_id.property_account_income_opening.id], - 'default_debit_account_id': acc_ids['acc_template_ref'][obj_multi.chart_template_id.property_account_expense_opening.id] + 'default_credit_account_id': acc_template_ref[obj_multi.chart_template_id.property_account_income_opening.id], + 'default_debit_account_id': acc_template_ref[obj_multi.chart_template_id.property_account_expense_opening.id] } obj_journal.create(cr, uid, vals_journal, context=context) @@ -3083,7 +3083,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'type': 'liquidity', 'user_type': account_template.user_type and account_template.user_type.id or False, 'reconcile': True, - 'parent_id': acc_ids['acc_template_ref'][ref_acc_bank.id] or False, + 'parent_id': acc_template_ref[ref_acc_bank.id] or False, 'company_id': company_id, } acc_cash_id = obj_acc.create(cr,uid,vals) @@ -3130,7 +3130,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'name': record[0], 'company_id': company_id, 'fields_id': field[0], - 'value': account and 'account.account,' + str(acc_ids['acc_template_ref'][account.id]) or False, + 'value': account and 'account.account,' + str(acc_template_ref[account.id]) or False, } if r: @@ -3141,7 +3141,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): property_obj.create(cr, uid, vals) #Generate Fiscal Position , Fiscal Position Accounts and Fiscal Position Taxes from templates - obj_fiscal_position_template.generate_fiscal_position(cr, uid, chart_temp_id, taxes_ids['tax_template_ref'], acc_ids['acc_template_ref'], company_id, context=context) + obj_fiscal_position_template.generate_fiscal_position(cr, uid, chart_temp_id, taxes_ids['tax_template_ref'], acc_template_ref, company_id, context=context) 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,