Commit Graph

134 Commits

Author SHA1 Message Date
Jeremy Kersten de3b64018a [FIX] osv: fix boolean in domain for custom field
When a new column has been added after that some data already exists,
the old lines will keep an empty/null value. So when we search is the new field
is equals to False or if it is different of True, we need to match the null
values.

close #9925
2015-12-04 16:31:31 +01:00
Denis Ledoux 56c08e486f [FIX] expression: `child_of` domain with `parent_store` & non-existing parent
In the `product.template` model,
when searching products within a category that doesn't exist,
all products were returned, while none should be returned.

For instance,
In Sales > Products,
In the search input, search with internal category:
"A category that doesn't exist",
all products were returned.

opw-649548
2015-11-10 16:35:55 +01:00
Denis Ledoux 8558ecfdf3 [MERGE] forward port of branch saas-3 up to dd8cbf4 2015-11-06 16:08:30 +01:00
Denis Ledoux dd8cbf49ac [MERGE] forward port of branch 7.0 up to d24fcd1 2015-11-06 16:04:21 +01:00
Raphael Collet c28a28e69e [IMP] osv: use iteration for expression negating
The current code when applying negative operator on an expression used
recursion which in extreme case is not best friend with python.

e.g: on instance with a lot of wharehouse, some simple action could lead
to a domain with lot of elements which could easiliy go over the python
maximum recursion limit.

This commit fixes this by replacing recursion with iteration.

We have a stack of negation flags and loop on each token of the domain
as follow :

- when we iterate on a leaf, it consumes the top negation flag,

- after a '!' operator, the top token negation is inversed,

- after an '&' or '|' operator, the top negation flag is duplicated on
  the top of the stack.

closes #9433
opw-653802
2015-11-05 17:13:28 +01:00
Thomas Rehn 11f538fae6 [FIX] expression: table alias reaching 64 characters limits
Postgresql has a limit of 64 characters for tables, columns names
as well as for aliases names.

When generating an alias name, e.g. for group by and order
by clauses, if the alias is longer than 64 characters,
use hashing to force the alias length to be within this
64 chars limit.

Fixes #8094
Closes #8142
2015-09-08 11:53:18 +02:00
Raphael Collet f5e5bbdae0 [FIX] expression: fix search on one2many field with inherited inverse field
Consider the following setting:
 - on model A, field F is computed, stored, and depends on field G
 - on model A, field one2many G to model B, with inverse field H
 - on model B, field many2one H is inherited (_inherits) from model C
 - on model C, field many2one H is stored

When adding records of model B, the field F must be recomputed.  In order to
determine which records to recompute, one searches model A with a domain like
[(G, 'in', ids)].  In expression.py, this is resolved with an SQL query like

    select H from B where id in {ids}

This query fails, since the field H is not stored in model B.  This happens in
general if H is not stored (it may be any computed field).  In that case, one
should instead browse records from B, and read field H through the ORM.

A test case has been added: it introduces a many2one field in a parent model,
and a one2many field using the inherited many2one on a child model.  The test
checks whether one can search on the one2many field.
2015-09-04 13:25:51 +02:00
Olivier Dony 9b1aa53f29 [MERGE] Forward-port saas-3 up to 9cdfb0696a 2015-06-23 15:18:00 +02:00
Olivier Dony 9cdfb0696a [MERGE] Forward-port 7.0 up to 6acd5ef91c 2015-06-23 15:13:47 +02:00
Olivier Dony 6acd5ef91c [FIX] expression: internal domain operators require different parsing
Ensure the absence of internal domain operators is correctly
propagated throughout the domain parsing.
2015-06-23 15:04:45 +02:00
Christophe Simonis 327e471c9b [MERGE] forward port of branch saas-3 up to b62ee07 2015-05-21 14:19:24 +02:00
Christophe Simonis b62ee0734c [MERGE] forward port of branch 7.0 up to eaaca65 2015-05-21 14:11:39 +02:00
Denis Ledoux 54a90179bb [FIX] expression: ensure tuple to compare leaf with TRUE/FALSE leaf
When setting a custom filter with as domain
[(0, '=', 1)]

the domain was rejected, because (0, '=', 1) wasn't
considered as a valid leaf, while it is.

This is because the Javascript converts this domain
using list instead of tuple
[(0, '=', 1)] -> [[0, '=', 1]]

And therefore, comparing the "list" leaf
to the TRUE/FALSE leaf tuple failed.

Ensuring "element" as a tuple solves the issue.

opw-640306
2015-05-20 15:33:35 +02:00
Denis Ledoux dcfd94cbf5 [FIX] orm: Revert 332154444d && acd7d84da4
These revs. introduced an API change in the _name_search method.

