summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js15
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js25
2 files changed, 35 insertions, 5 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index 2fb0521ffb5..fbb6d0e7c6b 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -1028,6 +1028,21 @@ var FieldPhone = FieldEmail.extend({
},
/**
+ * Remove possibly present ­ characters when saving number
+ *
+ * @override
+ * @private
+ */
+ _setValue: function (value, options) {
+ // NOT NEEDED AS OF SAAS-11.3
+ if (value) {
+ // remove possibly pasted ­ characters
+ value = value.replace(/\u00AD/g, '');
+ }
+ return this._super(value, options);
+ },
+
+ /**
* Phone fields are clickable in readonly on small screens ~= on phones.
* This can be overriden by call-capable modules to display a clickable
* link in different situations, like always regardless of screen size,
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 353da62706f..a977147460a 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -1292,12 +1292,27 @@ var FieldOne2Many = FieldX2Many.extend({
// we don't want interference with the components upstream.
ev.stopPropagation();
+ var self = this;
var id = ev.data.id;
- // trigger an empty 'UPDATE' operation when the user clicks on 'Save' in
- // the dialog, to notify the main record that a subrecord of this
- // relational field has changed (those changes will be already stored on
- // that subrecord, thanks to the 'Save').
- var onSaved = this._setValue.bind(this, { operation: 'UPDATE', id: id }, {});
+ var onSaved = function (record, hasChanged) {
+ if (!hasChanged) {
+ return;
+ }
+ if (_.some(self.value.data, {id: record.id})) {
+ // the record already exists in the relation, so trigger an
+ // empty 'UPDATE' operation when the user clicks on 'Save' in
+ // the dialog, to notify the main record that a subrecord of
+ // this relational field has changed (those changes will be
+ // already stored on that subrecord, thanks to the 'Save').
+ self._setValue({ operation: 'UPDATE', id: record.id });
+ } else {
+ // the record isn't in the relation yet, so add it ; this can
+ // happen if the user clicks on 'Save & New' in the dialog (the
+ // opened record will be updated, and other records will be
+ // created)
+ self._setValue({ operation: 'ADD', id: record.id });
+ }
+ };
this._openFormDialog({
id: id,
on_saved: onSaved,