summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorDavid Monjoie <dmo@odoo.com>2017-07-26 12:00:42 +0200
committerDavid Monjoie <dmo@odoo.com>2017-07-28 08:29:12 +0200
commit3b3f6f04af79d7dcc4461262e14e05096d76180b (patch)
tree1c483a935bd90f4ef3c13fd3fb30c2f8b6554d87 /addons/web/static/src/js/views/basic/basic_model.js
parent4e12edc023dd20d435f5575b5517a3c11deb8421 (diff)
[FIX] web: save changes when readonly if force_save is set
In previous versions, readonly used to prevent sending the values of the fields to the server. However, it was not working properly for fields which have their own sub-arch in the view, as the value used to be sent regardless of the readonly value. In the new views, the readonly modifier is never overlooked, which created a bug in the stock_picking_return wizard which was not able to return products received from a po anymore. Basically the value of the product_id field was not sent so the create crashed. This commit introduces a new "force_save" modifier which is used to express that we want to save the value of the field even though it is readonly from a user interface point of view.
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.js13
1 files changed, 7 insertions, 6 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 73cd2863f21..04fe384afdc 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -2203,7 +2203,7 @@ var BasicModel = AbstractModel.extend({
// remove readonly fields from the list of changes
if (!withReadonly && fieldName in changes || fieldName in commands) {
var editionViewType = record._editionViewType[fieldName] || viewType;
- if (this._isFieldReadonly(record, fieldName, editionViewType)) {
+ if (this._isFieldProtected(record, fieldName, editionViewType)) {
delete changes[fieldName];
continue;
}
@@ -2562,9 +2562,10 @@ var BasicModel = AbstractModel.extend({
return context;
},
/**
- * Returns true if the field is readonly (checking first in the modifiers,
- * and if there is no readonly modifier, checking the readonly attribute of
- * the field).
+ * Returns true if the field is protected against changes, looking for a
+ * readonly modifier unless there is a force_save modifier (checking first
+ * in the modifiers, and if there is no readonly modifier, checking the
+ * readonly attribute of the field).
*
* @private
* @param {Object} record an element from the localData
@@ -2573,12 +2574,12 @@ var BasicModel = AbstractModel.extend({
* main viewType from the record
* @returns {boolean}
*/
- _isFieldReadonly: function (record, fieldName, viewType) {
+ _isFieldProtected: function (record, fieldName, viewType) {
var fieldInfo = record.fieldsInfo[viewType || record.viewType][fieldName];
if (fieldInfo) {
var rawModifiers = JSON.parse(fieldInfo.modifiers || "{}");
var modifiers = this._evalModifiers(record, rawModifiers);
- return modifiers.readonly;
+ return modifiers.readonly && !fieldInfo.force_save;
} else {
return false;
}