Indeed, the 'operator' attribute used to have 'ilike' as default value.
This cannot be changed, as every modules overriding this method
overrided it using the signature with operator='ilike'

For instance, _name_search method of addons/base/ir/ir_model.py
expects having 'ilike' as operator.
As it was not anymore the case,
it leaded to a crash when performing a name_search call on the model ir.model,
like when adding a new custom field to a model, from the web client.

opw-626161
2015-01-21 18:33:36 +01:00
Samus CTO 332154444d [FIX] Can not search using a string operator on column id 2015-01-20 09:52:55 +01:00
Raphael Collet 5e3de76f36 [FIX] expression: use "unaccent(column::text)" instead of "unaccent(column)::text"
As unaccent() of date fields will not work
Fixes #4615
2015-01-12 17:52:26 +01:00
Raphael Collet f2e4a10e1a [IMP] use model._fields instead of model._all_columns to cover all fields
The old-api model._all_columns contains information about model._columns and
inherited columns.  This dictionary is missing new-api computed non-stored
fields, and the new field objects provide a more readable api...

This commit contains the following changes:

 - adapt several methods of BaseModel to use fields instead of columns and
   _all_columns

 - copy all semantic-free attributes of related fields from their source

 - add attribute 'group_operator' on integer and float fields

 - base, base_action_rule, crm, edi, hr, mail, mass_mailing, pad,
   payment_acquirer, share, website, website_crm, website_mail: simply use
   _fields instead of _all_columns

 - base, decimal_precision, website: adapt qweb rendering methods to use fields
   instead of columns
2014-11-04 13:47:57 +01:00
Raphael Collet 5eb6e58156 [FIX] fields: make field.store=False on old-style function fields
Clarify the semantics of field attributes:
 - field.store is True when the field is actually stored in the database;
 - field.column is the column corresponding to field or None.

The various field definitions correspond to:
 - new-style stored field: field.store and field.column
 - new-style non-stored field: not field.store and not field.column
 - old-style regular field: field.store and field.column
 - old-style function field: not field.store and field.column
2014-10-30 13:29:21 +01:00
Raphael Collet e9587bf130 [IMP] expression.py: add a check to forbid records in domains
Records in domains cause a "maximum recursion depth exceeded" error when
converted to SQL. Simply add a test to show a better error message.
2014-10-16 10:22:23 +02:00
Raphael Collet cbe2dbb672 [MERGE] new v8 api by rco
A squashed merge is required as the conversion of the apiculture branch from
bzr to git was not correctly done. The git history contains irrelevant blobs
and commits. This branch brings a lot of changes and fixes, too many to list
exhaustively.

- New orm api, objects are now used instead of ids
- Environements to encapsulates cr uid context while maintaining backward compatibility
- Field compute attribute is a new object oriented way to define function fields
- Shared browse record cache
- New onchange protocol
- Optional copy flag on fields
- Documentation update
- Dead code cleanup
- Lots of fixes
2014-07-06 17:05:41 +02:00
Christophe Simonis a1b3e22a17 [MERGE] forward port of branch 7.0 up to 4bfcbb2 2014-06-25 11:35:11 +02:00
Mohammed Shekha 0b593ada11 Server Translation: Fixed the issue search on translated field do not return true result, search on tranlsated field fails due to expression parsing which fetches ids from ir_translation as well as working table and UNION of this makes search fruitless, also search fails for in language other then english when you enter part of a string for the field to search. 2014-06-24 17:42:48 +05:30
Christophe Simonis 3d2e9b4d2b [MERGE] forward port of branch 7.0 up to revid 5281 launchpad_translations_on_behalf_of_openerp-20140412094159-mhy3v2prb3ctx32k
bzr revid: jke@openerp.com-20140409153527-mic1a8afcvdhsd27
bzr revid: chs@openerp.com-20140410102422-fcwxhjk40z0oy8x5
bzr revid: chs@openerp.com-20140415133650-y46i0o3qkb2atbvi
2014-04-15 15:36:50 +02:00
jba 1578776814 [FIX] expression: when evaluatoing *like operator, add cast to text to column in case of different type
bzr revid: mat@openerp.com-20140409144346-nbn0dno3bs6ozwk5
2014-04-09 16:43:46 +02:00
Christophe Simonis 120342d537 [MERGE] forward port of branch 7.0 up to revid 5274 chs@openerp.com-20140404141611-qi1yagltvkd9q8ji
bzr revid: chs@openerp.com-20140404155858-mvupqmuvi8ime2tl
2014-04-04 17:58:58 +02:00
Christophe Simonis bcf36e6deb [IMP] expression: new helper for generating unaccent aware sql queries. Adapt _auto_join tests to use it.
bzr revid: chs@openerp.com-20140404141559-d2sn68lruik9hz81
2014-04-04 16:15:59 +02:00
Olivier Dony 63b8fe0d33 [FIX] domain parsing: better heuristic when a domain uses a date value for a datetime field
This comparison is flawed by nature but can be a useful
shortcut sometimes. It was using wrong boundaries and
would also loop for operators not explicitly handled
by the code (there was no `else` block). It is still
not possible to handle time zone conversions properly,
so this is only an experimental feature.

