diff --git a/addons/account/account.py b/addons/account/account.py index 8cccd7e3be5..9e431f65e7b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -538,7 +538,7 @@ class account_account(osv.osv): def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} - + if 'company_id' in vals: move_lines = self.pool.get('account.move.line').search(cr, uid, [('account_id', 'in', ids)]) if move_lines: @@ -1149,8 +1149,26 @@ class account_move(osv.osv): else: raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !')) return True - + def button_validate(self, cursor, user, ids, context=None): + def _get_chart_account(cursor, user, account): + if account.parent_id: + chart_account = _get_chart_account(cursor, user, account.parent_id) + else: + chart_account = account + return chart_account + + for move in self.browse(cursor, user, ids): + lines = move.line_id + if lines: + ref_line = lines[0] + ref_chart_account = _get_chart_account(cursor, user, ref_line.account_id) + parent_left = ref_chart_account.parent_left + parent_right = ref_chart_account.parent_right + result = True + for line in lines[1:]: + if not(line.account_id.parent_left > parent_left and line.account_id.parent_left < parent_right): + raise osv.except_osv(_('Error !'), _('You cannot validate a move unless accounts in its entry lines are in same Chart Of Accounts !')) return self.post(cursor, user, ids, context=context) def button_cancel(self, cr, uid, ids, context={}): diff --git a/addons/account/wizard/account_chart.py b/addons/account/wizard/account_chart.py index f7de4b593f3..3d5f308f7bd 100644 --- a/addons/account/wizard/account_chart.py +++ b/addons/account/wizard/account_chart.py @@ -24,7 +24,7 @@ from tools.translate import _ class account_chart(osv.osv_memory): """ - For Chart of Accounrs + For Chart of Accounts """ _name = "account.chart" _description = "Account chart"