Merge lp:~openerp-dev/openerp-web/7.0-opw-591255-msh into lp:openerp-web/7.0

Proposed by Mohammed Shekha(Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openerp-web/7.0-opw-591255-msh
Merge into: lp:openerp-web/7.0
Diff against target: 27 lines (+10/-0)
1 file modified
addons/web/static/src/js/pyeval.js (+10/-0)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-opw-591255-msh
Reviewer Review Type Date Requested Status
Xavier (Open ERP) (community) Needs Fixing
Martin Trigaux (OpenERP) Pending
Nicolas Vanhoren (OpenERP) Pending
Review via email: mp+158867@code.launchpad.net

Description of the change

Hello,

Fixed the issue of datetime.date.today and datetime.datetime.today which is not supported by pyeval, so add today method to allow developed to use datetime.date.today, as server addons developer will always write a code in terms of python(by thinking python's datetime.datetime.today method).

Demo:- To reproduce this issue create one search filter for date field as follow.

<filter icon="terp-go-month"
        string="Past 7 Days"
        domain="[('date_order','&lt;=', (datetime.date.today() + relativedelta(days=-7)).strftime('%%Y-%%m-%%d 23:59:59'))]" />

Or create for datetime field as follow.

<filter icon="terp-go-month"
        string="Past 7 Days"
        domain="[('date_order','&lt;=', (datetime.datetime.today()).strftime('%%Y-%%m-%%d 23:59:59'))]"/>

Noe goto search view and click on this filter and you will get error results.group_by is undefined.

Reason: today is not supported by datetime.date or datetime.datetime object(pyeval.js helper of py.js), as python datetime.datetime object has today method which gives localtime without tz information so we should support this as server addons developer will put domain by considering python.

Thanks.

To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

* Why doesn't datetime.datetime.today just call datetime.datetime.now since they're equivalent if timezones aren't supported?

* I expect the whole point of context_today is that using date.today is *wrong*. If that's the case, it definitely should not be added. Though you'll have to check that with niv.

review: Needs Fixing
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

(or maybe not, I don't know, in any case please ask niv for #2)

Unmerged revisions

3892. By Mohammed Shekha<email address hidden>

[FIX]Fixed the issue of datetime.date.today and datetime.datetime.today which is not supported by pyeval, so add today method to allow developed to use datetime.date.today, as server addons developer will always write a code in terms of python(by thinking python's datetime.datetime.today method).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/static/src/js/pyeval.js'
--- addons/web/static/src/js/pyeval.js 2013-03-19 10:27:19 +0000
+++ addons/web/static/src/js/pyeval.js 2013-04-15 09:01:26 +0000
@@ -402,6 +402,13 @@
402 d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(),402 d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(),
403 d.getUTCMilliseconds() * 1000]);403 d.getUTCMilliseconds() * 1000]);
404 }),404 }),
405 today: py.classmethod.fromJSON(function(){
406 var d = new Date();
407 return py.PY_call(datetime.datetime,
408 [d.getFullYear(), d.getMonth() + 1, d.getDate(),
409 d.getHours(), d.getMinutes(), d.getSeconds(),
410 d.getMilliseconds() * 1000]);
411 }),
405 combine: py.classmethod.fromJSON(function () {412 combine: py.classmethod.fromJSON(function () {
406 var args = py.PY_parseArgs(arguments, 'date time');413 var args = py.PY_parseArgs(arguments, 'date time');
407 return py.PY_call(datetime.datetime, [414 return py.PY_call(datetime.datetime, [
@@ -467,6 +474,9 @@
467 },474 },
468 fromJSON: function (year, month, day) {475 fromJSON: function (year, month, day) {
469 return py.PY_call(datetime.date, [year, month, day])476 return py.PY_call(datetime.date, [year, month, day])
477 },
478 today: function() {
479 return context_today()
470 }480 }
471 });481 });
472 /**482 /**