From eb69ddcce0c432d9648cb57661e4206d1d019adb Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Fri, 9 Dec 2011 15:18:44 +0530 Subject: [PATCH 1/3] [FIX] account : Can close period evenif there is unposted items on period lp bug: https://launchpad.net/bugs/901554 fixed bzr revid: mdi@tinyerp.com-20111209094844-sva1jl3l9v5k63e2 --- addons/account/wizard/account_period_close.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/account/wizard/account_period_close.py b/addons/account/wizard/account_period_close.py index 5b7589d7830..5a46add8150 100644 --- a/addons/account/wizard/account_period_close.py +++ b/addons/account/wizard/account_period_close.py @@ -20,6 +20,7 @@ ############################################################################## from osv import fields, osv +from tools.translate import _ class account_period_close(osv.osv_memory): """ @@ -39,11 +40,16 @@ class account_period_close(osv.osv_memory): @param ids: account period close’s ID or list of IDs """ period_pool = self.pool.get('account.period') + account_move_obj = self.pool.get('account.move') mode = 'done' for form in self.read(cr, uid, ids, context=context): if form['sure']: for id in context['active_ids']: + account_move_ids = account_move_obj.search(cr, uid, [('period_id', '=', id)], context=context) + if account_move_ids: + raise osv.except_osv(_('Invalid action !'), _('In order to close a period, you must first post related journal items.')) + cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id)) cr.execute('update account_period set state=%s where id=%s', (mode, id)) From c2aae9e46caa8585a39e7476eb059cb4287d958a Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Fri, 9 Dec 2011 15:22:22 +0530 Subject: [PATCH 2/3] [IMP] account : Improved the code bzr revid: mdi@tinyerp.com-20111209095222-43eo3pulebwdtapy --- addons/account/wizard/account_period_close.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/wizard/account_period_close.py b/addons/account/wizard/account_period_close.py index 5a46add8150..5217b119939 100644 --- a/addons/account/wizard/account_period_close.py +++ b/addons/account/wizard/account_period_close.py @@ -46,7 +46,7 @@ class account_period_close(osv.osv_memory): for form in self.read(cr, uid, ids, context=context): if form['sure']: for id in context['active_ids']: - account_move_ids = account_move_obj.search(cr, uid, [('period_id', '=', id)], context=context) + account_move_ids = account_move_obj.search(cr, uid, [('period_id', '=', id), ('state', '=', "draft")], context=context) if account_move_ids: raise osv.except_osv(_('Invalid action !'), _('In order to close a period, you must first post related journal items.')) From 430734a449b636610ad9b48a91c09aec98758b5a Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Tue, 13 Dec 2011 10:11:48 +0530 Subject: [PATCH 3/3] [IMP] account : Improved the error message bzr revid: mdi@tinyerp.com-20111213044148-c98n11r8vta387i8 --- addons/account/wizard/account_period_close.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/wizard/account_period_close.py b/addons/account/wizard/account_period_close.py index 5217b119939..fecf43f07ab 100644 --- a/addons/account/wizard/account_period_close.py +++ b/addons/account/wizard/account_period_close.py @@ -48,7 +48,7 @@ class account_period_close(osv.osv_memory): for id in context['active_ids']: account_move_ids = account_move_obj.search(cr, uid, [('period_id', '=', id), ('state', '=', "draft")], context=context) if account_move_ids: - raise osv.except_osv(_('Invalid action !'), _('In order to close a period, you must first post related journal items.')) + raise osv.except_osv(_('Invalid action !'), _('In order to close a period, you must first post related journal entries.')) cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id)) cr.execute('update account_period set state=%s where id=%s', (mode, id))