Commit Graph

7783 Commits

Author SHA1 Message Date
Raphael Collet 915af86a91 [IMP] fields: simplify definition of ID field 2015-03-23 14:36:15 +01:00
Raphael Collet ffa7f28d34 [IMP] fields: reduce memory footprint of list/set field attributes
The optimization consists in using tuples for attributes `inverse_fields`,
`computed_fields` and `_triggers`, and to let them share their value when it is
empty, which is common.  This saves around 1.8Mb per registry.
2015-03-23 14:36:15 +01:00
Raphael Collet 3df7754087 [IMP] fields: reduce memory footprint of `field._attrs` and `column._args`
The optimization consists in sharing the dictionary when it is empty, which is
the common case.  This saves around 1.5Mb per registry.
2015-03-23 14:36:15 +01:00
Raphael Collet 4d232969a3 [IMP] fields: remove attribute `_free_attrs` and use `_attrs` instead
This saves about 400Kb per registry by not allocating those lists, which are in
most cases empty.  The removal of the attribute will also simplify a bit the
management of free attributes.
2015-03-23 14:36:15 +01:00
Raphael Collet 9aad3d873b [IMP] fields: turn field.digits and column.digits into dynamic properties
The computed value of parameter digits is no longer stored into fields and
columns; instead the value is recomputed everytime it is needed.  Note that
performance is not an issue, since the method `get_precision` of model
'decimal.precision' is cached by the orm.  This simplifies the management of
digits on fields and saves about 300Kb per registry.
2015-03-23 14:36:15 +01:00
Raphael Collet bf703fd9a3 [FIX] models: reorder the base classes of models following an equivalent class hierarchy
Sometimes, the expected mro of the model is not the same as the one built with
a binary class hierarchy.  So we reorder the base classes in order to match the
equivalent binary class hierarchy.  This also fixes the cases where duplicates
appear in base classes.
2015-03-23 14:36:14 +01:00
Raphael Collet 9bce04de79 [IMP] models: build a flat hierarchy of classes for models
Instead of composing classes in a binary tree hierarchy, we make one class that
inherits from all its base classes.  This avoids keeping intermediate data
structures for columns, inherits, constraints, etc.  This saves about 600Kb per
registry.
2015-03-23 14:36:14 +01:00
Raphael Collet 0f9b452c33 [IMP] models: convert deprecated model._all_columns into a dynamic property
The mappings model._all_columns takes quite some memory (around 2MB per
registry) because of the numerous dictionaries (one per model) and inefficient
memory storage of column_info.  Since it is deprecated and almost no longer
used, it can be computed on demand.
2015-03-23 14:36:14 +01:00
Raphael Collet e2ea691cef [IMP] ormcache: turn it into a global LRU cache shared among registries
The ormcache is now shared among registries.  The cached methods use keys like
(DBNAME, MODELNAME, METHOD, args...).  This allows registries with high load to
use more cache than other registries.
2015-03-23 14:36:14 +01:00
Dharmraj Jhala 01f2c5c9d2 [IMP] Allow custom ordering of files contained in zip dumps
This will allow to speed up our migration platform: as funzip can pipe
the output of the first file of the archive, even if the file is not
fully unzipped yet. This is useful to plays with dump.sql without waiting
for the full archive decompression.
2015-03-18 14:22:22 +01:00
Olivier Dony d93148240b [FIX] ir.model.data: update_dummy should mark `inherits` parents too
When a `noupdate` record is processed during an update,
the update_dummy method marks the record as "seen" so
it won't be deleted at the garbage collection step,
and seen as an obsolete external ID.

This needs to be done also for the parent records via
_inherits, because they have also received an implicit
external ID at creation, and must not be garbage
collected, even if their `noupdate` flag (db side)
is not set because the flag was added later.

This rare problem could be reproduced by creating a product
in a module, then referencing it in e.g. a sales order,
then updating the module after changing the product
record to be in a `noupdate` block.
At the end of the update the implicit product.template
record would be garbage collected, and trigger a cascade
deletion of its children - blocked by the SO reference
to the product.
2015-03-18 14:10:18 +01:00
Christophe Simonis e27744df0c [MERGE] forward port of branch saas-3 up to b79f64f 2015-03-18 13:16:23 +01:00
Christophe Simonis b79f64f1f8 [MERGE] forward port of branch 7.0 up to e1daaff 2015-03-18 12:52:33 +01:00
Raphael Collet 6aa28a89bb [FIX] models: compute many2many field on existing records when field is introduced by an update 2015-03-18 09:43:45 +01:00
Raphael Collet e182da22f4 [FIX] base/ir_model: upon custom field creation, always clear manual fields in registry
The invalidation in registry was done only if the field's model was already in
registry.  This situation is not the case when you create a custom model with a
custom field.
2015-03-17 11:51:22 +01:00
Raphael Collet 7ac4639a24 [FIX] fields: fix determination of `field.selection` for custom fields
In the case of custom fields, `field.selection` is set directly instead of
being set in overridden fields.
2015-03-16 15:34:16 +01:00
Thomas Groutars 7e0ff24cca [FIX] base: delete cascade value mapping on server action deletion
When deleting a server action, its fields_lines were not deleted.
It causes an issue for example in this case:

Create a new custom field on any model
Create a server action with
Action To Do: Write on a Record
Base model: model of the custom field
Add a line in the value mapping,
using the custom field you just created

Delete the server action

