From 6c1525d84994774f9c31f1531639701fa966ff1f Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Tue, 25 Oct 2011 18:20:01 +0200 Subject: [PATCH] [IMP] account: find() method of account.fiscalyear will now filter correctly on company_id if needed bzr revid: qdp-launchpad@openerp.com-20111025162001-6um2vm5f277bf0n2 --- addons/account/account.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index dcf5c474077..865fc1c44d8 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -901,9 +901,16 @@ class account_fiscalyear(osv.osv): return True def find(self, cr, uid, dt=None, exception=True, context=None): + if context is None: context = {} if not dt: dt = time.strftime('%Y-%m-%d') - ids = self.search(cr, uid, [('date_start', '<=', dt), ('date_stop', '>=', dt)]) + args = [('date_start', '<=' ,dt), ('date_stop', '>=', dt)] + if context.get('company_id', False): + args.append(('company_id', '=', context['company_id'])) + else: + company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id + args.append(('company_id', '=', company_id)) + ids = self.search(cr, uid, args, context=context) if not ids: if exception: raise osv.except_osv(_('Error !'), _('No fiscal year defined for this date !\nPlease create one.'))