Commit Graph
403 Commits
Author SHA1 Message Date
Christophe Simonis e145f2b0c8 [MERGE] forward port branch saas-12.2 up to 2694174b41 2019-04-10 15:10:24 +02:00
Christophe Simonis 6c8e30cae6 [MERGE] forward port branch saas-12.1 up to 6d4940675f 2019-04-09 12:16:06 +02:00
Christophe Simonis 6d4940675f [MERGE] forward port branch 12.0 up to ea1fc124ef 2019-04-09 11:11:48 +02:00
Xavier-Do b5c2004160 [IMP] core: avoid to check access rules on empty recordset
Checking access rules only makes sence if we have some records,
_filter_access_rules will always return a subset or current
recordset, and a subset or a empty recordset is an empty recordset.

closes odoo/odoo#32313

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-04-02 15:39:30 +00:00
Martin Trigaux 489494e733 [FIX] base: upsert translations during copy_translations
When doing a copy, create the new translations directly in SQL and handle
potential conflicts.

Conflicts can occure in case of reinstallation as showed in opw-1955062 and
opw-1950117.
In case of "leftovers" of translations (e.g. remaining after the uninstallation
of a module), creating the new translations (when reinstalling the module) may
produce a conflict with (type, name, res_id, lang) and raise an error.

This is NOT a problem of reading .po file during installation (which handles
correctly conflicts) but of business code creating new records and linked
translations (e.g. website copying website.menu records).

Removing old translations during uninstall is handled in a previous commit in
ir.model.fields _drop_column method.
This commit fixes the reinstallation on instances with leftover translations
and fixes the issue without needing a manual intervention (i.e. delete the old
translations manually).

Closes odoo/odoo#32056

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-04-04 14:41:26 +00:00
Christophe Simonis 0e7675847f [MERGE] forward port branch saas-12.1 up to 0f4abc5c22 2019-02-22 16:25:02 +01:00
Christophe Simonis 1d2b6f1bef [MERGE] forward port branch 12.0 up to 84143a34b3 2019-02-21 15:37:19 +01:00
Yannick Tivisse 62c9dedafd [IMP] base: Remove useless ACL rules
Now that portal users don't have access to the backend, it doesn't make
sense to give the read access on attachments, as this is the role of
the specific controllers to provide this access according to the business
logic.

For the record, these rules have been introduced at:
https://github.com/odoo/odoo/commit/61065b6d04248aa496765e1035c4c90cbdc38de7
https://github.com/odoo/odoo/commit/f3fa266d115ac9d4723164af10f8dee40821b290

closes odoo/odoo#32134

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-03-29 12:00:25 +00:00
Christophe Simonis db1c7765cb [MERGE] forward port branch saas-11.3 up to 2c495502aa 2019-02-20 17:37:22 +01:00
Christophe Simonis f1ff55bca1 [MERGE] forward port branch 11.0 up to de8cefcef4 2019-02-20 13:40:48 +01:00
Raphael Collet 716a272480 [FIX] models: check groups on inverse fields
Before this, groups on non-stored inverse fields were not checked upon write.
The impact on existing fields is pretty small, since the inverse methods of
those fields are subject to access rights on the records they use.

closes odoo/odoo#30357
2019-02-13 10:45:04 +00:00
Christophe Simonis b277705e52 [MERGE] forward port branch saas-15 up to c0f24d54cf 2019-02-14 18:42:19 +01:00
Christophe Simonis c0f24d54cf [MERGE] forward port branch saas-14 up to c1fe9f18d5 2019-02-14 18:14:08 +01:00
Christophe Simonis c1fe9f18d5 [MERGE] forward port branch 10.0 up to 69719f598a 2019-02-14 18:09:24 +01:00
Raphael Collet cd3790c4ea [FIX] models: check groups on inverse fields
Before this, groups on non-stored inverse fields were not checked upon write.
The impact on existing fields is pretty small, since the inverse methods of
those fields are subject to access rights on the records they use.

