Commit Graph

35 Commits

Author SHA1 Message Date
qsm-odoo b2d66d0c14 [FIX] web: properly combine domains with "OR" in CompoundDomain
The CompoundDomain class allows to regroup several domains with an
implicit "AND"; these domains can be either a string, an array or
another CompoundDomain. A CompoundDomain can then be converted to
an array thanks to pyeval.js.
For example, if a CompoundDomain is initialized with `[A, B]` and
`[C]`, the array conversion gave `[A, B, C]` (which is expected).

However, a hackish method was used with CompoundDomain. If one of the
domain of a CompoundDomain is equal to `["|"]` (an array with the
OR operator in it), the two next subdomains were supposed to be joined
by a OR operator. Indeed, for the case of a CompoundDomain initialized
with `["|"]`, `[A]` and `[B]`, the array conversion gave `["|", A, B]`
(which is expected). However, if initialized with `["|"]`, `[A, B]` and
`[C]`, the array conversion gave `["|", A, B, C]` which is very wrong
as what was expected is `["|", "&", A, B, C]`. The problem is that the
given `[A, B]` contains implicit "&" operators.

This commit fixes the problem by normalizing only if the CompoundDomain
starts with a ["|"] or ["!"] array which is the standard odoo case.
This allows to limit breaking custom code (e.g we want a simple "AND"
of `[A]` and `[B]` to stay `[A, B]`, not become `["&", A, B]`).

The commit also modifies a test so that it checks that the problem is
properly solved.
2017-03-24 15:03:54 +01:00
Thomas Groutars b665478fa7 [FIX] py.js: unhandled prefix `not`
closes #6129
2015-11-19 13:54:26 +01:00
Xavier Morel f64a2fa386 [ADD] js tests: more relativedelta tests
* add some more boundary tests and nudges
* add test for weekday

ref #5089
2015-03-03 11:55:18 +01:00
Xavier Morel 5b7ade9db1 [ADD] ways to correctly handle local datetimes in e.g. domains
* change datetime.now() to generate user-local naive datetimes
* add datetime.utcnow() behaving as the old now()
* add date.today() generating a user-local date (for the current day)
* add datetime.replace() to replace any specific attribute of the
  datetime object (except tzinfo, for now)
* datetime.toJSON() now returns the equivalent javascript Date object
  (warning: uses the datetime attributes directly, since datetimes are
  naive if they were created with utcnow() the Date result is going to
  be complete nonsense). With the previous commit datetime.now()
  generates a user-local now() which is converted to the correct UTC
  datetime when sent to the server.

This means it becomes possible to generate datetime bounds for the
user's local today with either

    datetime.datetime.now().replace(hour=0, minute=0, second=0)

or

    datetime.datetime.combine(
        datetime.date.today(),
        datetime.time())

and once send over JSON-RPC the server will get the local datetime
in UTC to the server's format.

nb: user-local means "in the timezone of the user's browser" in this
context.