Delete the custom field => Throws an error because
required field col1 is not defined
on the ir_server_object_lines object
2015-03-13 11:25:08 +01:00
Fabien Pinckaers 4491c20bf0 Merge pull request #5728 from apertoso/8.0_fix_nl_BE_naming
[FIX] nl_BE language name
2015-03-12 15:28:07 -07:00
Thomas Groutars 3923f4051d [FIX] models: propagate context in action returned by get_formview_action
When opening a record from a many2one,
the context is not propagated to fields_view_get.
This is a problem if you set "form_view_ref" in the context for example.

opw-629628
2015-03-12 15:13:44 +01:00
Jos De Graeve 170674f994 Fix nl_BE language name 2015-03-12 15:08:10 +01:00
Nicolas Martinelli 2275af4b77 [FIX] base: ir sequence number is now reset to the requested value when calling the write method
opw: 626974
2015-03-11 11:35:25 +01:00
Julien Laloux a20545a936 [IMP] web: add no update info on metadata view (debug mode) 2015-03-11 11:10:42 +01:00
Olivier Dony edcbf067d6 [FIX] workflow.workitem: deleting a subflow should never cascade to workitems
It's always dangerous because (cascade-)deleting workitems
has a great chance of killing the workflow instances they
belong to, putting the records in the workflow limbo
permanently. (They will appear stuck as they don't have
enough workitems anymore)

In addition, in some rare cases a subflow activity is
converted into a regular activity during an update, and
nullifying the `subflow_id` column is all there is to
fixing the corresponding workitems. It will simply take
them out of their subflow, and back into the main flow.

This is the case for the modification of the purchase.order
workflow in Odoo 8 (saas-5), for the picking subflow.
2015-03-10 19:35:23 +01:00
Olivier Dony 13476c844d [FIX] fields.html, forum: opt-in stripping of @style attrs
For public-facing HTML content provided by the user,
`<style>` tags and `style` attributes should be stripped
automatically, as they can easily be abused to deface
pages for abusive users and spammers.
<style> tags were already stripped, the optional `strip_style`
for fields.html enables the automatic stripping of style
attributes.

This is opt-in because custom style attributes are still
desirable in trusted HTML fields.
2015-03-09 14:41:14 +01:00
Christophe Simonis 416f0246ac [MERGE] forward port of branch saas-3 up to 4a3c471 2015-03-09 12:03:22 +01:00
Christophe Simonis 4a3c4713e9 [MERGE] forward port of branch 7.0 up to 209ce6f 2015-03-09 11:24:32 +01:00
Christophe Simonis 7bfd56d9c6 [FIX] base: correct test
Bad things happen when you write your code for master and
commit it in 8.0 without testing...
2015-03-04 13:38:36 +01:00
Christophe Simonis d6998061f1 [FIX] base: correct custom views validation.
As custom views validation is done while `self.pool._init` is set,
filter on currently loaded modules was still applied.
As a side effect, only one custom view per base view was validated.
In case this view is depending on another custom inherited view, the
validation failed.
Now force loading all views when validating custom views.
2015-03-04 12:49:06 +01:00
Christophe Simonis 325de62f51 [FIX] base: correct inheritance application
While `apply_inheritance_specs` apply most of its changes inplace, it may
completely replace the `arch_tree` if the root node is replaced.
This new root node wasn't used for `primary` views that inherit from
another.
2015-03-04 12:43:22 +01:00
Stefan Rijnhart 4781deb5b6 [FIX] base: Replace unreliable reference count through ORM by SQL
When the ORM is cleaning up related attachments upon record deletion, the
search() method hides the attachment of the record that is being deleted.
If the same file is used exactly once in another attachment, the reference
count will be 1 and the file will be deleted.
2015-03-04 11:23:44 +01:00
Xavier Morel 603c03799d [FIX] ir.qweb: ensure attributes are generated encoded
closes #2856, closes #4182
2015-03-03 17:04:20 +01:00
Raphael Collet 983dcf193c [FIX] fields: make base_field recursive in case a field is inherits'ed across several models 2015-03-03 13:18:04 +01:00
Raphael Collet 04ba0e99a4 [IMP] models: in _read_from_database(), fetch inherited fields when possible
This should improve the performance of method read() on models with inherited
fields, like product.product.  The inherited fields that are stored as columns
in parent tables (except for translated fields) are read in the same query as
the fields of the model.  Those fields will be directly stored in cache under
the main model, so that no copying will take place in cache for accessing them
(this is the default implementation of inherited fields).
2015-03-03 13:18:04 +01:00
Raphael Collet 2c261a2987 [IMP] models: in _read_from_database(), use the Query object to build the query
This makes the query construction more robust, as it handles joins for
conditions and ORDER BY clauses.  It also makes it easier to read() from
several tables (like inherited fields).
2015-03-03 13:18:04 +01:00
Raphael Collet 021c1a26c5 [IMP] fields: improve performance when reading many2one fields on records
Improve the performance of `name_get()` on many2one field values by making sure
that the records on which `name_get` is invoked are prefetched in cache.  This
is not automatic, because `name_get` is invoked on records in another
environment (sudo mode): the prefetching in the original environment should be
reproduced in the other environment.
2015-03-03 09:38:36 +01:00
FalcoBolger 714fe9135d [FIX] Signature on overriden fields_get method 2015-03-02 16:52:53 +01:00
David Monjoie 71e4d7145b [FIX] Scaffolding: moved two files to better reflect the architecture we currently use for our themes 2015-03-02 16:38:35 +01:00
Aaron Bohy 9ebfa11b8c [FIX] Packaging, Scaffolding: template files extension
Add .template as extension of the template files because RPM packaging
produces an error when trying to compile the python template files,
which contains Jinja instructions.

