Commit Graph

7612 Commits

Author SHA1 Message Date
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