summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorMohammed Shekha <msh@odoo.com>2019-12-06 06:17:49 +0000
committerAaron Bohy <aab@odoo.com>2020-04-06 14:42:34 +0000
commit2b776cbbb5e5a9c9dd8b68933c70080cae5f28e0 (patch)
tree9055e0a75b4bb0bb683cf70c28df0fd9ddefad97 /addons/web/static/src/js/views/basic/basic_model.js
parenta210d75f554e353f0ca1faec2506e454818814b8 (diff)
[IMP] do not propagate default_* key from parent context to sub view
before this commit: from commit: https://github.com/odoo/odoo/commit/d58d6e270f4106d717821438490f60bc4f71306e parent context was propagated to sub views, propagating whole context to sub view creates issue as it contains default_* key inside it, there is a chance that sub view has same field name which matches with default_fieldName in context, e.g. go to sale order form view and create sale order line, while selecting product, write in product_id field so that Create and Edit option comes, select Create and Edit option, so whatever previously written in product_id field will be added in product.product form's context as default_name, now go to Purchase tab of product form and try to create Supplier, but note that Vendors One2many should be editable, if it is not then to produce this issue, make Vendor o2m list editable top/bottom, as soon as you click on Vendor o2m's create button traceback generated which comes from name_get of res.partner, issue raised because vendor o2m has m2o of res.partner and field name is 'name', when default_get for vendor o2m is called it will propagate context and context has default_name='typed string in product_id', as name field is m2o with res.partner it will generate traceback as m2o accepts (id, name) tuple not string after this commit: propagate context to sub view but remove default_* keys from parent context task-2121161 closes odoo/odoo#49075 X-original-commit: 2e3756e0ce96a9e0c5fa304632a2600cbd832ef5 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_model.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js6
1 files changed, 5 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 8dc540a8861..8de831ee506 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -4364,8 +4364,12 @@ var BasicModel = AbstractModel.extend({
var fields = view ? view.fields : fieldInfo.relatedFields;
var viewType = view ? view.type : fieldInfo.viewType;
+ // remove default_* keys from parent context to avoid issue of same field name in x2m
+ var parentContext = _.omit(record.context, function (val, key) {
+ return _.str.startsWith(key, 'default_');
+ });
var x2manyList = self._makeDataPoint({
- context: record.context,
+ context: parentContext,
fieldsInfo: fieldsInfo,
fields: fields,
limit: fieldInfo.limit,