summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Trigaux <mat@openerp.com>2013-05-08 14:34:40 +0200
committerMartin Trigaux <mat@openerp.com>2013-05-08 14:34:40 +0200
commitf2c5aee290db938fa084513a1bdfb5bee3cee783 (patch)
tree1396723ec6d64dcdfcb5464261918ce8f912016f
parentdff5615b9ee7882e05121858d405a96f117cf664 (diff)
[IMP] account: use DEFAULT_SERVER_DATETIME_FORMAT
bzr revid: mat@openerp.com-20130508123440-kmtbv1vq4x03gr8k
-rw-r--r--addons/account/res_config.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/addons/account/res_config.py b/addons/account/res_config.py
index 7d164f73f94..adce6814b25 100644
--- a/addons/account/res_config.py
+++ b/addons/account/res_config.py
@@ -25,6 +25,7 @@ from dateutil.relativedelta import relativedelta
from operator import itemgetter
from os.path import join as opj
+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT as DF
from openerp.tools.translate import _
from openerp.osv import fields, osv
from openerp import tools
@@ -140,18 +141,18 @@ class account_config_settings(osv.osv_memory):
"""
company_id = self._default_company(cr, uid, context=context)
fiscalyear_ids = self.pool.get('account.fiscalyear').search(cr, uid,
- [('date_start', '<=', time.strftime('%Y-%m-%d')), ('date_stop', '>=', time.strftime('%Y-%m-%d')),
+ [('date_start', '<=', time.strftime(DF)), ('date_stop', '>=', time.strftime(DF)),
('company_id', '=', company_id)])
if fiscalyear_ids:
# has a current fiscal year, use this one
return self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_ids[0], context=context).date_start
else:
past_fiscalyear_ids = self.pool.get('account.fiscalyear').search(cr, uid,
- [('date_stop', '<=', time.strftime('%Y-%m-%d')), ('company_id', '=', company_id)])
+ [('date_stop', '<=', time.strftime(DF)), ('company_id', '=', company_id)])
if past_fiscalyear_ids:
# use the latest fiscal year+1 day, sorted by start_date
latest_stop = self.pool.get('account.fiscalyear').browse(cr, uid, past_fiscalyear_ids[-1], context=context).date_stop
- return (datetime.datetime.strptime(latest_stop, "%Y-%m-%d") + datetime.timedelta(days=1)).strftime('%Y-%m-%d')
+ return (datetime.datetime.strptime(latest_stop, DF) + datetime.timedelta(days=1)).strftime(DF)
else:
return time.strftime('%Y-01-01')
@@ -163,19 +164,19 @@ class account_config_settings(osv.osv_memory):
"""
company_id = self._default_company(cr, uid, context=context)
fiscalyear_ids = self.pool.get('account.fiscalyear').search(cr, uid,
- [('date_start', '<=', time.strftime('%Y-%m-%d')), ('date_stop', '>=', time.strftime('%Y-%m-%d')),
+ [('date_start', '<=', time.strftime(DF)), ('date_stop', '>=', time.strftime(DF)),
('company_id', '=', company_id)])
if fiscalyear_ids:
# has a current fiscal year, use this one
return self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_ids[0], context=context).date_stop
else:
past_fiscalyear_ids = self.pool.get('account.fiscalyear').search(cr, uid,
- [('date_stop', '<=', time.strftime('%Y-%m-%d')), ('company_id', '=', company_id)])
+ [('date_stop', '<=', time.strftime(DF)), ('company_id', '=', company_id)])
if past_fiscalyear_ids:
# use the latest fiscal year+1 day, sorted by start_date
latest_year = self.pool.get('account.fiscalyear').browse(cr, uid, past_fiscalyear_ids[-1], context=context)
- latest_stop = datetime.datetime.strptime(latest_year.date_stop, "%Y-%m-%d")
- return latest_stop.replace(year=latest_stop.year+1).strftime('%Y-%m-%d')
+ latest_stop = datetime.datetime.strptime(latest_year.date_stop, DF)
+ return latest_stop.replace(year=latest_stop.year+1).strftime(DF)
else:
return time.strftime('%Y-12-31')