diff --git a/addons/account/account.py b/addons/account/account.py index 3abbe4cef2e..ada9a12cb4a 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -805,19 +805,28 @@ class account_fiscalyear(osv.osv): (_check_fiscal_year, 'Error! You cannot define overlapping fiscal years',['date_start', 'date_stop']) ] - def create_period3(self,cr, uid, ids, context=None): + def create_period3(self, cr, uid, ids, context=None): return self.create_period(cr, uid, ids, context, 3) - def create_period(self,cr, uid, ids, context=None, interval=1): + def create_period(self, cr, uid, ids, context=None, interval=1): + period_obj = self.pool.get('account.period') for fy in self.browse(cr, uid, ids, context=context): ds = datetime.strptime(fy.date_start, '%Y-%m-%d') - while ds.strftime('%Y-%m-%d')fy.date_stop: + if de.strftime('%Y-%m-%d') > fy.date_stop: de = datetime.strptime(fy.date_stop, '%Y-%m-%d') - self.pool.get('account.period').create(cr, uid, { + period_obj.create(cr, uid, { 'name': ds.strftime('%m/%Y'), 'code': ds.strftime('%m/%Y'), 'date_start': ds.strftime('%Y-%m-%d'), @@ -2449,6 +2458,8 @@ class account_chart_template(osv.osv): 'property_account_expense': fields.many2one('account.account.template','Expense Account on Product Template'), 'property_account_income': fields.many2one('account.account.template','Income Account on Product Template'), 'property_reserve_and_surplus_account': fields.many2one('account.account.template', 'Reserve and Profit/Loss Account', domain=[('type', '=', 'payable')], help='This Account is used for transferring Profit/Loss(If It is Profit: Amount will be added, Loss: Amount will be deducted.), Which is calculated from Profilt & Loss Report'), + 'property_account_income_opening': fields.many2one('account.account.template','Opening Entries Income Account'), + 'property_account_expense_opening': fields.many2one('account.account.template','Opening Entries Expense Account'), } account_chart_template() @@ -2681,6 +2692,7 @@ 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_tax_code = self.pool.get('account.tax.code') + obj_tax_code_template = self.pool.get('account.tax.code.template') # Creating Account 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 @@ -2693,9 +2705,9 @@ class wizard_multi_charts_accounts(osv.osv_memory): todo_dict = {} #create all the tax code - children_tax_code_template = self.pool.get('account.tax.code.template').search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id') + children_tax_code_template = obj_tax_code_template.search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id') children_tax_code_template.sort() - for tax_code_template in self.pool.get('account.tax.code.template').browse(cr, uid, children_tax_code_template, 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 obj_multi.company_id.name or tax_code_template.name, 'code': tax_code_template.code, @@ -2806,11 +2818,15 @@ class wizard_multi_charts_accounts(osv.osv_memory): seq_id_purchase_refund = obj_sequence.search(cr, uid, [('name','=','Purchase Refund Journal')]) if seq_id_purchase_refund: seq_id_purchase_refund = seq_id_purchase_refund[0] + seq_id_opening = obj_sequence.search(cr, uid, [('name','=','Opening Entries Journal')]) + if seq_id_opening: + seq_id_opening = seq_id_opening[0] else: seq_id_sale = seq_id seq_id_purchase = seq_id seq_id_sale_refund = seq_id seq_id_purchase_refund = seq_id + seq_id_opening = seq_id vals_journal['view_id'] = view_id @@ -2903,6 +2919,21 @@ class wizard_multi_charts_accounts(osv.osv_memory): # }) obj_journal.create(cr, uid, vals_journal, context=context) + # Opening Entries Journal + if obj_multi.chart_template_id.property_account_income_opening and obj_multi.chart_template_id.property_account_expense_opening: + vals_journal = { + 'view_id': view_id, + 'name': _('Opening Entries Journal'), + 'type': 'situation', + 'code': _('TOEJ'), + 'sequence_id': seq_id_opening, + 'analytic_journal_id': analitical_journal_purchase, + 'company_id': company_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) + # Bank Journals data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')]) data = obj_data.browse(cr, uid, data_id[0], context=context) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 1812e800880..cafc99b51de 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -2150,6 +2150,8 @@ + + diff --git a/addons/account/configurable_account_chart.xml b/addons/account/configurable_account_chart.xml index dd9c01142c3..4734e030113 100644 --- a/addons/account/configurable_account_chart.xml +++ b/addons/account/configurable_account_chart.xml @@ -191,6 +191,14 @@ + + 1106 + Opening Income Account + + closed + + + 111 Current Liabilities @@ -225,6 +233,13 @@ + + 1114 + Opening Expense Account + + closed + + @@ -431,6 +446,8 @@ + + diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index 65184b3d130..6ae6188ec62 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -421,6 +421,15 @@ + + Miscellaneous Journal - (test) + TMIS + general + + + + +