Commit Graph
403 Commits
Author SHA1 Message Date
Christophe Simonis a337b9ec92 [MERGE] forward port branch 12.0 up to f854e01a98 2019-01-18 14:26:33 +01:00
Nicolas Seinlet f8e37d6a80 [IMP] improve overridden sql constraints support
If module A define an sql constraints and module B, which depends on 
module A, override the sql constraint, we must ensure having only the 
last definition in constraints list. Having the two versions in the list
makes the ORM continuously trying to drop the second version by the 
first one, then recreate the second version, when performing operations 
like an upgrade a module B.

An illustration of this is the login_key on res.users, which is unique
per login in base, but unique per (login, website) in website.

closes odoo/odoo#30334
2019-01-18 09:20:02 +00:00
Christophe Simonis 8aa8548d8a [MERGE] forward port branch 12.0 up to 3e4138deaa
closes odoo/odoo#30045
2019-01-09 15:56:53 +00:00
Sébastien Theys 1fa10cbc5d [FIX] base,website_google_map: fix partner address not showing
Following commit 983c7e8152.

`_compute_display_name` is overridden in partner to force `show_adress` and some
other context variables to None. When those values are in the context, calling
`display_name` can give a different result than calling `name_get()[0][1]`.

This commit reverts the changes of the mentioned commit where the behavior is
actually different, that is, when `show_address` is in the context.

It also adds a comment on the `_compute_display_name` method to avoid further
mistakes.

closes odoo/odoo#29510
2018-12-13 11:17:23 +00:00
Raphael Collet befb3a1cd6 [FIX] models: make valid aggregation functions explicit
In `read_group`, allow an explicit set of aggregation functions.

closes odoo/odoo#29348
2018-12-10 08:52:50 +00:00
Christophe Simonis d4c65a7ede [MERGE] forward port branch 11.0 up to 2156af480f 2018-12-04 17:11:57 +01:00
Christophe Simonis 2156af480f [MERGE] forward port branch saas-15 up to 9bfc12cb3f 2018-12-04 16:17:49 +01:00
Raphael Collet a8f4b522a3 [FIX] models: onchange sends all fields upon change in x2many
On a record with a large x2many, the web client does not load all the data of
the lines (because of paging).  If a line is modified by an onchange, at some
point the client will determine whether lines are valid (all required fields
are provided).  It is possible that the client cannot evaluate the validity of
the modified line because of missing fields.  In order to avoid this situaion,
the server sends all fields on modified lines.
2018-11-30 13:34:44 +00:00
Raphael Collet 95f4287b6a [FIX] models: make onchange return a smaller diff
Large diffs (specifically in x2many fields) cause performance issues.  They
overload the web client, which considers all returned fields as dirty.
2018-11-30 13:34:20 +00:00
Christophe Simonis e3323a9b52 [MERGE] forward port branch saas-14 up to ba88252bc0 2018-11-30 12:44:11 +01:00
Christophe Simonis ba88252bc0 [MERGE] forward port branch 10.0 up to 80a11ca27d 2018-11-30 11:58:25 +01:00
Richard Mathot 1d553eea7b [FIX] models.py: log the full traceback when record import fails
Without the full stack trace, it is very hard for the developers to know
why and where the record creation has failed.

closes odoo/odoo#29143
2018-11-29 15:12:59 +00:00
Christophe Simonis caf1837216 [MERGE] forward port branch saas-11.3 up to d4c65a7ede 2018-12-05 12:27:57 +01:00
Raphael Collet 6a71a68046 [FIX] models: onchange sends all fields upon change in x2many
On a record with a large x2many, the web client does not load all the data of
the lines (because of paging).  If a line is modified by an onchange, at some
point the client will determine whether lines are valid (all required fields
are provided).  It is possible that the client cannot evaluate the validity of
the modified line because of missing fields.  In order to avoid this situaion,
the server sends all fields on modified lines.

