Commit Graph
332 Commits
Author SHA1 Message Date
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
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 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
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
Christophe Simonis 49c3264ce0 [MERGE] forward port branch saas-11.3 up to 4850fb0838 2018-09-07 14:43:48 +02:00
Toufik Benjaa 7700bd172f [FIX] mail: Avoid using default value for track fields logging
- When a tracked field is modified, a mail.message is created.
  When create is called its tries to fill missing values with "default
values".
  It first tries to find the default values in the context, which may
occurs.
  For example, modifying a tracked field on a subtask will add a key
"default_parent_id" in the context, which is the parent_id of the project.task.
  Create will try to use "default_parent_id" for the mail.message
parent_id field, which make the SQL Request invalid.
2018-09-05 18:36:54 +02:00
Christophe Simonis 4f62d6dd8f [MERGE] forward port branch saas-11.4 up to ef6b574eda 2018-08-22 12:02:30 +02:00
Christophe Simonis ef6b574eda [MERGE] forward port branch saas-11.3 up to 6cc7d3f945 2018-08-21 18:48:13 +02:00
Christophe Simonis 70d0148d0d [MERGE] forward port branch 11.0 up to fbfb91799e 2018-08-21 16:58:17 +02:00
Christophe Simonis fbfb91799e [MERGE] forward port branch saas-15 up to 9cf0dbe226 2018-08-21 16:00:40 +02:00
Christophe Simonis e80f853ab3 [MERGE] forward port branch saas-14 up to aafa6e38c4 2018-08-21 12:06:23 +02:00
Christophe Simonis aafa6e38c4 [MERGE] forward port branch 10.0 up to 342d037373 2018-08-21 11:33:53 +02:00
Nicolas Martinelli 07b5f205ab [FIX] models: unlink ir.property
On a new DB with demo data, as Demo User:
- Create a partner
- Unlink the partner

An `AccessError` is raised.

The error is raised on `ir.property`, for the field
`property_product_pricelist`. An entry was indeed automatically created
at partner creation. However, a regular user is not allowed to delete an
`ir.property`.

The property can be safely deleted as SUPERUSER as long as the proper
unlink access rights have been tested beforehand.

opw-1870737
2018-08-21 09:32:01 +02:00
Stefan Rijnhart b3824aa6cb [RFR] Hide implementation of constraint definition storage, courtesy of Raphael Collet 2018-08-16 10:33:06 +02:00
Stefan Rijnhart 6327b8f97f [IMP] Store the original constraint definition as a comment on the constraint
and use it to determine if the constraint definition was changed. This prevents
endless readding of constraints that are reformatted by postgresql in an
unrecognizable way (in which e.g. "CHECK (credit*debit=0)" becomes
"CHECK ((credit * debit) = 0::numeric)")
2018-08-16 10:33:06 +02:00
Florent de Labarre d319160d3d [IMP] models: keep a consistent order for record metadata
When reading the metadata of a record, ensure the order is consistent.
The retrieval of ir.model.data is now done using an order=id query

Use the ORM to retrieve ir.model.data instead of making an SQL to clean old
code (introduced at b3b22afc68)

Closes #25658
2018-08-13 16:44:08 +02:00
Francois Volral 914bbd363c [FIX] orm: Fix a bug in _read_group_fill_temporal.
_read_group_fill_temporal was returning a None value instand of a [] when its
'data' parameter was an empty array, resulting in crash in graph_view.
2018-08-13 15:45:38 +02:00
Francois Volral 6caf5ed7d2 [FIX] orm: Adapt test and read_group_fill_temporal
In the commit 4a40db2. the implementation of read_group_fill_temporal was
simplified during final review and tests needed to be adapted.

Also fix the implementation issues as detected by the tests.
2018-08-10 18:15:27 +02:00
Francois Volral 4a40db2097 [IMP] orm: add support to fill temporal holes (read_group)
This commit add an extra parameter 'fill_temporal' to read_group which allows
the orm to add missing groups for date intervals. This is useful for charts.

Suppose that we are in a use case where data are grouped by a date fields
(typically months but it could be another interval) and displayed in a Bar Chart
or a Line Char.
Let's says a request has to group records by month for August, September
and ...December.  If we don't changed anything, we would get a Bar Chart
looking like this :
                                        ___
                              ___      |   |
                             |   |     |   |
                             |   | ___ |   |
                             |   ||   ||   |
                             |___||___||___|
                              Aug  Sep  D
December follows directly after September, it can be unintuitive for the
user, so we change that. We add some fake records for each missing months
between the earliest and the lastest date of the result
                                             ___
                         ___                |   |
                        |   |               |   |
                        |   | ___           |   |
                        |   ||   |          |   |
                        |___||___| ___  ___ |___|
                         Aug  Sep  Oct  Nov  Dec

This commit is part of task #1835644
2018-08-10 17:21:17 +02:00
XavierDo 1de9496f14 [IMP] mail: add activity view
A simple new view to easily display all activity on a model grouped
by res_id and activity_type_id. Some action are possible like sending
a mail template for all record having an activity with this activity type
and present in the view (depends on the filter).

The view use the Kanban activity view on cells. It could be a good idea
to rename this widget to something like "DropdownActivityView" (maybe
after the freeze)

Task: #1870662
PR: #26272
2018-08-10 15:20:37 +02:00
Christophe Simonis 7499b47ffa [MERGE] forward port branch saas-11.4 up to edd586002e 2018-08-10 13:37:21 +02:00
Christophe Simonis 7717f082c0 [MERGE] forward port branch saas-11.3 up to af35aea6b0 2018-08-09 19:33:32 +02:00
Christophe Simonis 9cb97a8c2d [MERGE] forward port branch saas-11.2 up to 499af66727 2018-08-09 15:06:31 +02:00
Christophe Simonis efe2dcd7ae [MERGE] forward port branch 11.0 up to ced9156a97 2018-08-07 19:08:07 +02:00
Christophe Simonis 65a80cf3fd [MERGE] forward port branch saas-14 up to 0c5cbbe0bb 2018-08-07 17:01:16 +02:00