Commit Graph

1117 Commits

Author SHA1 Message Date
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
Denis Ledoux 00762bbae0 [MERGE] forward port of branch saas-3 up to 643bbcb 2015-01-05 14:25:34 +01:00
Denis Ledoux 643bbcb00b [MERGE] forward port of branch 7.0 up to 27d8cb8 2015-01-05 13:48:01 +01:00
Denis Ledoux 27d8cb843b [FIX] fields: apply user timezone in display name for models using a datetime as name
For models using a datetime field as name (hr.attendance for instance), the user timezone wasn't applied in the display name.
Therefore, in the breadcrumb, the datetime was different than in the form if the user had another timezone than UTC.
2015-01-05 12:48:38 +01:00
Denis Ledoux 276d0e76b2 [MERGE] forward port of branch 7.0 up to 284ca73 2014-12-08 14:57:21 +01:00
Sandy Carter aa10972d13 Raise error on read of a browse object with bad id
Check if id is valid by searching record columns when a key error is raised
If the record has the column, the key error is actually an error on a
missing or inaccessible id.

Signed-off-by: Sandy Carter <sandy.carter@savoirfairelinux.com>

Closes #3658
2014-12-04 13:24:26 +01:00
Raphael Collet fc2975a9af [IMP] models: in _init_manual_fields(), create fields instead of columns
Note that serialized fields are ignored; they are no longer supported, anyway.
2014-11-13 14:54:04 +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 7b1ef7085a [IMP] fields: reduce the number of attributes on _column instances
This is a memory optimization: instead of setting all attributes on all
instances, set them with their default value on the class, and only set
specific ones on instances.  This reduces the memory footprint of around 14Mb
per registry with modules crm, sale, purchase and stock installed.
2014-10-27 14:36:09 +01:00
Denis Ledoux 0e4216361b [MERGE] forward port of branch 7.0 up to 3a0af6a 2014-10-22 19:26:27 +02:00
Raphael Collet 8e6d5beb35 [IMP] fields: reuse column objects when possible, instead of recreating them
This is a memory optimization: it reduces the memory footprint of each
registry.  We have observed a reduction of 10Mb on a database with modules crm,
sale, purchase, stock.
2014-10-22 16:22:39 +02:00
Cedric Snauwaert fa2f7b86bf [FIX] product: remove digits_precision from uom factor fields
Remove the hardcoded precision of 12 on factor and factor_inv,
to use the complete natural precision of NUMERIC types,
preserving all significant digits.

e.g. a UoM with a factor_inv of 6.0 used to be computed as:
factor_inv: 6.0 -> factor: 0.166666666667 (1.0/6.0, rounded to 12 digits) -> factor_inv: 5.999999999988 (1.0/factor)
which could lead to errors such 12*0.166666666667 = 2.000000000004 instead of 2.0

Slightly changed the way the ORM handles float fields to allow setting `digits=0`
as a way to explicitly require a NUMERIC value but without enforcing/rounding
the values at the ORM level, i.e. a truly full-precision field.

NUMERIC type has unlimited precision but is less efficient so should not be
used as the default behaviour, which is why we keep float8 as an alternative.

Modified the view to display the product UOM factor with a 5 digits value by default.
This value is for usability purpose only, the field still accepts bigger precision, by
setting the `digits` option on the field in the form view.

