Commit Graph
33 Commits
Author SHA1 Message Date
Mathieu Duckerts-Antoine 01c159fd9f [FIX] web: quotes and backslashes in search view
The commit 6d3ada178f
aimed to solve problems occuring whith (single or
double) quotes when creating new custom filters.
Unfortunately, the point was missed and bugs were
still present. The present commit solves the
orginial problem satisfactorily.
There was also a problem in the management of
backslashes. Type '\\' in the search bar would
lead to a domain like
[('...', 'ilike', '\\\\\\\\\\\\\\\\')].
This has also been fixed. Note that it is
necessary to input "\\" if one is looking for a
backslash in db (as before).

A remark on the _formatAST function (py_utils.js):

We deescape only the chars `'`, `"`, and `\`
because it does not seem possible to produce a
string in the search view that would intend a
search for a line return or a tab for example.

A general remark:

Domains should always be in normalized form.
In that way they could be manipulated and combined
together without a tokenization/parsing!

closes odoo/odoo#29756
2019-02-12 12:45:51 +00:00
Géry Debongnie 6d3ada178f [FIX] web: prevent crash when searching for escaped strings
Recent works in the search view (in 12.0) on dynamic filters had an
unfortunate effect: when the user tries to input escaped strings (for
example "test" in custom filters, there was a crash.

The reason is that the JS python parser (or more specifically, the
tokenizer) was unable to parse that as a string.  It worked before
because the web client sent the raw string to the server.  However, with
dynamic filters, this is no longer the case, and we need to parse
domains to be able to combine them.

In this commit, we modify the tokenizer to be able to work with escaped
strings.

closes odoo/odoo#29324
2018-12-06 15:16:32 +00:00
Christophe Simonis 68d36512ef [MERGE] forward port branch saas-11.4 up to d78f23df84 2018-09-07 20:20:45 +02:00
Adrian Torres a1bad2191c [IMP] pyjs: add date/datetime utilities
Introduce utilities to calculate the start / end of a period given a date or datetime object in the JS python interpreter.

This commit is the JS implementation of commit 960360afe4
2018-08-09 15:00:37 +02:00
Mathieu Duckerts-Antoine 097464de6f [IMP] web: easy selection of a period in filters menu
This commit allow to create easily a range of periods (related to a field
of date or datetime type) to select in the filters menu.

Two new attributes on elements with tag 'filter' are now usable
in combination in a search view arch:

- date: string.

		A valid field name with associated type date or datetime

- default_period: string (optional).

		To choose in the following list:
			- 'today'
			- 'this_week'
			- 'this_month' (default)
			- 'this_quarter'
			- 'this_year'
			- 'yesterday'
			- 'last_week'
			- 'last_month'
			- 'last_quarter'
			- 'last_year'
			- 'last_7_days'
			- 'last_30_days'
			- 'last_365_days'

Example:

<filter string="Creation Date" name="period_generator" date="create_date" default_period="this_quarter"/>

Note: the attribute 'domain' can not be used for such filters.
The generated domains are dynamic and can be saved as such
via the favorites menu.
2018-07-06 14:09:09 +02:00
Géry Debongnie dcc4d71623 [REF] web: move some code from pyeval to lib py_extras
Some functions that were in web.pyeval were actually "odoo independant".
To make them easier to manage/understand, this commit move them in the
library py.js, as an extra file.
2018-07-06 14:09:09 +02:00
Mathieu Duckerts-Antoine 64f3580af7 [IMP] web: add support of modulo in pyeval 2018-07-06 14:09:09 +02:00
Aaron Bohy 977db823c7 [REF] web: stop duplicating web
Avoid duplicating web addon in enterprise by extracting a common basis.
Enterprise features stay in enterprise, but use that common basis.

Mainly:
 - JS refactoring and linting
 - Conversion of .sass into .less split into multiple files
 - Templates cleaning and DOM simplification
 - Re-generation of web.pot, and update of .po files
2016-04-21 15:21:39 +02:00
Christophe Simonis 56a442e205 [MERGE] forward port of branch saas-6 up to dade7e3 2015-11-25 13:26:02 +01:00
Denis Ledoux 32fd520d97 [MERGE] forward port of branch 8.0 up to 6f29cbe 2015-11-23 17:40:15 +01:00
Thomas Groutars b665478fa7 [FIX] py.js: unhandled prefix not
closes #6129
2015-11-19 13:54:26 +01:00
qdp-odoo c04065abd8 [IMP] accounting v9. Yeeeeaah 2015-05-05 17:28:04 +02:00
Christophe Simonis bc2fd0515b [MERGE] forward port of branch 8.0 up to 017f346 2015-03-04 15:16:10 +01:00
Xavier Morel 752e21a633 [FIX] py.js: arguments dispatching in PY_call
When providing an args of ``null`` (or ``undefined``) and a non-empty
kwargs, the kwargs would be removed/ignored.

While explicitly providing a null args is not necessary, it's perfectly
valid.
2015-03-03 11:51:50 +01:00
Arthur Maniet f0cefa7232 [ADD] py.js: len() and truthiness on lists, tuples and dicts
* use new support to colorize reconciled bank statement lines
* fixes tokenization of ``is not`` to not blow up on ``not foo``
* improves calling code to get truthiness of evaluated expression
  instead of truthiness of javascript-equivalent objects: an empty list
  is falsy in Python but truthy in javascript, since the evaluated
  expression is in Python one would expect Python truthiness rules
  without having to manually convert to boolean

closes #5070
2015-02-05 13:08:15 +01:00
Xavier Morel c694837a64 [FIX] parsing of domains with non-ascii unicode literals
update py.js to support parsing of escape sequences in string literals

bzr revid: xmo@openerp.com-20130517162215-4afen1mdzbfx1mxi
2013-05-17 18:22:15 +02:00
Christophe Matthieu a1e39f8d75 [FIX] py.js: add the name of value to display error when debugging.
bzr revid: chm@openerp.com-20130104140000-22t1wj95jp7ro2ho
2013-01-04 15:00:00 +01:00
Xavier Morel f9670e67a2 [FIX] rollback default conversion of js Object to py.object (not py.dict) and add default toJSON to all py.object
* Accesses in contexts & domains are object derefs, so using dicts was
  dumb

* But objects still need to round-trip through in case of e.g. o2m
  commands in contexts, so py.object needs a toJSON (or a special
  object kind needs to be added, specifically for round-tripping
  objects through)

bzr revid: xmo@openerp.com-20121203122312-gc499mujf4l0nuz7
2012-12-03 13:23:12 +01:00
Xavier Morel 54ea7670d3 [FIX] incorrect conversion of JS arrays to py.js lists/tuples
bzr revid: xmo@openerp.com-20121203114706-dn5sqq3glqst4g1q
2012-12-03 12:47:06 +01:00
Xavier Morel 0b54cbb64f [IMP] update py.js for abs builtin support
bzr revid: xmo@openerp.com-20121203084803-ib325gp18g5xvdv6
2012-12-03 09:48:03 +01:00
Xavier Morel 759f11f110 [FIX] py.js: bug in tokenization of single-quoted empty string
bzr revid: xmo@openerp.com-20121129132738-fcnam8bkqyt7h8ey
2012-11-29 14:27:38 +01:00
Xavier Morel 83d5c4f94c [IMP] update py.js to correctly tokenize unicode literals
also various style improvements in the lib

bzr revid: xmo@openerp.com-20121128155448-1tv62wyv3zy2asr5
2012-11-28 16:54:48 +01:00
Xavier Morel 6d27327d14 [FIX] parsing of long integers, as some openerp domains output them
bzr revid: xmo@openerp.com-20121127154037-fiu6vsfdvix3zlmz
2012-11-27 16:40:37 +01:00
Xavier Morel 7de2a2c965 [FIX] small typo
bzr revid: xmo@openerp.com-20121126075327-m3ljltvbhrwm8cbm
2012-11-26 08:53:27 +01:00
Xavier Morel 65db450c81 [IMP] update py.js to 0.7
bzr revid: xmo@openerp.com-20121126073002-deta3rdrwmzao6fy
2012-11-26 08:30:02 +01: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 6a23c24da1 [UP] py.js, old != operator and basic dict handling
bzr revid: xmo@openerp.com-20120806110638-1m4rg205sb3vjvm5
2012-08-06 13:06:38 +02:00
Xavier Morel 2a8d78c88c [UP] py.js for Object and Array converters to py types
bzr revid: xmo@openerp.com-20120404114647-t81pw90940canfwg
2012-04-04 13:46:47 +02:00
Xavier Morel f8a93bc284 [FIX] update py.js for operators &al, implement basic crummy version of relativedelta
bzr revid: xmo@openerp.com-20120305085532-0vcz6j0m985gjuz1
2012-03-05 09:55:32 +01:00
Xavier Morel 4a6776d7a1 [FIX] update py.js, fixes tokenization of expressions with trailing whitespace
bzr revid: xmo@openerp.com-20120301111807-f3lthxw4zkytk42f
2012-03-01 12:18:07 +01:00
Xavier Morel e762aec5a1 [ADD] forgotten py.js license
bzr revid: xmo@openerp.com-20120229115456-5rp0iuv3sftujq6b
2012-02-29 12:54:56 +01:00
Xavier Morel 27ca901a92 [FIX] update py.js to correctly handle comparisons between strings and booleans
bzr revid: xmo@openerp.com-20120229085250-ihg2vgjrpl2eyd0i
2012-02-29 09:52:50 +01:00
Xavier Morel 739f719ad6 [UP] py.parse 0.2 to py.js 0.4 ~
should probably go through a testing phase (checking its result
against that of eval_domain_and_context) for a while, but apart from
that it's supposed to work.

'stdlib' stuff (datetime.date.today, datetime.timedelta,
time.localtime, time.time, time.strftime) still need to be
written. Isn't there also a dateutil.relativedeleta somewhere?

Anyway that needs to be done and the various evaluation contexts need
to be defined, but the valuator itself should mostly work.

bzr revid: xmo@openerp.com-20120227073721-nkgeiqacbzch8xev
2012-02-27 08:37:21 +01:00