closes odoo/odoo#29177
2018-11-30 09:57:11 +00:00
Christophe Simonis e1f9499d26 [MERGE] forward port branch 12.0 up to 053bb45706 2018-12-05 18:46:15 +01:00
Christophe Simonis ce4cc24621 [MERGE] forward port branch 12.0 up to 82a1e1dcc3 2018-11-29 20:06:16 +01:00
Adrian Torres 758382b3a7 [REM] pycompat: remove python 2 shims and helpers
Odoo no longer supports python 2, thus some of these helpers can and
have been replaced by python 3 built-ins, therefore there is no need for
them to stay defined.

The removed helpers are:
    * izip, imap and ifilter
    * unichr, text_type
    * implements_to_string, implements_iterator
    * string_types, integer_types
    * to_native

The python 2 shims have also been removed, and only the python 3 helpers
have been kept, because they can still be usable (i.e. accepting
both bytes and str for functions that can only accept one of the two)

[REM] pyjsparser: remove PY3 shims

They're no longer necessary as Odoo doesn't officially support python 2
anymore.

closes odoo/odoo#28519
2018-11-29 09:28:17 +00:00
Adrian Torres 52f5528cfb [REF] *: replace deprecated pycompat helpers for builtins
This commit replaces calls to pycompat helpers that were intended for
python 2 <-> python 3 interoperability for python 3 builtins, as python
2 is no longer officially supported by Odoo.

This includes:
    * calls to imap/izip/ifilter replaced by map/zip/filter
    * uses of text_type replaced by str
    * uses of unichr replaced by chr
    * calls to implements_to_string, implements_iterator removed
    * string_types and integer_types replaced by str, int respectively
    * calls to to_native replaced by calls to to_text

This is done in preparation to the removal of these deprecated helpers
in the following commit.
2018-11-29 09:28:17 +00:00
Luis González a914d67661 [DOC] models.py: Fix old reference in _get_external_ids method's doc
It was referencing _get_xml_ids, whereas the method name is
_get_external_ids

closes odoo/odoo#28647
2018-11-14 04:19:38 +00:00
Christophe Simonis 3e4b9d4d66 [MERGE] forward port branch saas-11.4 up to 639bd89635 2018-11-09 14:51:55 +01:00
Christophe Simonis 639bd89635 [MERGE] forward port branch saas-11.3 up to 94a9fc9902 2018-11-08 17:08:03 +01:00
Raphael Collet eaa93d1bd4 [FIX] models: update write_date when writing on inherited fields
When changing the field `image` on `res.users`, the `write_date` of the user is
not updated because the field is inherited from `res.partner`.

Related to Issue : 1839603
2018-11-06 11:11:03 +01:00
Christophe Simonis afe0133302 [MERGE] forward port branch saas-11.3 up to 3e54704e66 2019-03-06 10:59:32 +01:00
Martin Trigaux 06d73eab62 [FIX] models: do not erase master version
For a translated field with a callable method (e.g. xml_translate), when
modifying the value of this field in another language than en_US, the master
version was lost.

Before this patch:

>>> record.arch = "<h1>Title</h1>"
>>> record.with_context(lang='fr_FR').arch = "<h1>Titre</h1>"
>>> record.with_context(lang='fr_FR').arch
"<h1>Titre</h1>"
>>> record.arch
"<h1>Titre</h1>"  # lost English version

After this patch:

>>> record.arch = "<h1>Title</h1>"
>>> record.with_context(lang='fr_FR').arch = "<h1>Titre</h1>"
>>> record.with_context(lang='fr_FR').arch
"<h1>Title</h1>"  # write had no effect
>>> record.arch
"<h1>Title</h1>"

When modifying a translated HTML field in English, a matching to detect the
difference and avoid losing the translations is done.
This is not supported for update in another language.
The main reason is the difficulty to detect changes in the architecture.

To update translations, the supported way is to go to the list of translations
and update them there.

