diff --git a/addons/account/account.py b/addons/account/account.py
index 64658550ae5..1ced6bd88e8 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -1563,65 +1563,64 @@ class account_config_fiscalyear(osv.osv_memory):
account_config_fiscalyear()
-
-class account_config_journal_bank_accounts(osv.osv_memory):
- _name='account.config.journal.bank.account'
- _columns = {
- 'name':fields.char('Journal Name', size=64),
- 'lines_id': fields.one2many('account.config.journal.bank.account.line', 'journal_id', 'Journal Lines'),
- }
-
- def action_cancel(self,cr,uid,ids,conect=None):
- return {
- 'view_type': 'form',
- "view_mode": 'form',
- 'res_model': 'ir.module.module.configuration.wizard',
- 'type': 'ir.actions.act_window',
- 'target':'new',
- }
-
- def action_create(self, cr, uid, ids, context=None):
- config_res=self.read(cr,uid,ids)[0]
- res_obj = self.pool.get('account.journal')
- line_obj=self.pool.get('account.config.journal.bank.account.line')
- if 'lines_id' in config_res and config_res['lines_id']:
- lines=line_obj.read(cr,uid,config_res['lines_id'])
- for res in lines:
- sequence_ids=self.pool.get('ir.sequence').search(cr,uid,[('name','=','Account Journal')])
- if 'name' in res and 'bank_account_id' in res and 'view_id' in res and sequence_ids and len(sequence_ids):
- vals={
- 'name':res['name'],
- 'type':'cash',
- 'view_id':res['view_id'],
- 'default_credit_account_id':res['bank_account_id'],
- 'default_debit_account_id':res['bank_account_id'],
- 'sequence_id':sequence_ids[0]
- }
- res_obj.create(cr, uid, vals, context=context)
- return {
- 'view_type': 'form',
- "view_mode": 'form',
- 'res_model': 'ir.module.module.configuration.wizard',
- 'type': 'ir.actions.act_window',
- 'target':'new',
- }
-
-account_config_journal_bank_accounts()
-
-class account_config_journal_bank_accounts_line(osv.osv_memory):
- _name='account.config.journal.bank.account.line'
- def _journal_view_get(self, cr, uid, context={}):
- journal_obj = self.pool.get('account.journal.view')
- ids = journal_obj.search(cr, uid, [])
- res = journal_obj.read(cr, uid, ids, ['id', 'name'], context)
- return [(r['id'], r['name']) for r in res]
- _columns = {
- 'name':fields.char('Journal Name', size=64,required=True),
- 'bank_account_id':fields.many2one('account.account', 'Bank Account', required=True, domain=[('type','=','cash')]),
- 'view_id':fields.selection(_journal_view_get, 'Journal View', required=True),
- 'journal_id':fields.many2one('account.config.journal.bank.account', 'Journal', required=True),
- }
-account_config_journal_bank_accounts_line()
+#class account_config_journal_bank_accounts(osv.osv_memory):
+# _name='account.config.journal.bank.account'
+# _columns = {
+# 'name':fields.char('Journal Name', size=64),
+# 'lines_id': fields.one2many('account.config.journal.bank.account.line', 'journal_id', 'Journal Lines'),
+# }
+#
+# def action_cancel(self,cr,uid,ids,conect=None):
+# return {
+# 'view_type': 'form',
+# "view_mode": 'form',
+# 'res_model': 'ir.module.module.configuration.wizard',
+# 'type': 'ir.actions.act_window',
+# 'target':'new',
+# }
+#
+# def action_create(self, cr, uid, ids, context=None):
+# config_res=self.read(cr,uid,ids)[0]
+# res_obj = self.pool.get('account.journal')
+# line_obj=self.pool.get('account.config.journal.bank.account.line')
+# if 'lines_id' in config_res and config_res['lines_id']:
+# lines=line_obj.read(cr,uid,config_res['lines_id'])
+# for res in lines:
+# sequence_ids=self.pool.get('ir.sequence').search(cr,uid,[('name','=','Account Journal')])
+# if 'name' in res and 'bank_account_id' in res and 'view_id' in res and sequence_ids and len(sequence_ids):
+# vals={
+# 'name':res['name'],
+# 'type':'cash',
+# 'view_id':res['view_id'],
+# 'default_credit_account_id':res['bank_account_id'],
+# 'default_debit_account_id':res['bank_account_id'],
+# 'sequence_id':sequence_ids[0]
+# }
+# res_obj.create(cr, uid, vals, context=context)
+# return {
+# 'view_type': 'form',
+# "view_mode": 'form',
+# 'res_model': 'ir.module.module.configuration.wizard',
+# 'type': 'ir.actions.act_window',
+# 'target':'new',
+# }
+#
+#account_config_journal_bank_accounts()
+#
+#class account_config_journal_bank_accounts_line(osv.osv_memory):
+# _name='account.config.journal.bank.account.line'
+# def _journal_view_get(self, cr, uid, context={}):
+# journal_obj = self.pool.get('account.journal.view')
+# ids = journal_obj.search(cr, uid, [])
+# res = journal_obj.read(cr, uid, ids, ['id', 'name'], context)
+# return [(r['id'], r['name']) for r in res]
+# _columns = {
+# 'name':fields.char('Journal Name', size=64,required=True),
+# 'bank_account_id':fields.many2one('account.account', 'Bank Account', required=True, domain=[('type','=','cash')]),
+# 'view_id':fields.selection(_journal_view_get, 'Journal View', required=True),
+# 'journal_id':fields.many2one('account.config.journal.bank.account', 'Journal', required=True),
+# }
+#account_config_journal_bank_accounts_line()
# ----------------------------------------------
# Account Templates : Account, Tax and charts.
@@ -1708,6 +1707,7 @@ class account_tax_code_template(osv.osv):
'code': fields.char('Case Code', size=16),
'info': fields.text('Description'),
'parent_id': fields.many2one('account.tax.code.template', 'Parent Code', select=True),
+ 'child_ids': fields.one2many('account.tax.code.template', 'parent_id', 'Childs Codes'),
'company_id': fields.many2one('res.company', 'Company', required=True),
'sign': fields.float('Sign for parent', required=True),
}
@@ -1780,8 +1780,7 @@ class account_tax_template(osv.osv):
'name': fields.char('Tax Name', size=64, required=True),
'sequence': fields.integer('Sequence', required=True, help="The sequence field is used to order the taxes lines from the lowest sequences to the higher ones. The order is important if you have a tax that have several tax children. In this case, the evaluation order is important."),
'amount': fields.float('Amount', required=True, digits=(14,4)),
-# 'type': fields.selection( [('percent','Percent'), ('fixed','Fixed'), ('none','None'), ('code','Python Code')], 'Tax Type', required=True),
- 'type': fields.selection( [('percent','Percent'), ('fixed','Fixed'), ('none','None')],'Tax Type', required=True),
+ 'type': fields.selection( [('percent','Percent'), ('fixed','Fixed'), ('none','None'), ('code','Python Code')], 'Tax Type', required=True),
'applicable_type': fields.selection( [('true','True'), ('code','Python Code')], 'Applicable Type', required=True),
'domain':fields.char('Domain', size=32, help="This field is only used if you develop your own module allowing developers to create specific taxes in a custom domain."),
'account_collected_id':fields.many2one('account.account.template', 'Invoice Tax Account'),
@@ -1854,6 +1853,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'company_id':fields.many2one('res.company','Company',required=True),
'chart_template_id': fields.many2one('account.chart.template','Chart Template',required=True),
'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Bank Accounts',required=True),
+ 'code_digits':fields.integer('No. of Digits for Account Code',required=True),
}
#global seq
@@ -1866,6 +1866,9 @@ class wizard_multi_charts_accounts(osv.osv_memory):
obj_journal = self.pool.get('account.journal')
obj_acc_template = self.pool.get('account.account.template')
+ if obj_multi.code_digits<=5:
+ raise osv.except_osv(_('User Error'), _('Account code should be of more than 5 digits.'))
+
# 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
@@ -1888,7 +1891,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'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,
'info': tax_code_template.info,
- 'parent_id': tax_code_template.parent_id and tax_code_template_ref[tax_code_template.parent_id.id] or False,
+ '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,
}
@@ -1906,7 +1909,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'type':tax.type,
'applicable_type': tax.applicable_type,
'domain':tax.domain,
- 'parent_id': tax.parent_id and tax_template_ref[tax.parent_id.id] or False,
+ 'parent_id': tax.parent_id and ((tax.parent_id.id in tax_template_ref) and tax_template_ref[tax.parent_id.id]) or False,
'child_depend': tax.child_depend,
'python_compute': tax.python_compute,
'python_compute_inv': tax.python_compute_inv,
@@ -1932,7 +1935,6 @@ class wizard_multi_charts_accounts(osv.osv_memory):
}
tax_template_ref[tax.id] = new_tax
-
#deactivate the parent_store functionnality on account_account for rapidity purpose
self.pool._init = True
children_acc_template = obj_acc_template.search(cr, uid, [('parent_id','child_of',[obj_acc_root.id])])
@@ -1941,17 +1943,22 @@ class wizard_multi_charts_accounts(osv.osv_memory):
for tax in account_template.tax_ids:
tax_ids.append(tax_template_ref[tax.id])
#create the account_account
+ dig=obj_multi.code_digits
+ code_main=len(account_template.code)
+ code_acc=account_template.code
+ if code_main<=dig:
+ code_acc=str(code_acc) + (str('0'*(dig-code_main)))
vals={
'name': (obj_acc_root.id == account_template.id) and obj_multi.company_id.name or account_template.name,
#'sign': account_template.sign,
'currency_id': account_template.currency_id and account_template.currency_id.id or False,
- 'code': account_template.code,
+ 'code': code_acc[:dig],
'type': account_template.type,
'user_type': account_template.user_type or False,
'reconcile': account_template.reconcile,
'shortcut': account_template.shortcut,
'note': account_template.note,
- 'parent_id': account_template.parent_id and acc_template_ref[account_template.parent_id.id] or False,
+ 'parent_id': account_template.parent_id and ((account_template.parent_id.id in acc_template_ref) and acc_template_ref[account_template.parent_id.id]) or False,
'tax_ids': [(6,0,tax_ids)],
'company_id': company_id,
}
@@ -2014,7 +2021,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
#'sign': ref_acc_bank.sign,
'currency_id': line.currency_id and line.currency_id.id or False,
'code': ref_acc_bank.code+str(current_num),
- 'type': 'cash',
+ 'type': 'other',
'user_type': account_template.user_type or False,
'reconcile': True,
'parent_id': acc_template_ref[ref_acc_bank.id] or False,
@@ -2100,7 +2107,6 @@ class wizard_account_chart_duplicate(osv.osv_memory):
'name':fields.char('Name',size=64),
'account_id':fields.many2one('account.account','Account Chart',required=True,domain=[('parent_id','=',False)]),
'company_id':fields.many2one('res.company','Company',required=True),
-
}
def action_create(self, cr, uid,ids, context=None):
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index a81e55824ec..7a44e823b79 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -1415,9 +1415,7 @@
new
-
-
-
+
@@ -1463,12 +1461,12 @@
open
-
+
@@ -1572,15 +1570,50 @@
form
@@ -1604,6 +1637,37 @@
+
+
+ account.tax.code.template.tree
+ account.tax.code.template
+ tree
+ child_ids
+
+
+
+
+
+
+
+
+
+ account.tax.code.template.form
+ account.tax.code.template
+ form
+
+
+
+
+
Account Tax Code Templates
account.tax.code.template
@@ -1613,7 +1677,6 @@
-
@@ -1624,6 +1687,7 @@