From c38c7d055cbb198f0696048e5b2fdac6aac12592 Mon Sep 17 00:00:00 2001 From: Manu <> Date: Tue, 19 Jul 2011 18:37:40 +0530 Subject: [PATCH 1/5] [FIX] account : improved the dates in recurring entries lp bug: https://launchpad.net/bugs/800767 fixed bzr revid: bde@tinyerp.com-20110719130740-eq87ant192zguo0n --- addons/account/account.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 03a9b628922..64aab95ee29 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1331,7 +1331,7 @@ class account_move(osv.osv): def _centralise(self, cr, uid, move, mode, context=None): assert mode in ('debit', 'credit'), 'Invalid Mode' #to prevent sql injection - currency_obj = self.pool.get('res.currency') + currency_obj = self.pool.get('res.currency') if context is None: context = {} @@ -1593,7 +1593,7 @@ class account_tax_code(osv.osv): (parent_ids,) + where_params) res=dict(cr.fetchall()) obj_precision = self.pool.get('decimal.precision') - res2 = {} + res2 = {} for record in self.browse(cr, uid, ids, context=context): def _rec_get(record): amount = res.get(record.id, 0.0) @@ -2120,7 +2120,7 @@ class account_model(osv.osv): period_id = period_id[0] for model in self.browse(cr, uid, ids, context=context): - entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%Y-%m')} + entry['name'] = model.name%{'year':context.get('date',time.strftime('%Y')), 'month':context.get('date',time.strftime('%m')), 'date':context.get('date',time.strftime('%d'))} move_id = account_move_obj.create(cr, uid, { 'ref': entry['name'], 'period_id': period_id, @@ -2141,7 +2141,7 @@ class account_model(osv.osv): 'analytic_account_id': analytic_account_id } - date_maturity = time.strftime('%Y-%m-%d') + date_maturity = context.get('date',time.strftime('%Y-%m-%d')) if line.date_maturity == 'partner': if not line.partner_id: raise osv.except_osv(_('Error !'), _("Maturity date of entry line generated by model line '%s' of model '%s' is based on partner payment term!" \ From e955394d4503d207c135a5476c684e2f32e2a96c Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Wed, 20 Jul 2011 17:09:53 +0530 Subject: [PATCH 2/5] [IMP] account : improved the context date in account model bzr revid: bde@tinyerp.com-20110720113953-h6774pxnk7gqpeu7 --- addons/account/account.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index 64aab95ee29..0364858fc58 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -21,6 +21,7 @@ import time from datetime import datetime +from time import mktime from dateutil.relativedelta import relativedelta from operator import itemgetter @@ -2120,7 +2121,10 @@ class account_model(osv.osv): period_id = period_id[0] for model in self.browse(cr, uid, ids, context=context): - entry['name'] = model.name%{'year':context.get('date',time.strftime('%Y')), 'month':context.get('date',time.strftime('%m')), 'date':context.get('date',time.strftime('%d'))} + context_date = context.get('date') + str_date = time.strptime(context_date,"%Y-%m-%d") + date = datetime.fromtimestamp(mktime(str_date)) + entry['name'] = model.name%{'year':date.strftime("%Y"), 'month':date.strftime("%m"), 'date': date.strftime("%Y-%m")} move_id = account_move_obj.create(cr, uid, { 'ref': entry['name'], 'period_id': period_id, From 3d103402d21eed173aa4d04f56dfe615ea4a74fb Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Thu, 28 Jul 2011 15:37:15 +0530 Subject: [PATCH 3/5] [IMP] improved the code for getting date bzr revid: bde@tinyerp.com-20110728100715-hujz539r1usdeu4w --- addons/account/account.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 0364858fc58..8e653bd5d93 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2122,8 +2122,7 @@ class account_model(osv.osv): for model in self.browse(cr, uid, ids, context=context): context_date = context.get('date') - str_date = time.strptime(context_date,"%Y-%m-%d") - date = datetime.fromtimestamp(mktime(str_date)) + date = datetime.strptime(context_date,"%Y-%m-%d") entry['name'] = model.name%{'year':date.strftime("%Y"), 'month':date.strftime("%m"), 'date': date.strftime("%Y-%m")} move_id = account_move_obj.create(cr, uid, { 'ref': entry['name'], From efc8992a52e8f2f78a60cb640240c416f55501eb Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Tue, 2 Aug 2011 14:10:05 +0530 Subject: [PATCH 4/5] [IMP] Made context_date + date variable outside the for loop and improved the variable names bzr revid: bde@tinyerp.com-20110802084005-vd891ebsio62i2s7 --- addons/account/account.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 8e653bd5d93..a5734138dd3 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2120,10 +2120,10 @@ class account_model(osv.osv): raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !')) period_id = period_id[0] + move_date = context.get('date', time.strftime('%Y-%m-%d')) + move_date = datetime.strptime(move_date,"%Y-%m-%d") for model in self.browse(cr, uid, ids, context=context): - context_date = context.get('date') - date = datetime.strptime(context_date,"%Y-%m-%d") - entry['name'] = model.name%{'year':date.strftime("%Y"), 'month':date.strftime("%m"), 'date': date.strftime("%Y-%m")} + entry['name'] = model.name%{'year':move_date.strftime("%Y"), 'month':move_date.strftime("%m"), 'date': move_date.strftime("%Y-%m")} move_id = account_move_obj.create(cr, uid, { 'ref': entry['name'], 'period_id': period_id, From cd85ba5a10d5d53716c23fe4a14ba894c8c634f8 Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Thu, 4 Aug 2011 12:23:37 +0530 Subject: [PATCH 5/5] [REM] removed mktime package from account.py bzr revid: bde@tinyerp.com-20110804065337-egm5ju0h3lyld3q7 --- addons/account/account.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index a5734138dd3..94fb9fa4c31 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -21,7 +21,6 @@ import time from datetime import datetime -from time import mktime from dateutil.relativedelta import relativedelta from operator import itemgetter