Before this patch, the given value in another language was given to the SQL
query and made an update in database:
if single_lang or not (has_translation and field.translate is True)
-> True or not (True and False) -> True

If a field is callable, it should also be ignored, the same way than
translate=True fields

opw-1887162

closes odoo/odoo#31330
2019-02-21 15:13:51 +00:00
Christophe Simonis a299517f83 [MERGE] forward port branch saas-11.3 up to 6136f0c02e 2018-10-29 11:56:32 +01:00
Christophe Simonis cc8e8237bf [MERGE] forward port branch 11.0 up to 84500c27b1 2018-10-25 13:59:45 +02:00
mhamra 55899f849a [FIX] models: use expected parameter type
set_failed function expects an iterable object
Introduced at 32a58c0db3

Fixes odoo/odoo#27744

closes odoo/odoo#27911
2018-10-23 14:21:55 +00:00
Christophe Simonis 5e055a2afd [MERGE] forward port branch saas-11.4 up to f6ca72b3ce 2018-11-02 10:52:55 +01:00
Raphael Collet 828b76d578 [FIX] models: make onchange return a smaller diff
Large diffs (specifically in x2many fields) cause performance issues.  They
overload the web client, which considers all returned fields as dirty.

closes odoo/odoo#27941
2018-10-23 14:25:38 +00:00
Martin Trigaux 933165ec3a [FIX] models: restore warning on wrong record
Was lost during d5b687a48f

Set the module name in the context to be able to detect errors in xml and csv import

closes odoo/odoo#27680
2018-10-21 08:41:22 +00:00
Raphael Collet ad065093eb [FIX] models: ormcache invalidation on import
Do not propagate cache invalidations to other workers when changes must be
discarded, because of an import error or a dry run, which are both handled as
successful transactions.
2018-11-22 11:03:51 +00:00
Manuel Vázquez Acosta c77f7fc5cd [FIX] models: Allow rich comparison with third party objects.
Instead of returning False directly when comparing a non-model, return
NotImplemented that will trigger the __eq__ test from the other side.

This allows third party objects (for instance a serialization/deserialization
scheme) that cannot be a Model to be considered equal is some scenarios.

closes odoo/odoo#19977
2018-10-11 16:59:49 +00:00
Nicolas Lempereur f3bd4e425f [FIX] models.py: modified field with uppercase
In 7f29b31cf the modifed has been improved but there was a typo if a
column contained an uppercase letter (which happen easily with random
field name in Odoo Studio).

opw-1890248
closes #27546
2018-10-09 13:14:47 +00:00
Martin Trigaux 718b0f8b63 [FIX] models: display first external id onyl
In case the result matches two records (e.g. a model has one external id per
module inheriting it), the last was used.

Use the first only.

Fixes #27363
2018-10-02 11:20:01 +02:00
Christophe Simonis 43b63a0465 [MERGE] forward port branch saas-11.4 up to 57e387b645 2018-10-01 16:01:54 +02:00
Christophe Simonis 998723b909 [MERGE] forward port branch saas-11.3 up to e980af9df0 2018-10-01 11:27:51 +02:00
Adrian Torres 52a8ed3c0c [IMP] fields: make related fields readonly by default
With this commit, any *explicitly* related fields will be `readonly=True`
by default.

*Implicitly* related fields (i.e. _inherits fields) however will keep the
source field's `readonly` attribute.

The rationales behind this patch are:
    * Enforce good practices, as the most common use-case for
      related fields is the same as for compute fields: to read data.
    * Avoid errors where some user saves a form view which contains
      a related field that the user doesn't have write access to.
2018-09-27 12:10:23 +02:00
Raphael Collet d1d496c0b6 [FIX] models: avoid multiple identical warnings in onchange 2018-09-26 13:28:56 +02:00
Yannick Tivisse 57ffbe89ef [IMP] models.py: Concatenate warning messages if they are different
Purpose
=======

When several warnings are raised, in an onchange for example, the warning
messages and titles are concatenated on the dialog, even if they are
exactly the same.

