From cc9cf2deaeab015ae310fd590f060ac806c0cd8c Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 31 Aug 2011 12:55:21 +0530 Subject: [PATCH 01/10] [IMP]: account: l10n fullness and inheritancy : 1)Passed template_id in generate_account instead of browse record 2)Changed the search method like Loaded the accounts templates only which related to current templates or false bzr revid: ron@tinyerp.com-20110831072521-lqb1aossh75ydzzz --- addons/account/account.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index b134c6aa5dc..387ecf13027 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2376,7 +2376,7 @@ class account_account_template(osv.osv): res.append((record['id'],name )) return res - def generate_account(self, cr, uid, account_root_id, tax_template_ref, code_digits, company_id, context=None): + def generate_account(self, cr, uid, template_id, account_root_id, tax_template_ref, code_digits, company_id, context=None): """ This method for generating accounts from templates. @param cr: A database cursor. @@ -2396,7 +2396,7 @@ class account_account_template(osv.osv): #deactivate the parent_store functionnality on account_account for rapidity purpose ctx = context.copy() ctx.update({'defer_parent_store_computation': True}) - children_acc_template = self.search(cr, uid, [('parent_id','child_of', [account_root_id]),('nocreate','!=',True)], order='id') + children_acc_template = self.search(cr, uid, [('parent_id','child_of', [account_root_id]),'|', ('chart_template_id','=', [template_id]),('chart_template_id','=', False), ('nocreate','!=',True)], order='id') for account_template in self.browse(cr, uid, children_acc_template, context=context): tax_ids = [] for tax in account_template.tax_ids: @@ -3117,7 +3117,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): taxes_ref = obj_tax_temp.generate_tax(cr, uid, tax_templates, tax_code_template_ref, company_id, context=context) # Generating Accounts from templates. - acc_template_ref = obj_acc_template.generate_account(cr, uid, template.account_root_id.id, taxes_ref['tax_template_ref'], code_digits, company_id, context=context) + acc_template_ref = obj_acc_template.generate_account(cr, uid, template_id, template.account_root_id.id, taxes_ref['tax_template_ref'], code_digits, company_id, context=context) # writing account values on tax after creation of accounts for key,value in taxes_ref['account_dict'].items(): From 1a2d69c0730fc314bbd3ce9444b299d8cb4a932e Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 31 Aug 2011 14:24:33 +0530 Subject: [PATCH 02/10] [IMP]: account: l10n fullness and inheritancy : 1)changed logic of Parent>child relation of installing of chart_templates 2)created back_journal list before execute function and passed as a keyword argu in _install_template() bzr revid: ron@tinyerp.com-20110831085433-7h14a933n5sab6h5 --- addons/account/account.py | 40 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 387ecf13027..6eec7393707 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -3034,32 +3034,13 @@ class wizard_multi_charts_accounts(osv.osv_memory): return True - def _install_template(self, cr, uid, ids, template_id, company_id, code_digits=None ,tax_data={}, context=None): - print 'install', template_id + def _install_template(self, cr, uid, template_id, company_id, code_digits=None ,tax_data={}, bank_jrnl_acc_list=[], context=None): template = self.pool.get('account.chart.template').browse(cr, uid, template_id, context=context) -# TOFIX: Improve relation between COA template and account template -# If we have COA template struct like : -# COA A -# COA B -# -# and account template struct like: -# A0 -# - A01 -# - B02 -# A1 -# - B11 -# - B12 -# where prefix A is intended to load for COA A, and B for B -# -# now I am processing COA B -# B02 is child of A0 so children_acc_template = obj_acc_template.search(cr, uid, [('parent_id','child_of',[obj_acc_root.id]),('nocreate','!=',True)]) -# will search all acc templates of A and B + if template.parent_id: + self._install_template(cr, uid, template.parent_id.id, company_id, code_digits=code_digits, context=context) + return self._load_template(cr, uid, template_id, company_id, code_digits=code_digits, tax_data=tax_data, bank_jrnl_acc_list=bank_jrnl_acc_list,context=context) -# if template.parent_id: -# self._install_template(cr, uid, ids, template.parent_id.id, company_id, code_digits=code_digits, context=context) - return self._load_template(cr, uid, ids, template_id, company_id, code_digits=code_digits, tax_data=tax_data, context=context) - - def _load_template(self, cr, uid, ids, template_id, company_id, code_digits=None, tax_data={}, context=None): + def _load_template(self, cr, uid, template_id, company_id, code_digits=None, tax_data={}, bank_jrnl_acc_list=[], context=None): 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_code = self.pool.get('account.tax.code') @@ -3154,13 +3135,22 @@ class wizard_multi_charts_accounts(osv.osv_memory): obj_tax_temp = self.pool.get('account.tax.template') obj_multi = self.browse(cr, uid, ids[0]) company_id = obj_multi.company_id.id + bank_jrnl_acc_list = [] tax_data = { 'sale': obj_multi.sale_tax_rate, 'purchase': obj_multi.purchase_tax_rate, 'sale_tax': obj_multi.complete_tax and obj_multi.sale_tax.id or False, 'purchase_tax': obj_multi.complete_tax and obj_multi.purchase_tax.id or False, } - self._install_template(cr, uid, ids, obj_multi.chart_template_id.id, company_id, code_digits=obj_multi.code_digits, tax_data=tax_data, context=context) + if obj_multi.bank_accounts_id: + for acc in obj_multi.bank_accounts_id: + bank_jrnl_acc_list.append({ + 'acc_name': acc.acc_name, + 'account_type': acc.account_type, + 'currency_id': acc.currency_id.id, + }) + self._install_template(cr, uid, obj_multi.chart_template_id.id, company_id, code_digits=obj_multi.code_digits, tax_data=tax_data, bank_jrnl_acc_list = bank_jrnl_acc_list, context=context) + return {} wizard_multi_charts_accounts() From 2c061fda6d179e1c32af8e425ff31cd01630991e Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 31 Aug 2011 14:27:31 +0530 Subject: [PATCH 03/10] [IMP]: account: l10n fullness and inheritancy : Improved code of load taxes generate from float(taxes) fields bzr revid: ron@tinyerp.com-20110831085731-422kg6f0ogj0ufo7 --- addons/account/account.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index 6eec7393707..38d51a57190 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -3043,6 +3043,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): def _load_template(self, cr, uid, template_id, company_id, code_digits=None, tax_data={}, bank_jrnl_acc_list=[], context=None): 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_acc_tax = self.pool.get('account.tax') obj_tax_code = self.pool.get('account.tax.code') obj_tax_temp = self.pool.get('account.tax.template') obj_acc_template = self.pool.get('account.account.template') @@ -3050,7 +3051,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): ir_values_obj = self.pool.get('ir.values') # create tax templates and real taxes from purchase_tax_rate,sale_tax_rate fields - if not template.set_tax_complete: + if not template.set_tax_complete and tax_data: tax_dict = {'sale': tax_data['sale'], 'purchase': tax_data['purchase']} for tax_type, value in tax_dict.items(): tax_name = tax_type == 'sale' and 'TAX Received' or 'TAX Paid' From 952bf7ec2becfdbc2ea7a9da07dd34d14edccf95 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 31 Aug 2011 14:39:17 +0530 Subject: [PATCH 04/10] [ADD]: account: l10n fullness and inheritancy : 1)Add bank_journals in generate_journals() 2)create random generation of number for create journals bzr revid: ron@tinyerp.com-20110831090917-8ge4kpr25phz5a41 --- addons/account/account.py | 103 ++++++++++++++++++++++++++++++-------- 1 file changed, 81 insertions(+), 22 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 38d51a57190..af5972ad98f 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -20,6 +20,7 @@ ############################################################################## import time +import random from datetime import datetime from dateutil.relativedelta import relativedelta from operator import itemgetter @@ -2862,7 +2863,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): res['fields'][field]['selection'] = template_select return res - def generate_journals(self, cr, uid, chart_template_id, acc_template_ref, company_id, context=None): + def generate_journals(self, cr, uid, chart_template_id, acc_template_ref, company_id, bank_jrnl_acc_list, code_digits, context=None): """ This method used for creating journals. @param cr: A database cursor. @@ -2875,29 +2876,33 @@ class wizard_multi_charts_accounts(osv.osv_memory): obj_data = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') obj_journal = self.pool.get('account.journal') + obj_acc = self.pool.get('account.account') + template = self.pool.get('account.chart.template').browse(cr, uid, chart_template_id, context=context) data = obj_data.get_object_reference(cr, uid, 'account', 'account_sp_journal_view') view_id = data and data[1] or False - income_acc_id = acc_template_ref.get(chart_template_id.property_account_income_categ.id) - expense_acc_id = acc_template_ref.get(chart_template_id.property_account_expense_categ.id) - credit_acc_id = acc_template_ref.get(chart_template_id.property_account_income_opening.id) - debit_acc_id = acc_template_ref.get(chart_template_id.property_account_expense_opening.id) + income_acc_id = acc_template_ref.get(template.property_account_income_categ.id) + expense_acc_id = acc_template_ref.get(template.property_account_expense_categ.id) + credit_acc_id = acc_template_ref.get(template.property_account_income_opening.id) + debit_acc_id = acc_template_ref.get(template.property_account_expense_opening.id) + ref_acc_bank = template.bank_account_view_id #Sales Journal analytical_sale_ids = analytic_journal_obj.search(cr, uid, [('type','=','sale')], context=context) analytical_journal_sale = analytical_sale_ids and analytical_sale_ids[0] or False + file_no = str(random.randint(1,9)) vals_journal = { - 'name': _('Sales Journal'), + 'name': _('Sales Journal-%s') %(file_no), 'type': 'sale', - 'code': _('SAJ'), + 'code': _('SAJ%s') %(file_no), 'view_id': view_id, 'company_id': company_id, 'analytic_journal_id': analytical_journal_sale, } - if chart_template_id.property_account_receivable: + if template.property_account_receivable: vals_journal.update({ 'default_credit_account_id': income_acc_id, 'default_debit_account_id': income_acc_id @@ -2909,15 +2914,15 @@ class wizard_multi_charts_accounts(osv.osv_memory): analytical_journal_purchase = analytical_purchase_ids and analytical_purchase_ids[0] or False vals_journal = { - 'name': _('Purchase Journal'), + 'name': _('Purchase Journal-%s') %(file_no), 'type': 'purchase', - 'code': _('EXJ'), + 'code': _('EXJ%s') %(file_no), 'view_id': view_id, 'company_id': company_id, 'analytic_journal_id': analytical_journal_purchase, } - if chart_template_id.property_account_payable: + if template.property_account_payable: vals_journal.update({ 'default_credit_account_id': expense_acc_id, 'default_debit_account_id': expense_acc_id @@ -2930,14 +2935,14 @@ class wizard_multi_charts_accounts(osv.osv_memory): #Sales Refund Journal vals_journal = { - 'name': _('Sales Refund Journal'), + 'name': _('Sales Refund Journal-%s') %(file_no), 'type': 'sale_refund', - 'code': _('SCNJ'), + 'code': _('SCNJ%s') %(file_no), 'view_id': view_id, 'analytic_journal_id': analytical_journal_sale, 'company_id': company_id } - if chart_template_id.property_account_receivable: + if template.property_account_receivable: vals_journal.update({ 'default_credit_account_id': income_acc_id, 'default_debit_account_id': income_acc_id @@ -2946,14 +2951,14 @@ class wizard_multi_charts_accounts(osv.osv_memory): # Purchase Refund Journal vals_journal = { - 'name': _('Purchase Refund Journal'), + 'name': _('Purchase Refund Journal-%s') %(file_no), 'type': 'purchase_refund', - 'code': _('ECNJ'), + 'code': _('ECNJ%s') %(file_no), 'view_id': view_id, 'analytic_journal_id': analytical_journal_purchase, 'company_id': company_id } - if chart_template_id.property_account_payable: + if template.property_account_payable: vals_journal.update({ 'default_credit_account_id': expense_acc_id, 'default_debit_account_id': expense_acc_id @@ -2967,9 +2972,9 @@ class wizard_multi_charts_accounts(osv.osv_memory): analytical_miscellaneous_ids = analytic_journal_obj.search(cr, uid, [('type', '=', 'situation')], context=context) vals_journal = { - 'name': _('Miscellaneous Journal'), + 'name': _('Miscellaneous Journal%s') %(file_no), 'type': 'general', - 'code': _('MISC'), + 'code': _('MISC%s') %(file_no), 'view_id': view_id, 'analytic_journal_id': analytical_miscellaneous_ids and analytical_miscellaneous_ids[0] or False, 'company_id': company_id @@ -2977,11 +2982,11 @@ class wizard_multi_charts_accounts(osv.osv_memory): obj_journal.create(cr, uid, vals_journal, context=context) # Opening Entries Journal - if chart_template_id.property_account_income_opening and chart_template_id.property_account_expense_opening: + if template.property_account_income_opening and template.property_account_expense_opening: vals_journal = { - 'name': _('Opening Entries Journal'), + 'name': _('Opening Entries Journal%s') %(file_no), 'type': 'situation', - 'code': _('OPEJ'), + 'code': _('OPEJ%s') %(file_no), 'view_id': view_id, 'company_id': company_id, 'centralisation': True, @@ -2989,6 +2994,60 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'default_debit_account_id': debit_acc_id } obj_journal.create(cr, uid, vals_journal, context=context) + + data = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_bank_view_multi') + view_id_cur = data and data[1] or False + + data = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_bank_view') + view_id_cash = data and data[1] or False + + #Create Bank journals + current_num = 1 + valid = True + for line in bank_jrnl_acc_list: + #create the account_account for this bank journal + if not ref_acc_bank.code: + raise osv.except_osv(_('Configuration Error !'), _('The bank account defined on the selected chart of account hasn\'t a code.')) + while True: + new_code = str(ref_acc_bank.code.ljust(code_digits-len(str(current_num)), '0')) + str(current_num) + ids = obj_acc.search(cr, uid, [('code', '=', new_code), ('company_id', '=', company_id)]) + if not ids: + break + else: + current_num += 1 + user_type = self.pool.get('account.account.type').search(cr, uid, [('name', '=', line['account_type'])], context=context) + vals = { + 'name': line['acc_name'], + 'currency_id': line['currency_id'], + 'code': new_code, + 'type': 'liquidity', + 'user_type': 1, + 'reconcile': True, + 'parent_id': acc_template_ref[ref_acc_bank.id] or False, + 'company_id': company_id, + } + acc_cash_id = obj_acc.create(cr,uid,vals) + + #create the bank journal + vals_journal = { + 'name': vals['name'], + 'code': _('BNK') + str(current_num), + 'type': line['account_type'] == 'cash' and 'cash' or 'bank', + 'company_id': company_id, + 'analytic_journal_id': False, + 'currency_id': False, + } + if line['currency_id']: + vals_journal['view_id'] = view_id_cur + vals_journal['currency'] = line['currency_id'] + else: + vals_journal['view_id'] = view_id_cash + vals_journal['default_credit_account_id'] = acc_cash_id + vals_journal['default_debit_account_id'] = acc_cash_id + obj_journal.create(cr, uid, vals_journal) + current_num += 1 + valid = True + return True def generate_properties(self, cr, uid, chart_template_id, acc_template_ref, company_id, context=None): From 6c4bfe62155c1ebd37bff2f900acbe3b9b7b53ed Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 2 Sep 2011 11:45:31 +0530 Subject: [PATCH 05/10] [IMP]: account: l10n fullness and inheritancy : remove unused ToDO code and change generate_journalr() arguments bzr revid: ron@tinyerp.com-20110902061531-0way3cdxuppjhk3b --- addons/account/account.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index af5972ad98f..5eb2fa3dba8 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -3169,11 +3169,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): }) # Create Jourals - #TODO: pass template_id - self.generate_journals(cr, uid, template, acc_template_ref, company_id, context) - - # Create Bank Journals (Can be done in the generate_journals function) - #TODO: Create a new function + self.generate_journals(cr, uid, template_id, acc_template_ref, company_id, bank_jrnl_acc_list, code_digits, context) # generate properties function self.generate_properties(cr, uid, template_id, acc_template_ref, company_id, context=context) From 757b00368da72429c706d3782f0166a84ef2a199 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 2 Sep 2011 12:31:42 +0530 Subject: [PATCH 06/10] [IMP]: account: l10n fullness and inheritancy : Created comment(TODO check) for Dynamically create user_type on code and removed TODO code from tax generate bzr revid: ron@tinyerp.com-20110902070142-jaa3lc6qew0nhl4u --- addons/account/account.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index 5eb2fa3dba8..d0aded91b66 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -3015,6 +3015,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): break else: current_num += 1 + #TODO: create proper user_type for account creation. user_type = self.pool.get('account.account.type').search(cr, uid, [('name', '=', line['account_type'])], context=context) vals = { 'name': line['acc_name'], @@ -3134,7 +3135,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): }, context=context) - # create all the tax code [TOCHECK: finds children of tax_code_root_id and processes] + # create all the tax code. tax_code_template_ref = {} tax_code_root_id = template.tax_code_root_id.id children_tax_code_template = obj_tax_code_template.search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id') From 17f723709aed37c97f84e901a61aa769b6b72dbd Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 5 Sep 2011 11:34:44 +0530 Subject: [PATCH 07/10] [IMP]: account: l10n fullness and inheritancy : 1) Created common function journals_already_created() to check for not creating duplicated journals for same company 2)Removed random generated code used for creating journals bzr revid: ron@tinyerp.com-20110905060444-rp5ew8q4hwzqjrn3 --- addons/account/account.py | 49 ++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index d0aded91b66..5692123a24b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -20,7 +20,6 @@ ############################################################################## import time -import random from datetime import datetime from dateutil.relativedelta import relativedelta from operator import itemgetter @@ -2863,6 +2862,16 @@ class wizard_multi_charts_accounts(osv.osv_memory): res['fields'][field]['selection'] = template_select return res + def journals_already_created(self, cr, uid, name, vals_journal, company_id, context=None): + """ + This method used for checking journals already created or not. If not then create new journal. + """ + obj_journal = self.pool.get('account.journal') + rec_list = obj_journal.search(cr, uid, [('name','=', name),('company_id', '=', company_id)], context=context) + if not rec_list: + obj_journal.create(cr, uid, vals_journal, context=context) + return True + def generate_journals(self, cr, uid, chart_template_id, acc_template_ref, company_id, bank_jrnl_acc_list, code_digits, context=None): """ This method used for creating journals. @@ -2891,12 +2900,10 @@ class wizard_multi_charts_accounts(osv.osv_memory): #Sales Journal analytical_sale_ids = analytic_journal_obj.search(cr, uid, [('type','=','sale')], context=context) analytical_journal_sale = analytical_sale_ids and analytical_sale_ids[0] or False - - file_no = str(random.randint(1,9)) vals_journal = { - 'name': _('Sales Journal-%s') %(file_no), + 'name': _('Sales Journal'), 'type': 'sale', - 'code': _('SAJ%s') %(file_no), + 'code': _('SAJ'), 'view_id': view_id, 'company_id': company_id, 'analytic_journal_id': analytical_journal_sale, @@ -2907,16 +2914,16 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'default_credit_account_id': income_acc_id, 'default_debit_account_id': income_acc_id }) - obj_journal.create(cr, uid, vals_journal, context=context) + self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) # Purchase Journal analytical_purchase_ids = analytic_journal_obj.search(cr,uid,[('type','=','purchase')], context=context) analytical_journal_purchase = analytical_purchase_ids and analytical_purchase_ids[0] or False vals_journal = { - 'name': _('Purchase Journal-%s') %(file_no), + 'name': _('Purchase Journal'), 'type': 'purchase', - 'code': _('EXJ%s') %(file_no), + 'code': _('EXJ'), 'view_id': view_id, 'company_id': company_id, 'analytic_journal_id': analytical_journal_purchase, @@ -2927,7 +2934,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'default_credit_account_id': expense_acc_id, 'default_debit_account_id': expense_acc_id }) - obj_journal.create(cr, uid, vals_journal, context=context) + self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) # Creating Journals Sales Refund and Purchase Refund data = obj_data.get_object_reference(cr, uid, 'account', 'account_sp_refund_journal_view') @@ -2935,9 +2942,9 @@ class wizard_multi_charts_accounts(osv.osv_memory): #Sales Refund Journal vals_journal = { - 'name': _('Sales Refund Journal-%s') %(file_no), + 'name': _('Sales Refund Journal'), 'type': 'sale_refund', - 'code': _('SCNJ%s') %(file_no), + 'code': _('SCNJ'), 'view_id': view_id, 'analytic_journal_id': analytical_journal_sale, 'company_id': company_id @@ -2947,13 +2954,13 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'default_credit_account_id': income_acc_id, 'default_debit_account_id': income_acc_id }) - obj_journal.create(cr, uid, vals_journal, context=context) + self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) # Purchase Refund Journal vals_journal = { - 'name': _('Purchase Refund Journal-%s') %(file_no), + 'name': _('Purchase Refund Journal'), 'type': 'purchase_refund', - 'code': _('ECNJ%s') %(file_no), + 'code': _('ECNJ'), 'view_id': view_id, 'analytic_journal_id': analytical_journal_purchase, 'company_id': company_id @@ -2963,7 +2970,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'default_credit_account_id': expense_acc_id, 'default_debit_account_id': expense_acc_id }) - obj_journal.create(cr, uid, vals_journal, context=context) + self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) # Miscellaneous Journal data = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_view') @@ -2972,28 +2979,28 @@ class wizard_multi_charts_accounts(osv.osv_memory): analytical_miscellaneous_ids = analytic_journal_obj.search(cr, uid, [('type', '=', 'situation')], context=context) vals_journal = { - 'name': _('Miscellaneous Journal%s') %(file_no), + 'name': _('Miscellaneous Journal'), 'type': 'general', - 'code': _('MISC%s') %(file_no), + 'code': _('MISC'), 'view_id': view_id, 'analytic_journal_id': analytical_miscellaneous_ids and analytical_miscellaneous_ids[0] or False, 'company_id': company_id } - obj_journal.create(cr, uid, vals_journal, context=context) + self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) # Opening Entries Journal if template.property_account_income_opening and template.property_account_expense_opening: vals_journal = { - 'name': _('Opening Entries Journal%s') %(file_no), + 'name': _('Opening Entries Journal'), 'type': 'situation', - 'code': _('OPEJ%s') %(file_no), + 'code': _('OPEJ'), 'view_id': view_id, 'company_id': company_id, 'centralisation': True, 'default_credit_account_id': credit_acc_id, 'default_debit_account_id': debit_acc_id } - obj_journal.create(cr, uid, vals_journal, context=context) + self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) data = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_bank_view_multi') view_id_cur = data and data[1] or False From 93c2c6cc88ced75b6a313b080019f2016d237980 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 5 Sep 2011 14:42:31 +0530 Subject: [PATCH 08/10] [IMP]: account: l10n fullness and inheritancy : Removed account_root_id as browse record argument from generate_account() bzr revid: ron@tinyerp.com-20110905091231-h7swueipnd5lfrae --- addons/account/account.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index f98ae574684..e9085282111 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2377,7 +2377,7 @@ class account_account_template(osv.osv): res.append((record['id'],name )) return res - def generate_account(self, cr, uid, template_id, account_root_id, tax_template_ref, code_digits, company_id, context=None): + def generate_account(self, cr, uid, template_id, tax_template_ref, code_digits, company_id, context=None): """ This method for generating accounts from templates. @param cr: A database cursor. @@ -2393,11 +2393,12 @@ class account_account_template(osv.osv): context = {} obj_acc = self.pool.get('account.account') company_name = self.pool.get('res.company').browse(cr, uid, company_id, context=context).name + template = self.pool.get('account.chart.template').browse(cr, uid, template_id, context=context) acc_template_ref = {} #deactivate the parent_store functionnality on account_account for rapidity purpose ctx = context.copy() ctx.update({'defer_parent_store_computation': True}) - children_acc_template = self.search(cr, uid, [('parent_id','child_of', [account_root_id]),'|', ('chart_template_id','=', [template_id]),('chart_template_id','=', False), ('nocreate','!=',True)], order='id') + children_acc_template = self.search(cr, uid, [('parent_id','child_of', [template.account_root_id.id]),'|', ('chart_template_id','=', [template_id]),('chart_template_id','=', False), ('nocreate','!=',True)], order='id') for account_template in self.browse(cr, uid, children_acc_template, context=context): tax_ids = [] for tax in account_template.tax_ids: @@ -2408,7 +2409,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 == account_template.id) and company_name or account_template.name, + 'name': (template.account_root_id.id == account_template.id) and company_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, @@ -3167,7 +3168,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): taxes_ref = obj_tax_temp.generate_tax(cr, uid, tax_templates, tax_code_template_ref, company_id, context=context) # Generating Accounts from templates. - acc_template_ref = obj_acc_template.generate_account(cr, uid, template_id, template.account_root_id.id, taxes_ref['tax_template_ref'], code_digits, company_id, context=context) + acc_template_ref = obj_acc_template.generate_account(cr, uid, template_id, taxes_ref['tax_template_ref'], code_digits, company_id, context=context) # writing account values on tax after creation of accounts for key,value in taxes_ref['account_dict'].items(): From 88bc353ca716d9a6453de2a6d8cc5d2ee48ecb73 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 5 Sep 2011 15:28:14 +0530 Subject: [PATCH 09/10] [IMP]: account: l10n fullness and inheritancy : Improved code of journals_already_created in vals_journal argument bzr revid: ron@tinyerp.com-20110905095814-n9o6a9w7h4dqdobf --- addons/account/account.py | 16 ++++++++-------- addons/l10n_multilang/__openerp__.py | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index e9085282111..554b94f6d9f 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2864,12 +2864,12 @@ class wizard_multi_charts_accounts(osv.osv_memory): res['fields'][field]['selection'] = template_select return res - def journals_already_created(self, cr, uid, name, vals_journal, company_id, context=None): + def journals_already_created(self, cr, uid, vals_journal, company_id, context=None): """ This method used for checking journals already created or not. If not then create new journal. """ obj_journal = self.pool.get('account.journal') - rec_list = obj_journal.search(cr, uid, [('name','=', name),('company_id', '=', company_id)], context=context) + rec_list = obj_journal.search(cr, uid, [('name','=', vals_journal['name']),('company_id', '=', company_id)], context=context) if not rec_list: obj_journal.create(cr, uid, vals_journal, context=context) return True @@ -2916,7 +2916,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'default_credit_account_id': income_acc_id, 'default_debit_account_id': income_acc_id }) - self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) + self.journals_already_created(cr, uid, vals_journal, company_id, context=context) # Purchase Journal analytical_purchase_ids = analytic_journal_obj.search(cr,uid,[('type','=','purchase')], context=context) @@ -2936,7 +2936,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'default_credit_account_id': expense_acc_id, 'default_debit_account_id': expense_acc_id }) - self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) + self.journals_already_created(cr, uid, vals_journal, company_id, context=context) # Creating Journals Sales Refund and Purchase Refund data = obj_data.get_object_reference(cr, uid, 'account', 'account_sp_refund_journal_view') @@ -2956,7 +2956,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'default_credit_account_id': income_acc_id, 'default_debit_account_id': income_acc_id }) - self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) + self.journals_already_created(cr, uid, vals_journal, company_id, context=context) # Purchase Refund Journal vals_journal = { @@ -2972,7 +2972,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'default_credit_account_id': expense_acc_id, 'default_debit_account_id': expense_acc_id }) - self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) + self.journals_already_created(cr, uid, vals_journal, company_id, context=context) # Miscellaneous Journal data = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_view') @@ -2988,7 +2988,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'analytic_journal_id': analytical_miscellaneous_ids and analytical_miscellaneous_ids[0] or False, 'company_id': company_id } - self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) + self.journals_already_created(cr, uid, vals_journal, company_id, context=context) # Opening Entries Journal if template.property_account_income_opening and template.property_account_expense_opening: @@ -3002,7 +3002,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'default_credit_account_id': credit_acc_id, 'default_debit_account_id': debit_acc_id } - self.journals_already_created(cr, uid, vals_journal['name'], vals_journal, company_id, context=context) + self.journals_already_created(cr, uid, vals_journal, company_id, context=context) data = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_bank_view_multi') view_id_cur = data and data[1] or False diff --git a/addons/l10n_multilang/__openerp__.py b/addons/l10n_multilang/__openerp__.py index bdb13afd7b4..45a7d1c676d 100644 --- a/addons/l10n_multilang/__openerp__.py +++ b/addons/l10n_multilang/__openerp__.py @@ -36,9 +36,10 @@ "depends" : ['account_accountant'], 'update_xml': [ 'l10n_multilang.xml', + 'l10n_multilang_demo.xml' ], 'demo_xml': [ - 'l10n_multilang_demo.xml' + ], 'installable': True, 'active': False, From abbc74de99ad9602980b0ae4985c3c8e97e3390c Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 5 Sep 2011 18:58:36 +0530 Subject: [PATCH 10/10] [IMP]: account: l10n fullness and inheritancy : Removed duplicate tax_code genearted from tax_code_template and improved code(name field) bzr revid: ron@tinyerp.com-20110905132836-7dletz0qr3ti5n72 --- addons/account/account.py | 10 ++++++---- addons/l10n_multilang/__openerp__.py | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 554b94f6d9f..a58fedba7be 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -3151,16 +3151,18 @@ class wizard_multi_charts_accounts(osv.osv_memory): company_name = self.pool.get('res.company').browse(cr, uid, company_id, context=context) for tax_code_template in obj_tax_code_template.browse(cr, uid, children_tax_code_template, context=context): vals = { - 'name': (tax_code_root_id == tax_code_template.id) and company_name or tax_code_template.name, + 'name': (tax_code_root_id == tax_code_template.id) and company_name.name or tax_code_template.name, 'code': tax_code_template.code, 'info': tax_code_template.info, 'parent_id': tax_code_template.parent_id and ((tax_code_template.parent_id.id in tax_code_template_ref) and tax_code_template_ref[tax_code_template.parent_id.id]) or False, 'company_id': company_id, 'sign': tax_code_template.sign, } - new_tax_code = obj_tax_code.create(cr, uid, vals) - #recording the new tax code to do the mapping - tax_code_template_ref[tax_code_template.id] = new_tax_code + rec_list = obj_tax_code.search(cr, uid, [('name', '=', vals['name']),('company_id', '=', vals['company_id'])], context=context) + if not rec_list: + new_tax_code = obj_tax_code.create(cr, uid, vals) + #recording the new tax code to do the mapping + tax_code_template_ref[tax_code_template.id] = new_tax_code # Generate taxes from templates. tax_template_to_tax = {} diff --git a/addons/l10n_multilang/__openerp__.py b/addons/l10n_multilang/__openerp__.py index 45a7d1c676d..bdb13afd7b4 100644 --- a/addons/l10n_multilang/__openerp__.py +++ b/addons/l10n_multilang/__openerp__.py @@ -36,10 +36,9 @@ "depends" : ['account_accountant'], 'update_xml': [ 'l10n_multilang.xml', - 'l10n_multilang_demo.xml' ], 'demo_xml': [ - + 'l10n_multilang_demo.xml' ], 'installable': True, 'active': False,