Include *.template files in MANIFEST.in to package them.
2015-03-02 16:38:34 +01:00
Holger Brunn 323233dd02 [FIX] ir_filters: return _auto_init's result
Closes #5204
2015-03-01 03:06:03 +01:00
Ravi Gohil 04de292885 [FIX] http: support old version of psutil
Add support for older versions of psutil (<1.2.0). Only used when
debug_rpc is enabled.

Closes #5108, #5163
2015-03-01 02:17:04 +01:00
Samus CTO fb285d8695 [FIX] prevent unneeded chmod datadir, but check writable 2015-02-27 17:16:16 +01:00
Christophe Simonis e6396deb4e [IMP] models: log source when "Comparing apples and oranges" 2015-02-27 15:57:13 +01:00
Xavier Morel 4bd2ee1aaa [FIX] undefined variable
Variable was added to an error message, then inlined in only one of the
two callsites. Undefined variable error would only appear when an error
is triggered in the actual (postgres-level) backup call.

inserted in ec9a543

fixes #5241
2015-02-27 15:07:15 +01:00
Xavier Morel 68f14c6870 [FIX] handling of big fields in CSV
fixes #2742
2015-02-27 14:11:21 +01:00
Christophe Simonis f0dc416871 [FIX] phantomjs 2.0 compatibility
phantomjs 2.0 remove the deprecated attribute `phantom.args`. Use the
new `system` module.
2015-02-26 15:08:17 +01:00
Raphael Collet 0c1b95d824 Merge pull request #5439 from guewen/test-inherits-3-levels
Reload fields of parent inherits, fixes #5398
2015-02-26 10:06:31 +01:00
Goffin Simon cbb51610ee [FIX] ir.ui.view: qweb translations: allow looking up translation in parent template
- Translations lookup normally uses the namespace of the current
QWeb template, after merging all inherited views.
But when a QWeb template is "cloned" by a child view using
inheritance with `primary` mode, the translations are more
likely to exist for the original (parent) template, and would not
be found when using only the "child" namespace.
This patch adds support for looking up each translation
also in the parent namespace in this case, if none was found
for the child template in the first place.

- ir.translation's _get_source() now supports a list of res_id
to search for, in addition to a single res_id

- Also moved the logic of routes /website/customize_template_get
and /website/get_view_translations to the ir.ui.view model where
it belongs.

opw: 615241

Closes #5325
2015-02-24 14:01:34 +01:00
David Monjoie 46186f54eb [FIX] openerp: fixed stretching of module icons in kanban view 2015-02-24 13:45:23 +01:00
Guewen Baconnier 608e58cce1 Reload fields of parent inherits, fixes #5398 2015-02-24 10:34:09 +01:00
Jeremy Kersten 0c964f0b7b [TYPO] modules: better safe than sorry
Too many people copy-past this line without understand !
2015-02-23 20:15:57 +01:00
Christophe Simonis a6a1764b2c [FIX] models: initialize `_fields` attribute.
Custom fields can point to custom models that have not been initialized
yet (`_setup_base` not called). Ensure every models in the registry
have a `_fields` attribute.
Use a `frozendict` as a defensive check to ensure it wont be modified
before calling `_setup_base`.
2015-02-23 18:33:26 +01:00
Raphael Collet 5ec8596f67 [FIX] fields: fix `_column.new()` by relying on `to_field_args()`
The implementation was based on the ill-defined method `same_parameters()` that
compares arguments based on a heuristic.  Instead, we now create a new column
and check whether it is equivalent to `self` by comparing the arguments
returned by `to_field_args()`.  If that is the case, `self` is reused instead
of the new column.

The code refactoring also fixes the column reuse which was broken by the
introduction of the parameter `compute` in commit 9333c62.  Indeed, with that
parameter, `same_parameters()` always returned False, since old-api columns do
not have that parameter by default.  The parameter has been renamed to
`_computed_field`, and is no longer passed for creating columns.
2015-02-23 15:50:09 +01:00
Raphael Collet 121b8e6800 [FIX] models: in onchange, false changes where detected in many2many fields
This was due to secondary fields loaded from database in 'onchange' mode.  In
that mode, the secondary fields were marked 'dirty', and therefore returned by
the method `onchange`.  The fix consists in loading those secondary fields in
cache before processing the onchanges.

This incidentally fixes a test on method `onchange`: in a one2many field, some
dirty fields were unexpectedly returned in the result.  This was due to those
fields being loaded while processing onchanges.
2015-02-21 11:29:13 +01:00
Denis Ledoux 2e7347dba5 [FIX] translate: possibility to disable translation of view nodes
Node content of inherited views using <attribute> tags are added
in the translation terms when syncing the terms.

The fact that the content should be translated or not depends
on the content, or to which attribute it refers.
For instance, string attributes should be translated, but
domains probably not.
But, even for domains, this is possible that it requires a translation
e.g. [('category_id.name', 'ilike', 'Customers')].
This domain is very unlikely to be integrated in the standard source code,
but this is possible to have such a domain in a view customization.

Therefore, we provide the possibility to disable the translation
case by case. Setting translation="off" in the attribute of the node
will prevent to add the node content in the translated terms.

opw-625762
2015-02-20 17:22:39 +01:00
Samus CTO 4ed38c2a92 [FIX] base: ambiguous @required for `name` of ir.actions subclasses
Column `name` is required in ir.actions, and thus
automatically required in subclasses such as `ir.actions.act_window`
and `ir.actions.act_url`, due to the specific PostgreSQL inheritance
mechanism. Mark it so in the model to make it explicit.
This does not change the database constraints, as they should already
be set though inheritance.

