Merge lp:~openerp-dev/openobject-server/6.1-opw-589975-msh into lp:openobject-server/6.1

Proposed by Mohammed Shekha(Open ERP)
Status: Rejected
Rejected by: Chris Biersbach (OpenERP)
Proposed branch: lp:~openerp-dev/openobject-server/6.1-opw-589975-msh
Merge into: lp:openobject-server/6.1
Diff against target: 28 lines (+7/-1)
1 file modified
openerp/osv/fields.py (+7/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.1-opw-589975-msh
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+154267@code.launchpad.net

Description of the change

Hello,

Fixed the issue of context_today method, returns wrong date, it returns UTC date if there is no tz key not found, there should be fallback, if tz not found in context then we should read context_tz of user, as context will not always available, it may come blank if context_today is called from method of workflow.

Demo:- Go to Accounting -> Customer Invoices and create one customer invoice in timezone Australia/Hobart wich UTC+11 and create invoice before 11 AM in Australia/Hobart so that in UTC it is 11PM of previous day, or change your system clock to generate this scenario, now validate invoice, so you will get invoice_date previous day even though your system shows 20th March but invoice_date will 19th March.

Reason:- tz not passed in context, so it should be handled if tz not available in context.

Thanks.

To post a comment you must log in.
4348. By Mohammed Shekha<email address hidden>

[FIX]Refixed the issue of context timezone.

Revision history for this message
Chris Biersbach (OpenERP) (cbi-openerp) wrote :

I reject this because 6.1 is not an LTS and we thus no longer merge in it.

Revision history for this message
Anaël Closson (openerp) (acl-openerp) wrote :

I'd like to clarify these points to avoid misunderstandings :

* The merge proposal has been rejected _in trunk_ because it cannot be reproduce in it. It has either been corrected or changes in the code make it obsolete. So no, the bug is not in trunk.

I case you can reproduce it in trunk (or version above 6.1), there might be a mistake from the person who tested it. Please let us know if we fall in that case.

* As we are limited on resources we try to avoid merging in non LTS version. A project should not start in that version so new users won't face the bug, and if the bug hasn't been reported previously in that version we can consider none (or few) user faced it before you.

That's why we provide the patch. Merging into stable means more reviews and testing. It has a cost we can't afford for each issue of each version. That's why we have LTS and STS versions till now.

Though, the patch is available for everyone, and will be merged if we notice it's a recurring issue.

Unmerged revisions

4348. By Mohammed Shekha<email address hidden>

[FIX]Refixed the issue of context timezone.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/osv/fields.py'
2--- openerp/osv/fields.py 2012-06-19 15:16:51 +0000
3+++ openerp/osv/fields.py 2013-04-04 04:51:22 +0000
4@@ -45,6 +45,7 @@
5 from openerp.tools.translate import _
6 from openerp.tools import float_round, float_repr
7 import simplejson
8+from openerp import SUPERUSER_ID
9
10 _logger = logging.getLogger(__name__)
11
12@@ -292,10 +293,15 @@
13 """
14 today = timestamp or DT.datetime.now()
15 context_today = None
16+ tz_name = None
17 if context and context.get('tz'):
18+ tz_name = context['tz']
19+ else:
20+ tz_name = model.pool.get('res.users').read(cr, SUPERUSER_ID, uid, ['context_tz'])['context_tz']
21+ if tz_name:
22 try:
23 utc = pytz.timezone('UTC')
24- context_tz = pytz.timezone(context['tz'])
25+ context_tz = pytz.timezone(tz_name)
26 utc_today = utc.localize(today, is_dst=False) # UTC = no DST
27 context_today = utc_today.astimezone(context_tz)
28 except Exception: