Commit Graph
32 Commits
Author SHA1 Message Date
Christophe Simonis 0f57bdba72 [MERGE] forward port branch saas-11.2 up to 42659dc70c 2018-03-09 16:25:58 +01:00
Christophe Simonis 52a190dc09 [FIX] test_new_api: declare fields in correct model 2018-03-08 19:27:43 +01:00
Christophe Simonis a0aa939d9b [MERGE] forward port branch 11.0 up to fcb48b7241 2018-03-08 19:00:04 +01:00
Christophe Matthieu 070f1173da [FIX] odoo: onchange load the related field data
Configurations uses an onchange to populate the fields visible to the
user. However, the related fields are by default called sudo, when it is
an onchange, there may be a missmatch in the cache, the cache used being
empty, there is no value to return (cache fix is not currently possible).

Before this fix we must use 'related_sudo=False' to use the good cache but
it's an inconsistent fix because in some case we must use sudo to avoid
access error.

opw-1823363
2018-03-08 15:36:22 +01:00
Raphael Collet e724858d50 [REF] models: use parent_path to implement parent_store
This replaces the former modified preorder tree traversal (MPTT) with the
fields `parent_left`/`parent_right`.  Each record is associated to a string
`parent_path`, that represents the path from its root node to itself.  The path
is made of the node ids suffixed with a slash:

              a                 node | id | parent_path
             / \                  a  | 42 | 42/
           ...  b                 b  | 63 | 42/63/
               / \                c  | 84 | 42/63/84/
              c   d               d  | 85 | 42/63/85/

This field provides an efficient implementation for parent_of/child_of queries:
the nodes in the subtree of record are the ones where `parent_path` starts with
the `parent_path` of record.  It is also more efficient to maintain than the
MPTT fields, and less sensitive to concurrent updates, because the value of
`parent_path` does not depend on sibling nodes.
2018-02-28 10:33:44 +01:00
Raphael Collet 6f30f0af9c [FIX] models: behavior with multiple inverse/compute mixed on same fields 2018-01-23 16:41:45 +01:00
Raphael Collet f1d60d2e52 [IMP] api: make the implementation of field protection more robust 2018-01-23 16:41:45 +01:00
Raphael Collet 2ed137af3e [REF] models: refactor code to update parent_left/parent_right
Put the code to update the MPTT in specific methods, and reduce the number of
queries being made (from 5-6 queries to 2-3 queries).  Add test on MPTT to
validate the refactoring.
2018-01-16 10:47:13 +01:00
Raphael Collet 3fbd86bcbe [IMP] field: compute transitive dependencies over non-stored fields
In other words, when a field F depends on a non-stored field G, it also depends
on G's dependencies.  This guarantees that whenever a dependency of G is
modified, F will be invalidated and marked to recompute (if necessary).