Closes #4861
2015-02-20 12:24:49 +01:00
Guewen Baconnier 461c93081d Add a failing test for write as well 2015-02-20 11:25:57 +01:00
Guewen Baconnier f7b9046c7b Add a failing test to reproduce #5398 2015-02-20 11:16:45 +01:00
Vicente Jimenez Aguilar 0892a088fc [FIX] report_webkit: multiple misspellings of wkhtmltopdf
closes #5392
2015-02-20 11:16:13 +01:00
Raphael Collet 9333c622e9 [FIX] fields: allow overriding of a old-api function field
When overriding a field defined as a function field, the field must either
create a corresponding column that is not a fields.function (if stored), or
have no corresponding column (if not stored).
2015-02-19 15:33:27 +01:00
Christophe Simonis bfb877a671 [FIX] ir.model.data: cleanup _process_end()
Allow deletion of ir.model and ir.model.fields when updating modules
Log xml id of deleted records
Remove xml id of non-existing records
2015-02-19 14:01:49 +01:00
Raphael Collet bf99f434c8 [IMP] models: speed up loading by computing `_constraint_methods` and `_onchange_methods` lazily 2015-02-18 16:43:20 +01:00
Raphael Collet 1439fcc40e [IMP] test_new_api: move test on delegate=True to module test_inherit
Group together the tests on fields that deal with _inherit and _inherits, and
avoid warnings about the field that uses delegate=True.
2015-02-18 16:43:20 +01:00
Raphael Collet 45a37b22fd [IMP] models: speedup loading of registry (-20%)
Idea: look up for the model's fields in method `_setup_base()` instead of
method `__init__()`.  This does not make a significant difference when
installing or upgrading modules, but when simply loading a registry, the
(expensive) field lookup is done once per model instead of once per class.
2015-02-18 16:43:20 +01:00
Olivier Dony e3ba594789 [I18N] Remove deprecated PO files (incorrect names)
Those files have already been replaced by
correctly named ones.

uk_UA.po -> uk.po
lt_LT.po -> lt.po
nl_NL.po -> nl.po
2015-02-18 12:11:51 +01:00
Olivier Dony 65e8115b8a [I18N] Update translations from Launchpad 8.0 branches (again), after syncing direct changes from 67bdc241bd 2015-02-18 11:58:13 +01:00
Olivier Dony 91d4b947f6 [I18N] Update translations from Launchpad 8.0 branches 2015-02-18 11:51:07 +01:00
Yenthe 67bdc241bd [FIX] incorrect etherpad url URL
closes #5287
2015-02-18 11:43:41 +01:00
Denis Ledoux 550910a8f6 [MERGE] forward port of branch 7.0 up to a87d60f 2015-02-16 18:26:45 +01:00
Denis Ledoux 3fed8ca58d [FIX] base: Address must stay readonly when field use_parent_address is checked
When you change the country of your company, each field of a company address keeps
its attrs. This is why the company address stays on readonly when use_parent_address
is checked.

Closes #4808
opw: 627033
2015-02-13 16:01:07 +01:00
Goffin Simon 5b283419d3 [FIX] base: Address must stay readonly when field use_parent_address is checked
When you change the country of your company, each field of a company address keeps
its attrs. This is why the company address stays on readonly when use_parent_address
is checked.

Closes #4808
opw: 627033
2015-02-13 11:35:00 +01:00
Denis Ledoux c9154e08aa [FIX] api: environment recomputation
In a workflow context (for instance, in the invoice workflow),
context is not passed.

Therefore, relying on the 'recompute' key being the context
in order to not recompute the fields does not work with Workflows.

It leads to huge performance issues,
as fields are recomputed recursively (instead of sequentially)
when several records are implied.
For instance, when reconciling several invoices with one payment
(100 invoices with 1 payment for instance),
records of each invoice are recomputed uselessly in each workflow call
(for each "confirm_paid" method done for each invoice).

With a significant number of invoices (100, for instance),
it even leads to a "Maximum recursion depth reached" errror.

closes #4905
2015-02-12 14:57:31 +01:00
Raphael Collet 13b36ac677 [IMP] fields: in selection fields, 'selection_add' only adds options not in selection yet 2015-02-11 13:31:17 +01:00
Raphael Collet 75ca4f8b71 [FIX] models: in onchange(), do not assign field 'id' on record 2015-02-11 12:45:18 +01:00
Raphael Collet 3a44d84b0f [FIX] models: inherited fields must be copied iff their original field is copied
This fixes a bug introduced by commit f650522bbf
(related fields should not be copied by default).  Inherited fields are a
particular case, and given the implementation of copy(), they must be copied if
their original field is copied.

The test on copy() in test_orm has been modified to show the bug.
2015-02-11 12:23:11 +01:00
Raphael Collet ac0eec6c99 [IMP] models: in recompute(), only save stored fields to database 2015-02-11 10:49:17 +01:00
Raphael Collet 2eb3ad2b46 [FIX] res_bank: fix onchange_partner_id(), where partner_id may be a NewId 2015-02-11 09:29:51 +01:00
Raphael Collet 6cf7bc8838 [FIX] models: invoke old-api onchange methods with context
This helps fixing old-api onchange methods with a record id as a parameter.
Browsing this record id may be problematic, since it reads the record in an
environment with an empty context.  This is really problematic when the record
is a new record, because such a record only exists in a given environment.
2015-02-11 09:29:51 +01:00
Raphael Collet 2067a206ec [FIX] models: process onchange methods on new records in the order of the view
The onchange() on new records processes fields in non-predictable order.  This
is problematic when onchange methods are designed to be applied after each
other.  The expected order is presumed to be the one of the fields in the view.

