summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-07-14 12:19:20 +0200
committerGéry Debongnie <ged@odoo.com>2017-07-14 14:47:13 +0200
commit29e4394af96eb4856fad913d2427320c11c30523 (patch)
tree5a6ca4f8b3a261fb765944f7886ab28c4381b25d /addons/web/static/src/js/views/basic/basic_model.js
parent04c3b99cb7cc1d8b1e6e5590e5e6866b4386f6dd (diff)
[FIX] web: properly reload record data before doing another action
When a user edit a record, then click on a stat button, the web client was a little too aggressive in avoiding to reload data. It was assuming that even if the server overrides the create method, the web client did not need to know anything about the record before executing the action from the stat button. However, that assumption is incorrect: the display_name property is needed to correctly display the breadcrumbs. For example, here is a scenario that was not correct: open a res.partner in a form view, edit its name, then click on one of the stat button. You will see that the breadcrumb is not properly updated. To fix this issue, we have to reload the record, and to properly update the title property. In this commit, we also add a getName method in the model.
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.js19
1 files changed, 19 insertions, 0 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 c562fa388f0..5fb77204ec7 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -84,11 +84,14 @@ odoo.define('web.BasicModel', function (require) {
var AbstractModel = require('web.AbstractModel');
var concurrency = require('web.concurrency');
+var core = require('web.core');
var Context = require('web.Context');
var Domain = require('web.Domain');
var fieldUtils = require('web.field_utils');
var session = require('web.session');
+var _t = core._t;
+
var x2ManyCommands = {
// (0, _, {values})
CREATE: 0,
@@ -421,6 +424,22 @@ var BasicModel = AbstractModel.extend({
return list;
},
/**
+ * Returns the current display_name for the record.
+ *
+ * @param {string} id the localID for a valid record element
+ * @returns {string}
+ */
+ getName: function (id) {
+ var record = this.localData[id];
+ if (record._changes && 'display_name' in record._changes) {
+ return record._changes.display_name;
+ }
+ if ('display_name' in record.data) {
+ return record.data.display_name;
+ }
+ return _t("New");
+ },
+ /**
* Returns true if a record is dirty. A record is considered dirty if it has
* some unsaved changes, marked by the _isDirty property on the record or
* one of its subrecords.