bzr revid: odo@openerp.com-20140404133827-5owdendpsr083a17
2014-04-04 15:38:27 +02:00
Christophe Simonis 6fca27626a [FIX] expression: do not double quote column names
bzr revid: chs@openerp.com-20140403084524-9rb174osjrbmhgwc
2014-04-03 10:45:24 +02:00
Christophe Simonis 19993ab1d5 [FIX] expression: translated search as params are flatten, we need to expand "%s" placeholders when using the `in` operator
bzr revid: chs@openerp.com-20140402112730-eoqxt0pu7lvcq5yg
2014-04-02 13:27:30 +02:00
Christophe Simonis 4978cf4293 [MERGE] forward port of branch saas-2 up to revid 5025 chs@openerp.com-20140403084808-slnj7uis17kwi9js
bzr revid: chs@openerp.com-20140403085050-0blat5jm87j9gkbb
2014-04-03 10:50:50 +02:00
Christophe Simonis 1c3ee251f0 [MERGE] forward port of branch 7.0 up to revid 5270 chs@openerp.com-20140403084524-9rb174osjrbmhgwc
bzr revid: chs@openerp.com-20140402083506-w4cywcf0kxxx9xmk
bzr revid: chs@openerp.com-20140312174526-a5rhh83g0fw8djuc
bzr revid: chs@openerp.com-20140318105837-53vsx5g7fm517cuc
bzr revid: dle@openerp.com-20140326092548-bu4bqinhvco8j5wj
bzr revid: chs@openerp.com-20140402092735-3a23yjl169vvt0iv
bzr revid: chs@openerp.com-20140402112825-ky8rcb3p467ikitc
bzr revid: chs@openerp.com-20140403084808-slnj7uis17kwi9js
2014-04-03 10:48:08 +02:00
Christophe Simonis 7c9db05d1e [MERGE] forward port of branch saas-2 up to revid 5024 chs@openerp.com-20140402112825-ky8rcb3p467ikitc
bzr revid: chs@openerp.com-20140402093016-rcl15e5vpdj7ishv
bzr revid: chs@openerp.com-20140402114823-4mncr059d9ms8v3t
2014-04-02 13:48:23 +02:00
Christophe Simonis dfe28ec31f [FIX] expression: use unaccent() for translated search
lp bug: https://launchpad.net/bugs/1049653 fixed

bzr revid: chs@openerp.com-20140331123012-dq3hsw2bc368zvgq
2014-03-31 14:30:12 +02:00
Christophe Simonis a69f789b41 [MERGE] forward port of branch 7.0 up to revid 5224 chs@openerp.com-20140206105141-7e8bv8ordqqsswh7
bzr revid: dle@openerp.com-20140205105045-j95kduyjiq83e57z
bzr revid: dle@openerp.com-20140114173613-ruxye1m7fxtcjfim
bzr revid: dle@openerp.com-20140116161158-u95vcs3os4tk2zob
bzr revid: dle@openerp.com-20140121172737-gzawfi3ssg7xifef
bzr revid: chs@openerp.com-20140129094554-c3abc8x3qz9mpszr
bzr revid: chs@openerp.com-20140129140159-9vwkpr078shoonum
bzr revid: chs@openerp.com-20140206110220-myn57cryam1y4k9v
2014-02-06 12:02:20 +01:00
Christophe Simonis 378c908d4c [MERGE] forward port of branch saas-2 up to revid 5006 chs@openerp.com-20140129140159-9vwkpr078shoonum
bzr revid: chs@openerp.com-20140129094847-4rsg0kjio0ed0rjk
bzr revid: chs@openerp.com-20140129141002-4p8fttm8ii0ogsse
2014-01-29 15:10:02 +01:00
Martin Trigaux f2b2ee8eae [FIX] expression: do not look at translation in parse when searching with empty string or false
This fixes traceback when applying filter 'is not set' on a translatable field

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