closes odoo/odoo#30356
2019-02-13 10:35:09 +00:00
Yannick Vaucher f610a28670 [IMP] models: more meaningful comment for the ensure_one implementation
See discussion comment
https://github.com/odoo/odoo/pull/30817#discussion_r255899919

This revision is related to
ce0575ef27
2019-02-13 11:01:30 +01:00
Christophe Simonis c023d0784f [MERGE] forward port branch saas-11.3 up to ecd8c023b7 2019-03-08 16:10:55 +01:00
Christophe Simonis ecd8c023b7 [MERGE] forward port branch 11.0 up to e5f93b83c6 2019-03-08 15:08:16 +01:00
Jairo Llopis 8da3750cee [FIX] core: remove extra exception log, redundant in P3
Reverts 2b1d3ff82d introduced in 10.0 via

It was relatively useful in Odoo 10.0 because in Python 2 the exception
was missing a root cause traceback. But Python 3 includes exception
chaining by default, so it comes for free.
See [PEP3134](https://legacy.python.org/dev/peps/pep-3134/)

On top of being redundant in P3, it can also break some testcases
by causing an extra ERROR log entry, even when the final exception is
expected and caught. So it's simpler to remove it.

closes odoo/odoo#31699

Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2019-03-08 10:46:23 +00:00
Christophe Simonis 3e54704e66 [MERGE] forward port branch 11.0 up to 27081bf6f5 2019-03-05 17:26:04 +01:00
Martin Trigaux 1748b46718 [REV] orm: revert d855e3911f
This commit introduced a regression in web_studio, discovered at opw-1947380

A fix in web_studio will be integrated too but the regression is the proof this
commit should not have been integrated in 11.0.
While the new behaviour introduced at d855e3911f makes more sense, it is still
a change of behaviour that should not target a stable version.

For the problem raised at opw-1887162 that d855e3911f was trying to fix, a
workaround should be used instead.
For instance, setting a widget='html_frame' allows to translate in the website
editor that handles this correctly.

In master, the new behaviour can be maintained and eventual regressions will be
investigated there.

closes odoo/odoo#31585

Signed-off-by: "Martin Trigaux (mat)" <mat@odoo.com>
2019-03-05 10:18:11 +00:00
Christophe Simonis 1c712986c4 [MERGE] forward port branch saas-15 up to 1f1fa35c07 2019-03-04 15:49:35 +01:00
Christophe Simonis 1f1fa35c07 [MERGE] forward port branch saas-14 up to 232da9a0ec 2019-03-04 13:40:44 +01:00
Christophe Simonis 4c46dd4f9d [MERGE] forward port branch 10.0 up to 2f139632d6 2019-02-27 10:42:03 +01:00
Martin Trigaux d855e3911f [FIX] orm: backport of 06d73eab62 to 11.0
[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#31451
2019-02-28 07:33:03 +00:00
Martin Trigaux 62a29dba2c [REV] models: do not erase master version
This commit has been backported in 11.0 [1] and then reverted [2],
because it introduced a regression in web_studio, discovered at opw-1947380

As no forward-port has been done between the backport and the revert,
the forward-port of the revert also contains the patch itself, resulting
in a noop.

Actually revert 06d73eab62 in branch `12.0`.

[1] d855e3911f
[2] 1748b46718

closes odoo/odoo#31637

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-03-06 14:45:21 +00:00
Jairo Llopis 2b1d3ff82d [FIX] core: log unexpected validation exceptions
Before this patch, any exception raised by a constraint method that
were not of type `ValidationError` were hard to debug, because the
origin line was never logged.

Explicitly logging the error (with traceback) when we catch it
ensures proper contextual info, even in the absence of exception
chaining.

closes odoo/odoo#28612
2019-02-20 09:47:56 +00:00
Xavier Morel 51819dcf17 [IMP] access errors through related fields
When an access error bubbles through a related field (aka the user
doesn't have access to the delegate or the delegate's field), append
the "intermediate step" so that it's easier to understand e.g. that
the access error to a partner really comes from accessing a user or
somesuch.
2019-02-06 11:29:29 +00:00
Xavier Morel 0f167634be [IMP] access error messages on fields with groups 2019-02-06 11:29:29 +00:00
Xavier Morel 6461a0f58c [FIX] core, base: rules detail on access error
In debug mode, if an access fails due to access rules, try to provide
a clearer error message & include a list of the rules which fail for
the record-set.

Note: for read() operations it'll be a bit misleading as failed
records will get a list of all the rules failing for the recordset,
only some of which might apply to that specific record.
2019-02-06 11:29:29 +00:00
Martin TrigauxandRaphael Collet ba58888ced [IMP] models: remove orphan translations
Same logic as for the mail.message or ir.attachment, when a record is deleted,
drop the ir.translations linked to it as well.

Fixes odoo/odoo#25105

Co-authored-by: Raphael Collet <rco@odoo.com>

closes odoo/odoo#30721
2019-01-31 10:22:16 +00:00
Christophe Simonis 952f784454 [MERGE] forward port branch 11.0 up to 4f2f299534 2019-01-15 17:48:36 +01:00
Christophe Simonis 4f2f299534 [MERGE] forward port branch saas-15 up to 3374ac805f 2019-01-15 15:08:01 +01:00
Christophe Simonis 3374ac805f [MERGE] forward port branch saas-14 up to 28785f21e4 2019-01-15 11:45:44 +01:00
Christophe Simonis 28785f21e4 [MERGE] forward port branch 10.0 up to 6edfadbdd2 2019-01-15 10:48:11 +01:00
Christophe Simonis b50883d17b [MERGE] forward port branch 11.0 up to c07b7200b2 2019-01-08 11:52:15 +01:00
Christophe Simonis c07b7200b2 [MERGE] forward port branch saas-15 up to e1c7fefe89 2019-01-07 18:19:25 +01:00
Christophe Simonis e1c7fefe89 [MERGE] forward port branch saas-14 up to cdb0c08cb9 2019-01-07 17:30:57 +01:00
Christophe Simonis cdb0c08cb9 [MERGE] forward port branch 10.0 up to d4024a713c 2019-01-07 17:30:11 +01:00
Raphael Collet a07a076c45 [FIX] models: avoid prefetch hell when reading fields
The method `read()` may be very slow when reading relational fields and
computed fields, because the computed fields can be computed on a recordset
that is larger than expected.

The issue occurs on model 'res.partner' when reading fields 'child_ids' and
'purchase_order_count', for instance.  Suppose we read those two fields on a
partner with 1000 contacts.  First, the one2many field is read from the
database and stored to the cache; the latter adds the value ids to the
prefetching of 'res.partner'.  Then, the fields are fetched from the cache.
When 'purchase_order_count' is accessed on the partner, the field is computed
on all its children as well...

closes odoo/odoo#29867
2019-01-03 12:45:48 +00:00
Raphael Collet 1b434ed8c3 [FIX] models: make prefetching more specific in read()
Commit a07a076c45 restricts the prefetching to
`self` when accessing the fields to return.  This is too restrictive, as it
cancels prefetching of secondary records in computed fields.  In this commit we
limit the scope of the restriction to `self`'s model only; this fixes the
original issue without impacting other models.

closes odoo/odoo#30133
2019-01-11 11:01:22 +00:00
Romain Derie b5fe23055d [FIX] website: handle COW'd views during module install/update
Since multi-website, we COW (copy on write) views when editing a view on a
website.
This is causing 2 issues related to module install/update:
1. During a module install, when creating an inherited view, it will create
   that view as expected on the generic tree.
   But that generic tree may not be used on website(s). Indeed, if the view
   was edited, we are now using a copy of the view instead of the original
   XML view (with an xml_id).
   That copied view won't get the new inherited view in its view tree.
   Now, we correctly copy the new view under every specific view tree (if
   exists).
2. During a module update, when updating a view, it will only update the view
   having the xml_id, so the generic one.
   But most of the time, the generic view is not used as it was usually COW'd
   and the specific view now replace the generic one.
   Now, we also apply the update on the COW'd view. Note that only unmodified
   field will be updated, this behavior basically mimic the noupdate behavior
   on view's ir.model.data.

Step to reproduce for bug 1:
  - Install website_sale module
  - Go to a product page and then enter edit mode
  - Make a modification to trigger COW, eg edit the information area under the
    price "30-day money-back guarantee".
  - Now install website_sale_comparison module
  - The product page won't have the comparison button as the comparison view
    inheriting the product view was created on the generic tree and not copied
    on the specific tree (COW'd before the comparison module install).

Step to reproduce for bug 2:
  - Repeat first 3 steps of bug 1
  - Now make a modification in a view from the XML file in
    website_sale_comparison module and update the module
  - Only the view with the xml_id is updated, not it's COW'd views. This mean
    that only the generic view is updated and not the specific one(s) really
    used on the website.

task-1920487

closes odoo/odoo#29956
2019-01-10 16:19:35 +00:00
Christophe Simonis 378b283c02 [MERGE] forward port branch saas-11.3 up to 83cc046e9a 2019-01-16 17:02:34 +01:00
Christophe Simonis 3e4138deaa [MERGE] forward port branch saas-11.3 up to 2d824a5b7a 2019-01-08 17:08:48 +01:00
Christophe Simonis ec9400821e [MERGE] forward port branch saas-11.3 up to 27a084eb81 2019-01-04 14:54:08 +01:00
Denis Ledoux 36551615b7 [IMP] read, cache: faster read by updating the cache by fields
instead of updating the cache by records.

We use `cr.fetchall()` and `zip` to get the values by field, which is more
convenient to be stored in cache.

Result of `cr.fetchall()`:
```
[
    (3, 'Marc Demo', 'demo@example.com', '032'),
    (1, 'Mitchell Admin', 'admin@example.com', '001'),
]
```
After being grouped by field:
```
[
    [3, 1],
    ['Marc Demo', 'Mitchell Admin],
    ['demo@example.com', 'admin@example.com'],
    ['032', '001'],
]
```

That way we can update the cache of a field for all records at once, by calling
the builtin `update` method of `dict` with the `zip` of record ids and
corresponding values.

This significantly speeds up the storage of field values in the cache.

closes odoo/odoo#30817
2019-02-11 16:22:01 +00:00
Denis Ledoux cb0e8831f9 [IMP] models: read, faster missing algorithm
Instead of fetching the cache values of records that will eventually be
removed, skip fetching values of a record as soon as we know a it is missing.
2019-02-11 15:54:21 +00:00
Denis Ledoux ecbc18ad8d [IMP] models: read, speed up by avoiding the use of indexation
Instead of iterating on self and then putting the values in the right place in
the `data` dict, iterate over data directly.

This removes the need of the indexing `data[record]`, which takes a significant
time when dealing with hundred of thousands of records.
2019-02-11 15:53:20 +00:00
Denis Ledoux ce0575ef27 [IMP] models: faster ensure_one implementation
Calling `len` on a long list and checking that its value is 1 is slower than
just unpacking the list.  The point is to check whether there is just one item
in the list, and counting all items just for that is a bit overkill.
2019-02-11 15:50:51 +00:00
Denis Ledoux dcc752aaab [IMP] models: faster browse records iteration
By avoiding to update the prefetch ids for each record when iterating on
recordsets.  This is faster when iterating on very large recordsets.
2019-02-11 15:49:21 +00:00