This change is safe in a stable series, the `digits=0` alternative is
treated the same as the default `digits=None` everywhere in the framework,
except when creating the database field.
2014-10-22 14:28:34 +02: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 10142d7dc7 [FIX] openerp/osv/fields: fix method to_field() to pass some falsy parameters.
For instance, the attribute copy=False was not passed when converting the
_column to a Field.  Simply make sure those parameter are always passed.
2014-10-08 16:39:59 +02:00
Raphael Collet a69996b50c [IMP] fields: split multi-purpose '_origin' into 'column' and 'inherited'
This makes it easier to determine when a field interfaces a column, and when it
implements an inherited field (with _inherits).
2014-10-01 16:00:44 +02:00
Denis Ledoux b6e6b57326 [FIX] orm: typo during forward port 60a82133cc 2014-09-17 16:24:40 +02:00
Denis Ledoux 60a82133cc [MERGE] forward port of branch 7.0 up to f5f7609 2014-09-17 13:39:13 +02:00
Denis Ledoux f5f76094a7 [FIX] orm write: do not try to store computed & stored fields for relational records deleted by *2many fields
opw-613772
2014-09-17 13:32:30 +02:00
Martin Trigaux 32f5168974 [FIX] orm: do not drop foreign keys of transient models
During the update of a module, the existing foreign keys are dropped if they have a different ondelete_rule than the one specified on the field.
The foreign keys for many2one transiant -> non-transiant are created with cascade rule by default (see `m2o_add_foreign_key_checked` method) so the check needs to be realised in the same conditions.
2014-09-15 15:24:53 +02:00
Christophe Simonis fdc62713a5 [MERGE] forward port of branch 7.0 up to 9b1cdea 2014-09-12 17:28:55 +02:00
Denis Ledoux 2459cd5dd1 [FIX] ir_attachment: attachements removed on record unlink 2014-09-10 12:18:14 +02:00
Raphael Collet 7428464004 [FIX] openerp/osv/fields: disable prefetching when reading inverse of one2many fields
This fixes issue #2146.  The inverse of a one2many field can be an inherited
field (_inherits).  In that case, we cannot read its value with a simple
database query.  Instead, we let the related field read it, but for performance
considerations we disable the prefetching of other fields.
2014-09-10 09:41:36 +02:00
Denis Ledoux b1f4a61705 [MERGE] forward port of branch 7.0 up to 8dff247 2014-09-09 18:23:32 +02:00
Denis Ledoux 8dff247096 [FIX] orm, read_group: read_group_fill_results handle no_leaf 2014-09-09 16:47:40 +02:00
Raphael Collet f2f1f3465d [IMP] models: prefetch fields with groups (those to which user has access) 2014-09-02 14:11:11 +02:00
Martin Trigaux 4a10295823 [FIX] fields: avoid prefetching of one2many fields
When reading a one2many field, the inverse mapping of the lines (matching m2o -> lines of corresponding record) was instantiating each line and then triggering the prefect of fields.
To improve the performances, the inverse mapping is done in sql to avoid triggering the prefetching.
2014-09-02 13:34:57 +02:00
Raphael Collet 2c6ee89080 [FIX] osv/fields.py: enable argument 'obj' in property fields
Fixes #1719
2014-08-22 12:10:46 +02:00
Raphael Collet 20b302cc8c [FIX] osv/fields.py: fix the fix at rev 43756a24. 2014-08-22 11:14:08 +02:00
Raphael Collet 43756a24ca [FIX] osv/fields.py: fix sum in rev 48dfd70 2014-08-22 10:56:07 +02:00
Raphael Collet 48dfd70b4a [IMP] osv/fields.py: improve code change of rev eea07e27 2014-08-22 09:23:42 +02:00
Christophe Simonis eea07e27c0 [FIX] osv/fields.py: correct reading name_get of m2o property 2014-08-21 21:23:22 +02:00
Raphael Collet 618e397df1 [FIX] fields: in many2one property fields, name_get() the value as superuser 2014-08-21 17:29:56 +02:00
Raphael Collet dce5228da7 [FIX] fields: add missing option 'sanitize' on Html fields 2014-08-21 13:27:30 +02:00
Christophe Simonis 5dff035878 [MERGE] forward port of branch saas-5 up to 39bee35 2014-08-20 20:33:17 +02:00
Christophe Simonis c3131317d7 [MERGE] forward port of branch saas-4 up to ddef2dd 2014-08-20 17:57:22 +02:00
Christophe Simonis ddef2dd10a [MERGE] forward port of branch saas-3 up to 8f13e83 2014-08-20 17:51:20 +02:00
Christophe Simonis 8f13e8320e [MERGE] forward port of branch 7.0 up to d0a0b7d 2014-08-20 17:45:05 +02:00
Martin Ambroz 106cb1ec2b [FIX] base: python 2.6 incompatibility for dictionary comprehension 2014-08-20 10:28:37 +02:00
Raphael Collet 052f9ed5d7 [FIX] models: improve rationale for the management of flag 'recompute' in context
When the context contains 'recompute': False, the recomputation was not even
prepared. Now both create() and write() prepare the recomputation by invoking
method modified(). The flag only controls whether method recompute() is invoked.
In addintion, the former flag 'no_store_function' was converted to the flag
'recompute', so that both create() and write() use the same flag.

Fixes #1456
2014-08-19 11:50:42 +02:00
Olivier Dony e11eddf753 [MERGE] Forward-port of saas-5 up to 20cc18d 2014-08-13 20:46:47 +02:00
Olivier Dony 2a94d1d811 [MERGE] Forward-port saas-4 up to 2694ed1 2014-08-13 17:34:27 +02:00
Olivier Dony 2694ed1472 [MERGE] Forward-port saas-3 up to b9275da 2014-08-13 17:33:12 +02:00
Olivier Dony b9275da8a5 [MERGE] Forward-port 7.0 up to 23cffab 2014-08-13 17:30:06 +02:00
Samus CTO 7f88681186 [FIX] context_timestamp MUST return a "timezone aware" timestamp 2014-08-13 14:58:55 +02:00
Olivier Dony 7aa0376f3e [FIX] gamification: prohibitive record rule processing with many users/goals
Due to the multi-company record rule on gamification.goal,
each access to the Goals menu and each opening of the
Messaging menu (thus calling get_serialised_gamification_summary())
is extremely slow (with several thousands goals/users).

Adding auto_join to the user_id FK on goals makes it much
faster. However it causes crashes when reading the table
because the _order of gamification.goal uses `create_date`,
which becomes ambiguous after the auto_join with res_users.

Solving this can be done by re-implementing _read_flat()
in the ORM using the internal Query object, as in search(),
which takes care of fully-qualifying all column names.

Until this is fixed, a simple workaround is to use
start_date in the _order instead of collision-prone `create_date`.
2014-08-13 13:47:50 +02:00
Olivier Dony a2943a4432 [IMP] fields.boolean: simplify symbol_set, cast to bool
In combination with f28be81, this should help speed up
initialization of new boolean columns. psycopg2 handles
bool parameters values just fine inside cr.mogrify()
2014-08-11 12:37:52 +02:00
Christophe Simonis 407c1be1e8 [FIX] fields.py: correct copy/paste error, use the right attribute 2014-08-07 13:50:27 +02:00