summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-08-31 12:55:41 +0200
committerChristophe Simonis <chs@odoo.com>2017-08-31 12:55:41 +0200
commit4879ce040797fd4a47b6b8326c3aacd365c8ab91 (patch)
tree45479b47c5dcfba0d0ced4f05d770b0852f31263 /addons/web/static/src/js/views/basic
parentdae6178a0a5629ce678b20fcc9226caa44a5b0ce (diff)
parentfe77df3ba480d40b3d6b25736397bd52c684ce03 (diff)
[MERGE] forward port branch saas-17 up to fe77df3ba48
Diffstat (limited to 'addons/web/static/src/js/views/basic')
-rw-r--r--addons/web/static/src/js/views/basic/basic_controller.js6
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js24
2 files changed, 23 insertions, 7 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js
index cfdee6793dd..67de3ec8ad9 100644
--- a/addons/web/static/src/js/views/basic/basic_controller.js
+++ b/addons/web/static/src/js/views/basic/basic_controller.js
@@ -539,6 +539,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
* reload
*/
_onReload: function (event) {
+ event.stopPropagation(); // prevent other controllers from handling this request
var data = event && event.data || {};
var handle = data.db_id;
if (handle) {
@@ -546,7 +547,10 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
this.model.reload(handle).then(this._confirmSave.bind(this, handle));
} else {
// no db_id given, so reload the main record
- this.reload({fieldNames: data.fieldNames});
+ this.reload({
+ fieldNames: data.fieldNames,
+ keepChanges: data.keepChanges || false,
+ });
}
},
/**
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 537fa11fdb9..5eca6c5374f 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -1631,8 +1631,8 @@ var BasicModel = AbstractModel.extend({
*/
_fetchRecord: function (record, options) {
var self = this;
- var fieldNames = options && options.fieldNames ||
- _.uniq(record.getFieldNames().concat(['display_name']));
+ var fieldNames = options && options.fieldNames || record.getFieldNames();
+ fieldNames = _.uniq(fieldNames.concat(['display_name']));
return this._rpc({
model: record.model,
method: 'read',
@@ -2045,7 +2045,7 @@ var BasicModel = AbstractModel.extend({
if (record.data.hasOwnProperty(domainModel)) {
domainModel = record._changes && record._changes[domainModel] || record.data[domainModel];
}
- var domainValue = record._changes && record._changes[fieldName] || record.data[fieldName];
+ var domainValue = record._changes && record._changes[fieldName] || record.data[fieldName] || [];
// avoid rpc if not necessary
var hasChanged = this._saveSpecialDataCache(record, fieldName, {
@@ -2339,6 +2339,16 @@ var BasicModel = AbstractModel.extend({
_generateOnChangeData: function (record) {
var commands = this._generateX2ManyCommands(record, {withReadonly: true});
var data = _.extend(this.get(record.id, {raw: true}).data, commands);
+ // 'display_name' is automatically added to the list of fields to fetch,
+ // when fetching a record, even if it doesn't appear in the view. However,
+ // only the fields in the view must be passed to the onchange RPC, so we
+ // remove it from the data sent by RPC if it isn't in the view.
+ var hasDisplayName = _.some(record.fieldsInfo, function (fieldsInfo) {
+ return 'display_name' in fieldsInfo;
+ });
+ if (!hasDisplayName) {
+ delete data.display_name;
+ }
// one2many records have a parentID
if (record.parentID) {
@@ -2399,7 +2409,10 @@ var BasicModel = AbstractModel.extend({
_.each(list._changes, function (change) {
if (change.operation === 'ADD') {
relRecordAdded.push(self.localData[change.id]);
- } else if (change.operation === 'UPDATE') {
+ } else if (change.operation === 'UPDATE' && !self.isNew(change.id)) {
+ // ignore new records that would have been updated
+ // afterwards, as all their changes would already
+ // be aggregated in the CREATE command
relRecordUpdated.push(self.localData[change.id]);
}
});
@@ -2740,8 +2753,7 @@ var BasicModel = AbstractModel.extend({
var fieldInfo = element.fieldsInfo[element.viewType][fieldName];
var rawModifiers = JSON.parse(fieldInfo.modifiers || "{}");
var modifiers = self._evalModifiers(record, rawModifiers);
- var required = 'required' in modifiers ? modifiers.required : field.required;
- if (required && !self._isFieldSet(recordData[fieldName], field.type)) {
+ if (modifiers.required && !self._isFieldSet(recordData[fieldName], field.type)) {
isValid = false;
}
});