Avoid "patching" the registry, as this introduces inconsistencies (some field
attributes are lost). Instead, proceed as follows:
- update the definition of custom fields in database;
- clear the corresponding cache on the registry (this was missing);
- setup the models in registry (this reloads the custom models and fields);
- update the database schema of the models based on the registry.
This makes the update of custom fields simpler and more robust.
If multiple warnings were returned by a cascading onchange
call, only the last warning was displayed.
This revision concatenates the warnings in such a case.
opw-649275
The "Synchronise translation" wizard almost doubles the number of translated
terms in database.
This is due to the loss of the module reference at the synchronisation
(`module_name` is empty as updating all modules)
Only overwrite the module when it is set (default None)
Fixes#6149
Second part of the patches avoid inserting translations without any module for
locale xml ids.
If an error happens in an overload of setUp, the already-open cursor
is likely not to get properly released before the next test,
deadlocking the db, because tearDown only runs if setUp has
succesfully completed.
Cleanups were added specifically to run every time, after tearDown has
(potentially) been executed.
closes#8327
Note: cleanups run in LIFO order (as they should).
In 5efac22043 and
1cf5723835 the computation
of the decimal precision of float fields was modified to
reuse a random cursor from the request environments.
Environment.envs is a WeakSet, subject to unpredictable
garbage collections.
This could cause hard-to-diagnose problems by executing
a SELECT query in a cursor that is supposed to be
otherwise idle and untouched.
As an example, this could cause a transaction start in a
cursor that was just committed/rolled back,
and was waiting for another operation to complete.
One such case happened semi-randomly during a module
installation triggered from the web client, where the request
cursor is committed and waiting for the registry
initialization done with a different cursor,
in the middle of _button_immediate_function()
After the registry initialization, the request cursor is
used again to determine the next action (ir.actions.todo),
and this could cause a TransactionRollbackError if the
request cursor was used during the initialization.
Using a new cursor every time is much safer, simpler,
and will not cause any significant performance hit,
because it will usually grab an available connection
from the connection pool, rather than create a new one.
Fixes opw-649151
* alter docstring of @api.one to mark it as deprecated for 9.0,
recommend using @api.multi instead
- deprecation notes were not correctly styled, add styling
matching "warning" alerts
* move @api.one down the doc page to deemphasize it
* fix "backend" tutorial to remove all instances of ``@api.one``
closes#8527
When linking a record into a `one2many` relation with command `(4, rid)`, a
query checks whether the record is already linked to the current record id:
SELECT 1 FROM {inv_table} WHERE id={rid} AND {inv_field}={id}
where `inv_field` is the name of the inverse field, and `inv_table` is the
table where this field is stored.
The query is wrong if the inverse field is inherited, because the `rid` does
not belong to the table `inv_table`.
The test has been replaced by a plain ORM access:
rec = obj.browse(cr, SUPERUSER_ID, rid)
if int(rec[inv_field]) != id:
...
This fixes#4685.
When exporting the translations, the terms stored in individual files outside of
addons folders (e.g. openerp/models.py) needs to be scanned as well and added in
base translations.
Some folders like osv and report were enough to add these files but with the new
api moving the ORM to openerp folder, a non-recusrive scan needs to be added.
Fixes#7482
The recomputation should not be necessary, as we normally don't change the
record referred by an ir_model_data record. This speeds up the creation of
ir_model_data records by 33%, which should be noticeable during module
installations.
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#8094Closes#8142
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.
The risk was introduced by b7f1b9c.
IF _store_set_values() recall another _create() or _write(),
the recomputation mechanism enter in an infinite recursion
trying to reevaluate for each call exactly the same fields
for the same records than the previous one
This revision replaces the loop of _store_set_values()
by 2 nested loops:
- that not breaks the entire consumption
of recompute_old queue
(Tested thanks to revision a922d39),
- that allows to clear the queue
before each recomputations bundle fixing thereby the recursion
Closes#7558