Close fiscal year wizard usable for a multi company database

Registered by André Kurz (Hasa.ch)

The "Close a fiscal year" wizard doesn't allow to do a closure in a multi company database.

People normally use record rules to show only the account of their company, and that's a problem when this wizard wants to access an account of another company. So, I added these lines in the wizard to access only the account from the company of the user and now I can do my closure in a multi company database.

Maybe there is already a solution in OpenERP 5 like that or maybe there should be one. This is usable too for a single company database.

+++ /home/andre/Desktop/tinyerp-server/addons/account/wizard/wizard_fiscalyear_close.py 2008-12-18 17:47:22.000000000 +0100
@@ -75,6 +75,11 @@
                                obj='account_move_line', context={'fiscalyear': fy_id})
                cr.execute('select id from account_account WHERE active')
                ids = map(lambda x: x[0], cr.fetchall())
+ #we give a new value to ids which are only the account that belong to the user company
+ user = pool.get('res.users').browse(cr, uid, uid)
+ ids = pool.get('account.account').search(cr, uid, [('company_id','=',user.company_id['id']),('active','=',True)])
                for account in pool.get('account.account').browse(cr, uid, ids,
                        context={'fiscalyear': fy_id}):

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.