diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-05-04 21:05:58 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2017-05-05 10:45:50 +0200 |
| commit | 2febb8778f13ef7eafd56ab6e3366a039b55a8cc (patch) | |
| tree | a41a4318693f82c477e67bdc3e9c8aa5db58c7e4 /addons/web/static/src | |
| parent | 2c84ecc92f573f9e1b5562cba9cc6e7e909be9ca (diff) | |
[FIX] web: use action context in evaluation contexts
The process of evaluating a domain is not really difficult, but the hard
part is getting the evaluation context right. The evaluation context is
supposed to contain informations coming from various sources (active id/ids,
session context, ...). Before this commit, we just ignored the context coming
from the action.
This could cause many problems. For example, in the Inventory
application: create a picking, add 10 ice cream in initial demand, force
assign, click on scrap. A form view should be opened (with the context
coming back from the button_scrap method). In that formview, there is a
many2one Product. Clicking on it should perform a name_search with a
domain looking like ['id', 'in', [64]]. This domain is the result of
the evaluation of "[('id', 'in', context.get('product_ids', []))]".
Before this commit, product_ids was ignored, so the domain was always
['id', 'in', []].
In this commit, we simply add the element context in the list of sources
when computing the evaluation context (the element context is the
context given to the view, which is the way an action give a context to
a view)
In short, handling context is hard...
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 64030cea866..cde2d2479ac 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2002,7 +2002,7 @@ var BasicModel = AbstractModel.extend({ } _.extend(evalContext, {parent: parent.data}); } - return _.extend({}, session.user_context, evalContext); + return _.extend({}, session.user_context, element.context, evalContext); }, /** * Returns the list of field names of the given element according to its |