In order to implement this behavior, the JS client invokes method onchange()
with the list of fields (in view order) instead of False.  The server then uses
that order for evaluating the onchange methods.

This fixes #4897.
2015-02-10 13:12:40 +01:00
Raphael Collet a11100adb8 [FIX] fields: new-api many2many fields always determine their table and columns
The mechanism to determine the table and column names of new-api many2many
fields only worked for many2many fields created from old-api many2many columns!

This fixes #4851.
2015-02-10 09:21:12 +01:00
Kiril Vangelovski ea60fed97a [FIX] tools.translate: use `request` to find `cr` and `lang` when other methods fail
Do it only after other direct methods fail,
to avoid ignoring a closer environement coming
from a calling frame.

+ Sign CLA

Closes #5148
2015-02-09 20:21:10 +01:00
Raphael Collet 4fd8e40ff7 [FIX] fields: add a flag "compute_sudo" to recompute fields as user admin
This reverts commit 8cd2cc8910.

It turned out that forcing recomputing fields as user admin breaks some
existing behavior.  Instead, we make the recomputation as user admin explicit
by adding compute_sudo=True in the field's definition.
2015-02-09 09:57:34 +01:00
Stefan Rijnhart 0fc5860fca [IMP] api decorator allow both res_id as well as id
As in python id is a builtin function name.

Closes: #5027
2015-02-09 01:10:36 +01:00
Jeremy Kersten 5a26c2d3ec [FIX] crm,hr,base: disable the quick create for country field
The creation of a country is not something to create at flight !
The impact could be bigger that what people was expected (no accounting configured, ...).

The bad manipulation is more often the responsible, eg 'Belgium ' was creating a new country with a trailing whitespace, while the user didn't see the difference and use both country withtout making the diff.
2015-02-05 14:14:59 +01:00
Christophe Simonis 7ab70cab74 [IMP] models.py: do not log handled "bad query" 2015-02-04 14:45:50 +01:00
Csaba Tóth ac845819ee [FIX] models: allow empty selection list
If a selection field is created with an empty list of choices (e.g. added by
submodules), initialise the field as a varchar column (most common).
Check if the list exists to avoid crashing while checking the type of the first
key.
Fixes #3810
2015-02-02 10:54:04 +01:00
Denis Ledoux 2883e3f67d [MERGE] forward port of branch saas-3 up to ba5c972 2015-01-30 16:55:36 +01:00
Denis Ledoux ba5c972c3e [MERGE] forward port of branch 7.0 up to 05c907b 2015-01-30 16:52:41 +01:00
Denis Ledoux 57cf6f814b [FIX] base: attachment security for SUPERUSER
If the superuser is not in the group employee,
we should nevertheless give him the access rights to attachments
2015-01-30 15:31:36 +01:00
Denis Ledoux 05c907b60b [FIX] res: currency, rates name_search
In currencies, advanced search with "equals" or "not equals" on rates
was not possible for something else than a date, in server format (crash).

This is because the name field of the model res.currency.rate is a date

This is now possible to search rates with just a float and the equal operators,
it returns currencies which are having at least one rate set to this float value

This is also possible to search rates with the equal operators with a date in
user (context) date format.
2015-01-30 15:04:20 +01:00
Jeremy Kersten 4a698da8b3 [IMP] qweb: Allow to propagate value to variables outside the loop.
If the variable was existing outside the context of the ``foreach``,
the value is copied at the end of the foreach into the global context.

Fix #4461 - Q74531 - Q71486 - Q71675
2015-01-30 14:26:48 +01:00
Xavier Morel 88cc816670 [IMP] http: don't warn when using HTTPException results
When returning an HTTPException e.g. by calling ``request.not_found()``
which returns a ``werkzeug.exceptions.NotFound()``, the http system
would log a warning as HTTPException is neither a subclass of Odoo's
Response nor a subclass of werkzeug's BaseResponse.

Move the string response case about (for flow clarity), and convert
HTTPException instances to Werkzeug responses then fall into the normal
BaseResponse -> Response case to ultimately get an Odoo response object
out of the HTTPException instance.
2015-01-29 16:15:36 +01:00
Raphael Collet f650522bbf [FIX] fields: related fields should not be copied by default 2015-01-29 14:43:50 +01:00
Olivier Laurent c49d20c61a [FIX] base: _auto_init change column type fix
When changing the type of a column (if size differs for example),
'selection' field should be considered like a 'char' field (since they
are internaly the same column type)

This will fix some migration issues where 'char' fields were correctly
changed but not 'selection,' field.

Use case:
* create a 6.0 db with 'stock' module installed
* 'state' field in 'stock.move' model is of type 'character varying(16)'
* migrate it to 8.0
* 'state' field is still 'character varying(16)' but should normally be
  'character varying'
2015-01-29 14:16:21 +01:00
Olivier Dony 801a8b8fa9 [MERGE] Forward-port latest saas-3 bugfixes, up to c9b690f6b6 2015-01-29 13:54:13 +01:00
Olivier Dony c9b690f6b6 [MERGE] Forward-port latest 7.0 bugfixes, up to 4c2706d685 2015-01-29 13:50:51 +01:00
Antony Lesuisse 06c681ba11 [FIX] base: add env to ir_action and ir_ui_view qweb context
To impel new api usage in server actions and qweb templates.
2015-01-28 23:48:23 +01:00
Samus CTO 7126ae8143 [FIX] mail: prevent sending mail during registry loading 2015-01-28 16:17:43 +01:00
Manuel Vázquez Acosta a4597fe34f [FIX] ir_mail_server: use local envelope sender rather than spoofing it
Acting as a mailing-list-like distribution system, the system used
to set the enveloper sender (aka bounce address) to the From header
of the message, effectively pretending to be the original sender.

