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
=== modified file 'openerp/osv/fields.py'
--- openerp/osv/fields.py 2012-06-19 15:16:51 +0000
+++ openerp/osv/fields.py 2013-04-04 04:51:22 +0000
@@ -45,6 +45,7 @@
45from openerp.tools.translate import _45from openerp.tools.translate import _
46from openerp.tools import float_round, float_repr46from openerp.tools import float_round, float_repr
47import simplejson47import simplejson
48from openerp import SUPERUSER_ID
4849
49_logger = logging.getLogger(__name__)50_logger = logging.getLogger(__name__)
5051
@@ -292,10 +293,15 @@
292 """293 """
293 today = timestamp or DT.datetime.now()294 today = timestamp or DT.datetime.now()
294 context_today = None295 context_today = None
296 tz_name = None
295 if context and context.get('tz'):297 if context and context.get('tz'):
298 tz_name = context['tz']
299 else:
300 tz_name = model.pool.get('res.users').read(cr, SUPERUSER_ID, uid, ['context_tz'])['context_tz']
301 if tz_name:
296 try:302 try:
297 utc = pytz.timezone('UTC')303 utc = pytz.timezone('UTC')
298 context_tz = pytz.timezone(context['tz'])304 context_tz = pytz.timezone(tz_name)
299 utc_today = utc.localize(today, is_dst=False) # UTC = no DST305 utc_today = utc.localize(today, is_dst=False) # UTC = no DST
300 context_today = utc_today.astimezone(context_tz)306 context_today = utc_today.astimezone(context_tz)
301 except Exception:307 except Exception: