Commit Graph

720 Commits

Author SHA1 Message Date
Christophe Simonis 2e9b33b793 [MERGE] forward port of branch 7.0 up to 80c7209 2015-11-03 11:40:01 +01:00
Raphael Collet 8ea17a8cc9 [FIX] orm: always save boolean function fields, even when they are false
Fixes #4292: searching for records when a related boolean field is `False`
always returns nothing.
2015-10-12 16:38:17 +02:00
Olivier Dony 733cb3e76f [MERGE] Forward-port from 7.0 up to 8b3d69a0d7 2015-08-04 15:17:51 +02:00
Daniel Reis 8b3d69a0d7 [FIX] orm: performance of regex to check search `order` spec
This regex is used for a quick sanity check of
the order_spec in `search(order=<order_spec>)`.
Because it was build on the repetition of a
group ending with a series of optional patterns,
it could cause expensive backtracking when the
order spec did not actually match the regex
(the regex engine was trying all possible ways
to split the groups)

Forcing the repeating group to either end
with a comma or the end of the string prevents
prohibitive backtracking, while being even
more restrictive with regard to the syntax of
the order spec.

Closes #7755
2015-08-04 11:45:01 +02:00
Christophe Simonis d3e7a8ef5e [MERGE] forward port of branch 7.0 up to 856bc6f 2015-04-10 18:24:46 +02:00
Ravi Gohil ffacce7140 [FIX] orm: export on empty one2many
When exporting the content of a one2many, if the first row got an empty value,
it was filled with the name_get of all lines and skipped the next lines.
The guessed reason of this was for the representation of the m2m lines but was
left after a proper export of m2m has been implemented (91cafbe).
This code was problematic as it prevented to properly export records with
an empty value on the first line (e.g. credit amount on account.move.line).
Fixes #4218, opw 620178
2015-04-07 15:54:01 +02:00
Denis Ledoux a692c6e934 [MERGE] forward port of branch 7.0 up to f406847 2015-01-15 11:49:28 +01:00
Sandy 3b7e00d718 [FIX] orm: prevent pgerrors from raising `UnicodeDecodeError`
Use `tools.ustr` for error conversion to prevent `UnicodeDecodeError` when
converting errors which can be unicode in depending on data.

Example:
```python
from openerp.osv.orm import convert_pgerror_23505
from psycopg2 import IntegrityError

e = IntegrityError(
    'duplicate key value violates unique constraint '
    '"hr_job_name_company_uniq"\nDETAIL:  '
    'Key (name, company_id)=(Directrice comptabilit\xc3\xa9, 1) '
    'already exists.\n'
)

convert_pgerror_23505(None, [], None, e)

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 129: ordinal not in range(128)
```
2015-01-12 15:35:23 +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
Denis Ledoux 0e4216361b [MERGE] forward port of branch 7.0 up to 3a0af6a 2014-10-22 19:26:27 +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
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
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
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 5a0a500994 [MERGE] Forward-port 7.0 up to 9411a2da 2014-08-01 23:01:57 +02:00
Olivier Dony 9411a2da03 [FIX] Model.load(): extra error checking while importing data
If any missing or partially incorrect values cause
an exception other than a psycopg2 error, we should
still catch it, rollback that record and report
the error, rather than letting bubble and fail
without any feedback to the user.

Fixes #1485
2014-08-01 22:42:01 +02:00
dhr-odoo eb775fc2ea [FIX] orm: set default before removing magic fields
When a record is created, the magic fields (id, create_date,...) are first removed from the vals as the user should not set a value for these.
However if a value for this is given in default value (e.g. defined in an ir.value), the creation would crash (sql error : column specified more than once) as the magic column would be added again.
2014-08-01 15:37:01 +02:00
Olivier Dony e79a3675d1 [FIX] orm.search_count: ignore `limit`, `offset` and most importantly `order`
These parameters are (or should be) irrelevant for
a search_count(), and they could actually break the
result or make it significantly slower (e.g applying
`order` on large tables).
This fixes a performance regression introduced by
0f43032b.

We could also raise an error offset/limit are
passed in combination with count, but that seems
unnecessary.

Also switched to "SELECT count(1)" for the count
query, as it is simpler and just as fast.
We'd get the same perf with * or any constant value,
as in "SELECT count('me in')", but let's keep it
simple ;-)
2014-08-01 12:34:45 +02:00
Olivier Dony a9d2b65da5 [MERGE] Fwd-port 7.0 up to 783b9e1 2014-07-11 11:51:06 +02:00
Martin Trigaux 437116f3c4 [FIX] orm: custom m2m with different label
At rev 84e9a67cdf a check to avoid the creation of ir.model.relation for custom modules was added. The condition is not correct as based on the string instead of the field name. We do not have access to column name at this level but the the m2m relation table do start with x_ for custom fields (see __init__ method).
2014-07-11 11:39:32 +02:00
Christophe Simonis a35aec2a0b [MERGE] forward port of branch 7.0 up to 6e96ffd 2014-07-10 22:02:01 +02:00
Martin Trigaux 84e9a67cdf [FIX] orm: better removal of custom m2m fields
orm: do not try to create ir.model.relation for custom m2m as self._module is either empty (for custom models), either the one of the last inheriting module (which is wrong). The field should be removed manually and should not be impacted by the uninstallation of modules. The removal of the relation table can be done when removing manually the custom field (see rev 6af3193).

ir.model: when removing a model, drop the table with the CASCADE instruction. This will remove left constraints from remaining m2m tables.
This means that dropping a table (either manually removing a custom model or uninstalling a module) will not drop the relation table for a custom m2m field. This is not ideal but better than the previous behaviour (which was to fail the DROP TABLE instruction and keep the table with a few columns and unconsistent data).
2014-07-08 15:56:24 +02:00
kevin wang 59c27970b5 [FIX] orm: allow unicode in inherit views with attribute
When extending a view with position='attributes', prevent crash if view contains unicode char
Fixes #706
2014-06-23 12:48:27 +02:00
Denis Ledoux 3c0292645f [MERGE] Forward-port of 7.0 bugfixes up to 63ea0df73f 2014-06-16 17:37:10 +02:00
Martin Trigaux 86acc1a62f [FIX] orm: avoir errors reading twice a field
_read_flat: remove duplicated fields in read call
get many2one: as False is instance of int, check the value of x first to avoid calling a name_get with a list of False

When we were reading twice a m2o field where at least one result is null, the first call to name_get would set the value to False instead of None and then accepted by the filter 'isinstance(x, (int,long))'
2014-06-12 16:14:41 +02:00
Christophe Simonis 4601d85944 [MERGE] forward port of branch 7.0 up to 6fdb783 2014-06-10 11:49:14 +02:00
Oliver Laurent 306d5c89a0 [FIX] orm: do not resize unlimited char fields 2014-06-05 19:05:36 +02:00
Christophe Simonis 38abc8a006 [MERGE] forward port of branch 7.0 up to revid b09b6a0 2014-05-20 18:57:04 +02:00
Thibault Delavallée 066fb14326 [FIX] orm: unlink: when unlinking a record, trigger the computing of
function fields for other records in the same model. Previously all function fields in the
current model were not computed for some reason not provided by the history.

We therefore compute effective store_ids on which the various trigerred
function fields will be computed again. Those ids are the ids given
in the store_get storage variable minus the deleted ones.
2014-05-19 18:12:41 +02:00
Olivier Dony 7e66bd9d55 [FIX] orm.search_read: drop active_test context flag during the read() step
The active_test flag is meant for search(),
but when passed to search_read() it was also
propagated to the read() call.
This has little consequence normally because
read() ignores this flag, but it can have
side-effects when reading x2m fields or
function fields. They are likely to call
search() somewhere downstream, still with
 the propagated active_test flag, while
it should not be applied anymore.