bzr revid: xmo@openerp.com-20140122151911-akn1nr6e739eg92s
2014-01-22 16:19:11 +01:00
niv-openerp c63a86c593 [IMP] Merged corelib.js and coresetup.js into core.js
bzr revid: nicolas.vanhoren@openerp.com-20130806122623-pq6bpkjk65jx0fnp
2013-08-06 14:26:23 +02:00
niv-openerp 17ba69eb52 Applied jshint on test files and corrected errors
bzr revid: nicolas.vanhoren@openerp.com-20130725112416-j6wbm254yx05i890
2013-07-25 13:24:16 +02:00
Xavier Morel 11a0ece543 [FIX] evaluation context structures not being round-tripped through eval
JS objects are converted to py.object when passed in through the
evaluation context. py.object are not serializable by default (because
that doesn't really make sense), which breaks when the input is
intended as a dict and returned (e.g. o2m values, which are triples of
(int, int?, dict?)).

Intuitively, JS objects passed as part of the context should be mostly
JSON-ish and thus dicts, but that turns out not work work as some
addons use attribute accesses within contexts (e.g. parent.access in
account/account_invoice_view.xml)

=> Temporarily solve by converting raw js objects to an "attributed
dict" which acts as both a dict and an object and can be converted to
JSON.

Ideally, py.js should provide for a pluggable conversion, or should
use an attributed mapping internally. See issues 21 and 23.

lp bug: https://launchpad.net/bugs/1182101 fixed

bzr revid: xmo@openerp.com-20130624055929-3rtkgqrp4o87pvau
2013-06-24 07:59:29 +02:00
Xavier Morel ac5008abc9 [FIX] pyeval: argspec of relativedelta
bzr revid: xmo@openerp.com-20130318105244-qkgvi69do0219lkk
2013-03-18 11:52:44 +01:00
vta vta@openerp.com 56e97a98bb [FIX] Fixed issue with testing context in eval.js, due to a previous change in get_session_info (context -> user_context)
bzr revid: vta@openerp.com-20130111094314-odrm9enzrmcrtcu6
2013-01-11 10:43:14 +01:00
Raphael Collet 43ca577f99 [FIX] js tests: add an abstraction over instance to create properly an assertion function
bzr revid: rco@openerp.com-20121210154309-mubr65ildpiw2wpx
2012-12-10 16:43:09 +01:00
Raphael Collet 38994104f0 [IMP] js tests: when testing pyeval on datetimes, avoid comparison with an indepent call to new Date()
bzr revid: rco@openerp.com-20121210151828-lfzyfy75oldkjxk5
2012-12-10 16:18:28 +01:00
niv-openerp 053d6af231 [FIX] forgot to modify test after API change
bzr revid: nicolas.vanhoren@openerp.com-20121130140335-k1nus3oz1xw6deeu
2012-11-30 15:03:35 +01:00
niv-openerp f9b9e7c4cb [IMP] added context_today()
bzr revid: nicolas.vanhoren@openerp.com-20121129160746-c3c691zk5fxhzse0
2012-11-29 17:07:46 +01:00
niv-openerp cc6f0aa20a [FIX] potential problem with pyeval datetime/date today()/now() methods. Now only returns the same timezone than server (UTC).
bzr revid: nicolas.vanhoren@openerp.com-20121129153601-vtpnvkc0vylo9hux
2012-11-29 16:36:01 +01:00
Xavier Morel aab69ae7a9 [TEST] for crazy
bzr revid: xmo@openerp.com-20121126084159-lbgfa56vafg4bxc4
2012-11-26 09:41:59 +01:00
Xavier Morel 2c7f30a047 [REM] session reload dependency on db
bzr revid: xmo@openerp.com-20121123120500-k7fhwoocu0zbiali
2012-11-23 13:05:00 +01:00
Xavier Morel 6b2b2d889c [IMP] move nonliteral domains and contexts to JS test case
bzr revid: xmo@openerp.com-20121123114923-t4047w6jztria91x
2012-11-23 12:49:23 +01:00
Xavier Morel 709f2506ff [REM] server-side eval_domain_and_context
bzr revid: xmo@openerp.com-20121123113932-siz0u2vp2u7z6wk2
2012-11-23 12:39:32 +01:00
Xavier Morel 242a5da5a9 [REM] stray logging
bzr revid: xmo@openerp.com-20121123095824-xg6afc1l01t3y48y
2012-11-23 10:58:24 +01:00
Xavier Morel 328537a7ba [ADD] arithmetics between date and timedelta
bzr revid: xmo@openerp.com-20121123095206-dtvoiignb7xnzsl0
2012-11-23 10:52:06 +01:00
Xavier Morel 815b908759 [ADD] partial but sufficient (I think) implementation of datetime.timedelta
bzr revid: xmo@openerp.com-20121123075938-oazwt4bn2l639r3a
2012-11-23 08:59:38 +01:00
Xavier Morel 3909d1ff02 [ADD] a bunch of eval domain and context tests
bzr revid: xmo@openerp.com-20121122111628-4khivcp97xoy121i
2012-11-22 12:16:28 +01:00
Xavier Morel 5a9f78302f [MERGE] from trunk
when creating the instance, set instance.session.uid to 42 so the evaluator has something to chew on when it tries to create the evaluation context

bzr revid: xmo@openerp.com-20121120101733-b0ire11bbuywfi8u
2012-11-20 11:17:33 +01:00
Xavier Morel a130035409 [IMP] port basic/existing tests to new framework, apart from editor stuff
bzr revid: xmo@openerp.com-20121026092144-0arxx2v9oi28e3d6
2012-10-26 11:21:44 +02:00
Xavier Morel b94e9c30a7 [FIX] after discussions with odo, date/datetime/time for locally-evaluated contexts and domains should be local, not UTC
bzr revid: xmo@openerp.com-20121011075759-qfwkfws5tu9yidab
2012-10-11 09:57:59 +02:00
Xavier Morel 1fa00288b2 [FIX] add 'context' free variable in evaluation contexts for domains and contexts
bzr revid: xmo@openerp.com-20121010145945-16shdry3udum0mn1
2012-10-10 16:59:45 +02:00
Xavier Morel 894bd34e62 [REM] timedelta, because pain
bzr revid: xmo@openerp.com-20121008125523-ed1g42vjxbcfo62r
2012-10-08 14:55:23 +02:00
Xavier Morel 7bcbadb099 [FIX] update py.js to 0.6, port existin classes to it, attempt to implement timedelta
bzr revid: xmo@openerp.com-20121008120619-lhmexjnujjrigjn9
2012-10-08 14:06:19 +02:00
Xavier Morel 10bc6ddfe4 [ADD] groupby eval tests
bzr revid: xmo@openerp.com-20121005142808-yx6o8nfnn0o4ms56
2012-10-05 16:28:08 +02:00
Christophe Simonis 63e4d9b572 [IMP] sed -i '' -e 's/connection/session/g'
bzr revid: chs@openerp.com-20120814152900-8r84kyz0qy1hwkvz
2012-08-14 17:29:00 +02:00
Xavier Morel 6f4abdfbd5 [IMP] move eval functions for domains, groupbys and contexts outside of corelib, as well as the standard evaluation context building (and related objects)
bzr revid: xmo@openerp.com-20120806094627-8c9lwtfkbfws2bmj
2012-08-06 11:46:27 +02:00
Xavier Morel f1b6bc35d6 [FIX] add current_date to JS evaluation context
bzr revid: xmo@openerp.com-20120801144435-h0643av6ju9ncdpx
2012-08-01 16:44:35 +02:00
Xavier Morel e7ab44929f [MERGE] from trunk
bzr revid: xmo@openerp.com-20120419081213-m3fhofkgydj6gp1m
2012-04-19 10:12:13 +02:00
Xavier Morel a029cf244f [FIX] in a compound context, context n+1 has all of its preceding siblings in its evaluation context
bzr revid: xmo@openerp.com-20120405095009-v2i1xg8gf6lvigjv
2012-04-05 11:50:09 +02:00
Xavier Morel 239a118913 [FIX] compound domain and context's eval_context can be a compound itself, evaluate those if needs be
also fix tests html file for renames and extracts, and add a test case for complex non-literal evaluation contexts

bzr revid: xmo@openerp.com-20120404114830-a6416m2v7h8cyf08
2012-04-04 13:48:30 +02:00