The transitive closure of dependencies is not computed over stored fields.
Anyway stored fields already trigger the recomputation of their dependent
fields during their recomputation.  The performance impact on the loading of a
registry is negligible (less than 1%), and the increase of recomputation
triggers is small (less than 10%).
2018-01-12 13:42:05 +01:00
Kinjal Mehta 564988f58d [IMP] test_new_api: changed duplicate field label in the same model 2018-01-04 17:56:57 +05:30
Raphael Collet 886003af93 [FIX] models: in onchange, consider all levels of subfields 2017-09-13 10:12:16 +02:00
Christophe Simonis 4879ce0407 [MERGE] forward port branch saas-17 up to fe77df3ba4 2017-08-31 12:55:41 +02:00
Christophe Simonis d0f132b297 [MERGE] forward port branch saas-16 up to 4ac347735d 2017-08-28 14:49:11 +02:00
Raphael Collet 32aa7dc9a0 [FIX] models: implement change_default behavior for fields
The behavior is no longer implemented by the web client.  Implement it
server-side as part of the onchange mechanism, simply by defining onchange
methods for the fields that have the flag.
2017-08-24 09:37:55 +02:00
Raphael Collet 8b49007a32 [IMP] avoid one query when recomputing a field (#18846)
Specifically, instead of reading fields on `recs.exists()`, simply read those
fields and catch `MissingError`.  This generates around 5% less queries.
2017-08-16 16:55:09 +02:00
xmo-odoo fffaf735f5 [FIX] P3: list -> iterable builtins (#16811)
In Python 3:

* various builtins and dict methods were changed to return
  view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
  removed altogether

This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).

Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.

issue #8530
2017-05-10 09:39:55 +02:00
Christophe Simonis b0992d082d [MERGE] forward port branch saas-14 up to 8f30e707e5 2017-04-13 15:31:27 +02:00
Christophe Simonis 13ad16104a [MERGE] forward port branch 10.0 up to 00e169c05a 2017-04-13 13:22:27 +02:00
Raphael Collet 3481f0faff [FIX] fields: recompute recursive stored fields 2017-04-11 15:34:34 +02:00
Christophe Simonis 2df5faa551 [MERGE] forward port branch saas-14 up to 2f68e9e93a 2017-03-28 18:05:31 +02:00
Christophe Simonis 2f68e9e93a [MERGE] forward port branch 10.0 up to 72fa3e8bda 2017-03-28 17:27:19 +02:00
Raphael Collet 9e23458d40 [FIX] models: ensure recomputation after inversing fields (#15683)
When updating record using "record.field = value", we need to ensure that
all fields in cache depending on "record.field" will be recomputed.
2017-03-23 17:11:00 +01:00
Nicolas Lempereur a247939620 [FIX] test_new_api: new steps for onchange and o2m
In f65475d6 one2many fields of default view in a form view were propagated
to the ORM so the value received from an onchange was not empty.

These new steps test this on a tree view embedded in a form view, or a
tree view originating from a default view by testing onchange adding row
or updating values of a one2many.
2017-03-20 13:25:40 +01:00
Christophe Simonis c8f01e3b62 [MERGE] forward port branch saas-14 up to b2fa9f2ad1 2017-03-17 18:03:00 +01:00
Christophe Simonis b2fa9f2ad1 [MERGE] forward port branch 10.0 up to 31ebb07773 2017-03-17 17:57:52 +01:00
Nicolas Lempereur cc1c15327c [FIX] expression: improve o2m with m2o integer
We sometimes use in Odoo a One2many field with an inverse Integer
field instead of a usual Many2one.

This allow for example in several instances to have a "Many2one" which
can be reference from several models, eg:

Model Ranking:
	name = String field
	res_id = Integer field
	res_model = String field

Model Toy:
	rank = One2many [inverse: Ranking -> res_id]
                        [domain: res_model == Toy]

Model Tool:
	rank = One2many [inverse: Ranking -> res_id]
                        [domain: res_model == Tool]

This enable us to have a shared feature between otherwise unrelated models.

But there was several issue when searching on these One2many:

1) if the Integer Many2one was not stored (eg. it came from an inherits) on
   the searched model, this could lead to an error.

2) when we searched:

   - by IDs (rank in ['55']) with at least one id not respecting the domain
   - by IDs with a negative operator
   - with a negative operator on unfound string (rank != "no rank has this")
   - with a false value (rank = False)

   we would not apply the One2many domain (eg. res_model == Toy) and thus
   possibly getting Toy 3 errenously because a Tool 3 was found without
   the domain being applied.

This fix modify the search on One2many and for:

1. if the inverse is an Integer not stored field instead of Many2one
   manage it.

2. if the field is an Integer field instead of Many2one and there is a
   domain on the One2many: apply the domain on the inverse model found.

So only some search on One2many with a domain whose inverse field is an
Integer could be impacted.

This would also be nice to have for all One2many with a domain but the
probability of it being useful versus risk for performance is not judged
high enough.

opw-710508
2017-03-16 11:57:04 +01:00
Raphael Collet b0646f9d2c [REF] move support for sparse fields into a separate module (#15070)
This removal has led to a necessary refactoring:
- make the setup of field attributes extensible;
- make the instantiation of custom fields extensible;
- delegate model and field reflection to `ir.model` and `ir.model.fields`;
- move the implementation of sparse and serialized fields to module `base_sparse_field`;
2017-01-19 16:29:29 +01:00
Raphael Collet 5d746d0ac6 [IMP] base, *: tighten ir.model access rights
Remove unrestricted "read" access.  To make code internally using `ir.model`
work, add a private method `_get` on `ir.model` to retrieve the record
corresponding to a model name, without access rights issue.

Change signature of method `get_authorized_fields` to make it use a model name
instead of a model id.  This removes the necessity of a search on `ir.model`.
2017-01-03 16:52:49 +01:00
Christophe Simonis f3532a6da6 [MERGE] forward port branch saas-12 up to 54ebe31 2016-10-11 19:07:42 +02:00
Christophe Simonis f4fc3985b6 [MERGE] forward port branch saas-12 up to 10cde43 2016-09-16 11:03:50 +02:00
Raphael Collet 7596fa3ee3 [FIX] base: adapt imports 2016-09-02 17:28:13 +02:00
Raphael Collet 9e64f9f951 [REF] openerp: move openerp to odoo 2016-09-02 17:28:12 +02:00