Ultimately dropping this flag could be
done by read() in all cases, but changing
search_read() is less likely to block
exotic cases where the flag was passed
on purpose. Moving it to read() could
be done as a later step.
2014-05-13 17:29:35 +02:00
Christophe Simonis 1e9ed7baf6 [MERGE] forward port of branch 7.0 up to revid 5275 odo@openerp.com-20140407105740-elbz311w5u9e8eos
bzr revid: chs@openerp.com-20140407144238-3s38zadkh7yxpdy7
2014-04-07 16:42:38 +02:00
Olivier Dony 5be9e5612f [FIX] browse()/browse_record: use iterables instead of forcing lists when constructing browse_lists
This allows iterable list_class implementations

bzr revid: odo@openerp.com-20140407105740-elbz311w5u9e8eos
2014-04-07 12:57:40 +02:00
Martin Trigaux 9b19c1a337 [FIX] orm: add missing pooler in call
bzr revid: mat@openerp.com-20140403074134-fav63w1k6hm1b8ar
2014-04-03 09:41:34 +02:00
Christophe Simonis c7d114d9a9 [MERGE] forward port of branch saas-2 up to revid 5020 chs@openerp.com-20140312174526-a5rhh83g0fw8djuc
bzr revid: chs@openerp.com-20140312180614-8yb454s3mkjwnk2q
2014-03-12 19:06:14 +01: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
Olivier Dony 07fbbe288c [MERGE] Forward-port of 7.0 bugfixes, up to rev. 5251 revision-id: odo@openerp.com-20140304152927-havybom9x1jgdzae
bzr revid: odo@openerp.com-20140305213115-w55dqs3xra6ejmni
2014-03-05 22:31:15 +01:00
Martin Trigaux 63763dcc55 [IMP] readability
bzr revid: mat@openerp.com-20140305143050-zddqtyh7qg6lcx3q
2014-03-05 15:30:50 +01:00
Martin Trigaux 016a1ed37b [FIX] orm: create a foreign key for the function fields of type many2one and store value
bzr revid: mat@openerp.com-20140305140514-2sksy3lwqm07wvjh
2014-03-05 15:05:14 +01:00
Olivier Dony b79a33aefc [FIX] orm.read_group: improve test coverage and corner case handling:
- allow leading spaces in orderby spec for m2o columns
- extra test for read_group on multiple columns
- proper handling of groupby on numeric column with default order

bzr revid: odo@openerp.com-20140304152927-havybom9x1jgdzae
2014-03-04 16:29:27 +01:00
Olivier Dony 27a1770e20 [FIX] orm.read_group: fix various issues introduced in recent commit, cleanup
Fixed the implementation of the sorting for inherited
columns, many2one columns, and aggregated columns.
Added corresponding tests with increased coverage of
the read_group() method.

bzr revid: odo@openerp.com-20140228173320-p8l0jc8op7xsgn1x
2014-02-28 18:33:20 +01:00
Martin Trigaux 43df0b4d23 [MERGE] [FIX] orm: when generating xml ids for export, use the model of the exported field instead of the current model. Courtesy of Stefan Rijnhart (Therp).
bzr revid: mat@openerp.com-20140226133716-vgdjjmqc2lou0n3u
2014-02-26 14:37:16 +01:00
Denis Ledoux 67866db5b6 [MERGE] Forward-port of latest saas-2 bugfixes, up to rev. 5015 dle@openerp.com-20140221104908-7ytdg6xkxaza05o4
bzr revid: dle@openerp.com-20140220132700-hhc1nsu25j1ye257
bzr revid: mat@openerp.com-20140220150028-p6l0vnwa5q18uxiu
bzr revid: dle@openerp.com-20140221105500-t7jg037uusdloigl
2014-02-21 11:55:00 +01:00
Martin Trigaux bb3ff8b449 [MERGE] Forward-port of latest 7.0 bugfixes, up to rev.5240 revid:mat@openerp.com-20140220145445-0xt7alp3uj0os1fz
bzr revid: mat@openerp.com-20140220145701-6y7s1roj88q7ys13
2014-02-20 15:57:01 +01:00