Commit Graph
384 Commits
Author SHA1 Message Date
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
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
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
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