Specification
=============

Don't concatenate warning messages if they are exactly the same.
2018-09-25 18:39:32 +02:00
Thibault Delavallée 82f361a318 [FIX] models: add filter method on access rules
Currently check_access_rule method checks for record rules and raises an error
if there are either missing ids (deleted records) or forbidden ids (records
hidden due to a record rule).

Purpose of this commit is to have a method allowing to filter a given recordset
and receive only valid records. Its implementation is basically a refactoring
of check_access_rule.

This commit is linked to task ID 1856417 and PR #26565.
2018-09-25 10:51:34 +02:00
Yannick Tivisse 9e3a2eff61 [IMP] models.py: Log a warning if no '_description' is set on model 2018-09-21 16:13:59 +02:00
Martin Trigaux 60e9e1f738 [FIX] models: do not copy translations from specified inherited records
A copy call cn be made with a specified value to an inherits value, e.g.:
   self.env['product.product'].browse(42).copy({'product_tmpl_id': 1})

In such scenario, it is assumed the translations are already correct on the
specified related record and should not be used in the copy translation.
i.e. the translations of the product.template 1 must not be duplicated during
the copy call above

Same logic for One2many fields which should not recursively copy the
translations for user provided values

Closes #27108
2018-09-20 16:55:44 +02:00
Ravi Gohil 5c11e0d6f9 [FIX] models: support group by with multiple date fields
When filling the results of a read_group using
_read_group_fill_temporal we were using the name of the field.
(https://github.com/odoo/odoo/commit/283c842289f1bc06bc30a877864e868127418e80)

But _read_group_format_result needs the name of the groupy which can
differ from the name of the field as groupby supports the following
syntax for dates `field:groupby`

This ultimately lead to a crash when trying to groupby multiple date
fields in a graph view.

Linked to Tasks : #1879604 and #1879168
2018-09-14 15:43:10 +02:00
Raphael Collet fa6774b899 [FIX] models: make log_access fields readonly, and remove useless definitions 2018-09-11 17:25:07 +02:00
Raphael Collet 9823fe6f07 [FIX] models: allow superuser to set log_access fields while loading registry
This enables a module to create data in the past.
2018-09-11 17:25:07 +02:00
Xavier Morel 5fade72656 [FIX] models: batch field set on creation when company_dependent
This may be completely broken/wrong, but damn if it doesn't speed
import up (2mn to 30s, the main cost center goes back to updating
computed fields during/after creation fields).
2018-09-11 16:43:55 +02:00
Xavier Morel 7f29b31cf3 [IMP] models: use raw sql for modified()
Avoiding search makes modified go from 18% of total runtime to 9% over
10k calls (though only 5k search() call).
2018-09-11 16:43:55 +02:00
Xavier Morel d7210f5257 [IMP] api, models: _write performances on import
Followup from the previous commit: before this, _write takes 32% of
total runtime, of which 13.7% is ultimately assignable to add_todo.

Turns out for the test case we mostly keep adding records to recorsets
where they're already present, so the 13.7% of runtime in add_todo are
mostly spent creating orderedsets (11.17) then converting those back
into recordsets (1.75%) with some time spent creating lists and
appending records (already present) in them.

Checking if the records are already present before merging them in
decreases add_todo's runtime cost to 0.5%, and ultimately _write to
20%.

As many of the ignorable calls were merging a singleton or an empty
recorset into the parent recordset, optimising for these cases was
added to BaseModel's <= and >=.
2018-09-11 16:43:55 +02:00
Christophe Simonis 68d36512ef [MERGE] forward port branch saas-11.4 up to d78f23df84 2018-09-07 20:20:45 +02:00
RomainLibert 283c842289 [FIX] models: support multiple group by in _read_group_fill_temporal
The method _read_group_fill_temporal did not support multiple levels of
groupby. Which meant that everytime you grouped by a date and by
something else you had a traceback.
2018-09-07 17:03:22 +02:00