In some cases the domain of the From header explicitly forbids
sending emails from external systems (e.g. with a hardfail SPF
record), so this could cause the email to be rejected by some
spam filters, depending on their policies.

The system will now use a local bounce address in the form:
  mail-catchall-alias@mail-catchall-domain
or, if no catchall is configured:
  postmaster-odoo@mail-catchall-domain
(as soon there is a mail.catchall.domain configured)
It will only fallback to using the From header when no
catchall domain is configured.

Fixes issue #3347.
Closes #3393.
2015-01-28 15:51:23 +01:00
Olivier Dony 7a0451d649 [FIX] safe_eval: no shadowing of PostgreSQL's exceptions
Letting PostgreSQL low-level exceptions bubble up
ensures that the mechanism for automatically
retrying transactions will work.
In case of transient errors such as deadlocks or
serialization errors, the transaction will be
transparently retried. Previously they were
transformed into ValueError and caused a permanent
failure immediately.

The fallback to ValueError is meant for invalid
expressions or expressions that use variables not
provided in the evaluation context. Other
exception types should be preserved (this is
further improved in Odoo 8)
2015-01-28 14:34:54 +01:00
Xavier Morel 426bcf427c [FIX] incorrect serialisation of log_handler
Saving log_handler to the config file is not currently special-cased,
the value is thus dumped as the repr() of the list, but not deserialized
with literal_eval. This means -s breaks log_handler and the
configuration file example is incorrect (it looks like a list).

Repeated -s further break the log_handler by interpreting the original
value as a string, putting it into a list, then reserialising that with
repr(), injecting a bunch of escaping backslash. The config file is soon
filled with backslashes and doubles in size with each new -s.

Furthermore for some reason the whole thing breaks --log-handler (and
aliases) entirely, once the wrong log_handler has been saved none of
them works anymore.

Fixes #4552
Closes #4157
2015-01-27 13:58:12 +01:00
Xavier Morel e9f0d79f85 [IMP] config: deduplicate loggers in log_handler
Saving multiple levels for the same logger should work with few issues,
but over time pathological (basket) cases (e.g. using ``-s`` all the
time) may build pointlessly huge lists in their config file.

Only keep the last level for each logger when saving to a config file.
2015-01-27 12:35:53 +01:00
Xavier Morel 8641826ca4 [IMP] config: make log_handler and --log-handler additive
For log_handler (list of logger configuration specs), having the
configuration file and the CLI configuration be exclusive (one
overwriting the other) is detrimental: it precludes keeping the
configuration file as a convenient baseline and only altering the subset
of loggers of interest at any given time. Combine specs from both
sources instead of overwriting one with the other.

* remove log_handler and its special case from the first options loop
* remove seeding of option with DEFAULT_LOG_HANDLER
* my_default is the baseline "configuration file" value, it's None if
  not provided which is not convenient. Use DEFAULT_LOG_HANDLER for it
  as baseline configuration file. DEFAULT_LOG_HANDLER isn't a list
  anymore, it's a CSV of logger specs (same as file-serialized)
* could actually use a DEFAULT_LOG_HANDLER of ``:`` (the default logger
  is root, the default level is info), but that might be a tad too
  cryptic
* things are weird between my_default and the file-sourced value,
  _parse_config is first run with my_defaults then with the file, but if
  there's no file it's re-run with already-parsed my_defaults. So when
  the file and the command-line values are of different type,
  _parse_config must be ready to handle both
2015-01-27 12:35:52 +01:00
Xavier Morel 9f4dea0891 [FIX] config: correctly serialize log_handler to CSV 2015-01-27 12:35:52 +01:00
Xavier Morel 23ad48a91b [FIX] config: a list is always equal to itself
add_option(action=append*) always modifies the ``default`` list
in-place. When using DEFAULT_LOG_HANDLER directly, that means
log_handler is always equal to DEFAULT_LOG_HANDLER since they're the
same list object. Thus the --log-handler command-line would never
overwrite the log_handler value from the configuration file, which is
unexpected

Fix that by copying DEFAULT_LOG_HANDLER before passing it as the
option's default value.
2015-01-27 12:35:51 +01:00
Olivier Dony 8e03852fd4 [I18N] Update translations from Launchpad 8.0 branches 2015-01-26 16:36:51 +01:00
Olivier Dony 740bf28907 [FIX] ir.model.data: verify record exists in _update_dummy
When a stale XML ID exists in the database, `_update_dummy()`
must consider it as missing entirely, and the next call
to `_update()` will take care of cleaning up the old XML ID.

Failing to do so for `noupdate` records means the `_update`
will never happen, and as soon as another record is created
or updated with a relationship to that stale XML ID, it will
plainly crash the installation/update.
2015-01-24 00:15:26 +01:00
Xavier Morel fca83b45f8 [IMP] on non-rpc debug, only break on non-HTTPException
Completes/improves fd6dde7ca

Because Werkzeug uses/provides flow-control exceptions via
HTTPException (which can be used as straight responses) they are used in
a few places of the web client, when triggering some redirections for
instance.

Breaking into the debugger for such mundane situations is surprising and
inconvenient for developers trying to debug actual issues in the system,
even though HTTPExceptions are by and large not error per-se, and
shouldn't warrant triggering post-mortem debugging.

