From 2086c6085e98e77ef0e59c0136cf48a0b85dc13e Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Fri, 24 Oct 2008 11:20:34 +0530 Subject: [PATCH 1/2] account.period: -> now we can open a close period but with specified role (period) in res.users only bzr revid: mra@tinyerp.com-20081024055034-o59unxwdlnk5os7k --- addons/account/account.py | 11 +++++++++++ addons/account/account_view.xml | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/addons/account/account.py b/addons/account/account.py index dbff7730fc9..e7304065b8d 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -562,6 +562,17 @@ class account_period(osv.osv): if not ids: raise osv.except_osv(_('Error !'), _('No period defined for this date !\nPlease create a fiscal year.')) return ids + + def action_draft(self, cr, uid, ids, *args): + users_roles = self.pool.get('res.users').browse(cr, uid, uid).roles_id + for role in users_roles: + if role.name=='Period': + mode = 'draft' + for id in ids: + cr.execute('update account_journal_period set state=%s where period_id=%d', (mode, id)) + cr.execute('update account_period set state=%s where id=%d', (mode, id)) + return True + account_period() class account_journal_period(osv.osv): diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 6b793707cb4..31b6c73d179 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -60,6 +60,9 @@ + + + account.period.form @@ -74,6 +77,7 @@ +