bzr revid: mat@openerp.com-20140127144913-qjh9hrnkfdn18sdb
2014-01-27 15:49:13 +01:00
Christophe Simonis 0771ca2692 [MERGE] forward port of branch saas-2 up to revid 5002 dle@openerp.com-20140114173613-ruxye1m7fxtcjfim
bzr revid: chs@openerp.com-20140115205357-arptzm69logz3osm
2014-01-15 21:53:57 +01:00
Denis Ledoux 05aab83eb1 [MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 9743 revid:qdp-launchpad@openerp.com-20140108160719-9i8xhrat49cn9l5e
bzr revid: chs@openerp.com-20140107141524-xzz39a2ym66swr0t
bzr revid: chs@openerp.com-20140107172248-zic9mqg0rigy2czb
bzr revid: chs@openerp.com-20140108160418-ph17jgy5hlejj9hr
bzr revid: dle@openerp.com-20140108171400-8r0fwv3wi36w2im0
2014-01-08 18:14:00 +01:00
Christophe Simonis 7f8b6542f0 [FIX] expression: allow exclusion of records with translated fields
lp bug: https://launchpad.net/bugs/1071710 fixed

bzr revid: chs@openerp.com-20140108152722-7f0dpsuv1skxbqub
2014-01-08 16:27:22 +01:00
Christophe Simonis 9675445dee [FIX] expression: allow exclusion of records with translated fields
Manual forwardport of revid 4369 chs@openerp.com-20140107112227-sc1ssd1dw404vcz2 of 6.1 branch

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

bzr revid: chs@openerp.com-20140107130840-igmm8sy03nrm5d5f
2014-01-07 14:08:40 +01:00
Quentin (OpenERP) bdda7b70d3 [FIX] expression.py: when searching on a datetime field with an argument formated as a date, conversion should happen _also_ for the '=' operator. This omission was causing an infinite loop beacuse we were pushing the exact same leaf on the stack without any modification
bzr revid: qdp-launchpad@openerp.com-20131104134314-2mv5wkt13ih9c1yg
2013-11-04 14:43:14 +01:00
Raphael Collet 7358cec8dc [FIX] expression: in nodes like (left, 'in', right), apply _symbol_set on all values in right
bzr revid: rco@openerp.com-20131003075351-5quyz6ge1ayczdo9
2013-10-03 09:53:51 +02:00
Olivier Dony fbd0758cb5 [MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 5054 rev-id: odo@openerp.com-20130820091157-e5brwlxuhujf8rrd
bzr revid: chs@openerp.com-20130724085026-525l9apggc9yzx0h
bzr revid: odo@openerp.com-20130730140644-1xih0as5jsks4pub
bzr revid: dle@openerp.com-20130801130723-khgwjkglgsdn34fj
bzr revid: odo@openerp.com-20130820091638-jpbcmh653bpa29em
2013-08-20 11:16:38 +02:00
Christophe Simonis 03381c761d [FIX] expression: a valid leaf must have a non empty string as first element or be the magic TRUE_LEAF/FALSE_LEAF
lp bug: https://launchpad.net/bugs/1197323 fixed

bzr revid: chs@openerp.com-20130719091903-28ez0txxyjh6qiii
2013-07-19 11:19:03 +02:00
Thibault Delavallée 1d5068b63e [FORWARD] Forward port of server 7.0 until revision 4988
bzr revid: tde@openerp.com-20130528102733-bsszxp6nvy8yws3t
2013-05-28 12:27:33 +02:00
Martin Trigaux 8ecd022348 [IMP] clean permissions and shebang in files
bzr revid: mat@openerp.com-20130514103333-puuj4kmxq3bwzwec
2013-05-14 12:33:33 +02:00
Christophe Simonis 60f0bd08ee [FIX] expression: allow creating child_of expression even if "id" field has been redefined, courtesy of Gustavo Adrian Marino
lp bug: https://launchpad.net/bugs/1030942 fixed
lp bug: https://launchpad.net/bugs/1131992 fixed

bzr revid: chs@openerp.com-20130423181926-yk628txd6yiybtko
2013-04-23 20:19:26 +02:00
Raphael Collet 05851d21ba [MERGE] from trunk
bzr revid: rco@openerp.com-20130411073017-x6e4h8xbvmy3ofdw
2013-04-11 09:30:17 +02:00
Vo Minh Thu 307ca374d6 [MERGE] forward merge 7.0 until revision 4919.
bzr revid: vmt@openerp.com-20130404130704-24vsmczw34cssytd
2013-04-04 15:07:04 +02:00
Raphael Collet 09be864f1d [IMP] replace all tests like 'registry.get(X)' by 'X in registry' where X is non static
bzr revid: rco@openerp.com-20130329140723-dnrl02saky570xg0
2013-03-29 15:07:23 +01:00