So in the non-RPC dispatcher, don't post-mortem on HTTPException either.
2015-01-23 15:34:53 +01:00
Denis Ledoux dab5ff7e76 [MERGE] forward port of branch saas-3 up to b3f3daf 2015-01-23 13:28:17 +01:00
Denis Ledoux b3f3dafcb9 [MERGE] forward port of branch 7.0 up to c62a75a 2015-01-23 13:27:13 +01:00
Christophe Simonis 6d37ff1091 [FIX] base: remove duplicated XOF res.currency (and rate) 2015-01-23 13:02:30 +01:00
Christophe Simonis ce1096c447 [FIX] base: correct currency rate wrongly changed during 9902424 2015-01-23 12:57:04 +01:00
Denis Ledoux c62a75a5f3 [FIX] report: line splitting compatible with reportlab > 3.0
While keeping the compatibility for reportlab 2.5.

Splitting the text node on line breaks '\n' leaded to orphans ending tags,
like '</font>', which is regarded by reportlab 3.0 as a paragraph,
and reportlab therefore surrounded these tags by <para> tags,
which leaded to not syntax correct html like
<para></font></para>

To test this patch:
 - While having reportlab > 3.0
 - Create a rml report containing (at least) '<font>\n</font>'
 - Then print the report. It must not crash (obviously)
2015-01-23 12:54:30 +01:00
Aaron Bohy 3cae676619 [FIX] Use local copies of png instead of fetching them from websites
Debian does not allow fetching data from external website at runtime.
This fixes the privacy-breach-generic lintian warnings for Debian packaging.
The removed youtube url was a dead link...
2015-01-23 11:23:04 +01:00
Christophe Simonis 99024240f5 [IMP] base: avoid useless call to time.strftime()
This will also ease next forward-port 8.0 -> master
2015-01-22 18:27:08 +01:00
Christophe Simonis be33101903 [FIX] base: correct currency rates.
- Do not force creation of rates.
- Using rates of 2010 and storing them as beeing from 2015 is not a good idea.
2015-01-22 16:23:42 +01:00
Raphael Collet 8cd2cc8910 [FIX] models: recompute fields with user admin to prevent access rights issues 2015-01-22 15:32:18 +01:00
Denis Ledoux e9d1d7aac0 [MERGE] forward port of branch saas-3 up to c5775e5 2015-01-22 14:45:16 +01:00
Denis Ledoux c5775e56d3 [MERGE] forward port of branch 7.0 up to 25f5329 2015-01-22 14:43:06 +01:00
Denis Ledoux 25f5329deb [FIX] report: break lines and splitted words with reportlab > 3.0
From reportlab 3.0, empty plaintext paragraphs do not lead to a break line anymore.
Before release 3.0, paragraphs having tags but no plaintext leaded to a break line.
This patch aims to recover the behavior of reportlab releases < 3.0, as
<para><font color="white"> </font></para> is used in allmost all rml reports
The current patch is not considered as clean, but we did not find any better solution.
If someone find a parameter to pass to reportlab in order to bring back the old behavior of reportlab
he is welcome to provide the better patch.

Besides, in reportlab 3.0, splitlongwords has been introduced as parameter,
to allow to break long words. The default value is True.
This parameter seems to break the columns headers
(it splits the text within the column header)
We therefore take the choice to not activate it, as it was not present anyway in reportlab < 3.0

To test the good behavior of this patch:
While having reportlab < 3.0 (2.5 for instance), print a draft invoice
Then, upgrade to reportlab > 3.0 (3.1.8 for instance), print the same draft invoice.
The generated pdf must be (allmost) identical, in particular concerning spaces.
Specifically, the space between the partner address and his phone.
2015-01-22 14:23:38 +01:00
Martin Trigaux 9f8731ca27 [FIX] base: backport of 152c5c2 to 7.0
[IMP] base: safer locking at user login

When a users connects, a lock is taken on the res_user table to modify the last login date. If another running transaction uses a foreign key to res.users (e.g. write_uid column), postgres may detect the update as a concurrent update and rollback the transaction.
In pg 9.3, the lock_strength parameter 'NO KEY' allows a weaker lock which is less likely to break another transaction.
Fixes #552
2015-01-22 13:34:19 +01: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
Martin Trigaux 2c99ddc612 [FIX] tools: exec_command_pipe parameters
args is a tuple, do not popen it as it's concatanated with another tuple
in _exec_pipe. This made the "print workflow" method crash.
2015-01-21 18:33:04 +01:00
Martin Trigaux cbd9b46129 [FIX] tools: return data from exec_command_pipe call
Rendering of workflow uses it, returns the pdf data
2015-01-21 18:33:04 +01:00
Olivier Dony 495ec92251 [I18N] Update translations from Launchpad 8.0 branches 2015-01-21 15:36:54 +01:00
Olivier Dony 39f00b3637 [I18N] Update translation templates with latest terms
Total new terms: 270
Total deleted terms: 82
Total identical terms: 19653
Old total number of terms: 19735
New total number of terms: 19923
2015-01-21 15:31:22 +01:00
Olivier Dony 8ea6ebede1 [IMP] fields: reduce verbosity of debug log for registry loading
This log line is only useful when debugging registry
loading, a limited use case now that Odoo 8 is stable.
It makes the debug log more difficult to read and causes
a small performance penalty when debug[_rpc] is on.
(+0.2s i.e. 10% extra time for loading a registry with 47
modules on a core i5-4200U machine)
2015-01-21 12:53:26 +01:00
Raphael Collet 431f8de815 [IMP] models: prepare the setup of fields at one place only 2015-01-21 11:26:23 +01:00
Raphael Collet 54c655cb71 [FIX] models: do not introduce a one2many manual field if its inverse is not on its comodel 2015-01-21 11:26:23 +01:00
Raphael Collet cf26f7ed80 [IMP] models, registry: let the registry retrieve manual fields from database 2015-01-21 11:26:23 +01:00
Raphael Collet 5d7bba4eb7 [FIX] loading: move code that should not be executed on simply installed modules 2015-01-21 11:26:23 +01:00
Raphael Collet 6c29af3fa5 [FIX] models: init function fields once columns are known and not before 2015-01-21 11:26:23 +01:00
Raphael Collet 5fee95ca63 [FIX] models, fields: reorganize model setup to retrieve all inherited fields
The model setup sometimes misses entries in _inherit_fields and _all_columns.
This is because those dictionaries are computed from parent models which are
not guaranteed to be completely set up: sometimes a parent field is only
partially set up, and columns are missing (they are generated from fields after
their setup).

To avoid this bug, the setup has been split in three phases:
(1) determine all inherited and custom fields on models;
(2) setup fields, except for recomputation triggers, and generate columns;
(3) add recomputation triggers and complete the setup of the model.

Making these three phases explicit brings good invariants:
- when setting up a field, all models know all their fields;
- when adding recomputation triggers, you know that fields have been set up.
2015-01-21 11:26:23 +01:00
Raphael Collet 2f06adde9c [IMP] models: speedup registry loading (35% less time)
The field setup on models is improved: only fields are determined when building
the model's class; the final _columns is computed from the fields once they are
set up.
2015-01-21 11:26:23 +01:00
Simon Lejeune e40a6fd325 [FIX] tools: pass env in `exec_pg_command` 2015-01-20 17:36:20 +01:00
Samus CTO acd7d84da4 [IMP] make name_search() use '=' if col _rec_name is an integer
When looking for an issue number, it's more useful to match the word in
the whole string instead of just a part of it.
2015-01-20 09:52:55 +01:00
Samus CTO 332154444d [FIX] Can not search using a string operator on column id 2015-01-20 09:52:55 +01:00
Christophe Simonis edbb14143e [FIX] test_new_api: it works by accident but company_id <> partner_id 2015-01-19 20:26:31 +01:00
Laurent Mignon (aka lmi) aef2150179 [IMP] let scaffold render files ending by .rst and .html
closes #4773
2015-01-19 14:25:36 +01:00
Jeremy Kersten a0e775e3fa [IMP] ir_http: authentification method can redirect to an other page 2015-01-19 13:44:25 +01:00
Christophe Simonis 7b7554c91f [MERGE] forward port of branch saas-3 up to cdb48d3 2015-01-19 12:16:33 +01:00
Christophe Simonis cdb48d39ba [MERGE] forward port of branch 7.0 up to 6c55a4b 2015-01-19 12:09:48 +01:00
Stéphane Bidoul 34fe1d211d [IMP] add support for directory templates in scaffold
closes #4767
2015-01-19 10:35:41 +01:00
Antony Lesuisse c1c8ac7d7f [FIX] dbmanager: backup allow pg_dump custom dump to be larger than diskspace
- delete a forgotten print
- allow pg_dump custom dumps to be larger than the available disk size, the
  previous commit allowed dumps to be larger than memory, this one remove this
  limitation. zip dumps are still limited to by the disk size.
2015-01-19 02:42:34 +01:00
Antony Lesuisse ec9a543014 [FIX] dbmanager: backup support both zip and pg_dump custom format
- let the user choose between the pg_dump custom format or the zip format including the filestore
- use file objects to allow dumps larger than memory
- postgres subprocess invocation is now clean and thread-safe, we dont touch the local process environ anymore
- add a manifest to the zip dump format with version information about odoo, postgres (pg_dump doesnt output it) and modules
2015-01-19 02:05:12 +01:00
Denis Ledoux 5959c41631 [IMP] res_lang: constraint for grouping field
As entering a wrong value in the grouping field of res.lang,
for instance '[,]', leads to an unavailability of the web interface,
We add a constraint to prevent entering wrong values.
2015-01-16 17:47:33 +01:00
Martin Trigaux 2f5a7b63d3 [FIX] base: keep first multiline translation in po file
The first term of a po file is a comment for translator e.g.:
msgid ""
msgstr ""
"Project-Id-Version: openobject-addons\n"
...

This comment is ignored if there is no source and it is the first term of the po
file. The first flage was disabled too late and if the following terms also
started with an empty source (for too long terms), they were skipped as well.

Disable the flag as soon as the condition is evaluated to make sure no
additional terms are ignored. opw 619786
2015-01-16 13:05:46 +01:00
Raphael Collet 309e3def30 [FIX] api: fix api decorators to not add '_api' on original methods
This fixes an issue where the same function is used in several model classes:
once the function is wrapped for the first class, it is erroneously considered
as a wrapper for the second class, and is therefore not wrapped in other
classes.
2015-01-15 16:43:46 +01:00
Xavier Morel af90f5f638 [IMP] test experience and documentation
closes #3152
2015-01-15 15:23:08 +01:00
Denis Ledoux 87dd06c941 [MERGE] forward port of branch saas-3 up to 8c150c6 2015-01-15 14:43:32 +01:00
Xavier Morel 65cd4a2a33 [FIX] remove deprecated checks/fast_suite test attributes from standard modules 2015-01-15 14:31:40 +01:00