tryton-sao 7.0.26 → 7.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG CHANGED
@@ -1,4 +1,14 @@
1
1
 
2
+ Version 7.0.28 - 2025-04-26
3
+ ---------------------------
4
+ * Bug fixes (see mercurial logs for details)
5
+
6
+
7
+ Version 7.0.27 - 2025-04-02
8
+ ---------------------------
9
+ * Bug fixes (see mercurial logs for details)
10
+
11
+
2
12
  Version 7.0.26 - 2025-03-15
3
13
  ---------------------------
4
14
  * Bug fixes (see mercurial logs for details)
@@ -3,7 +3,7 @@
3
3
 
4
4
  /* eslint-disable no-redeclare */
5
5
  var Sao = {
6
- __version__: '7.0.26',
6
+ __version__: '7.0.28',
7
7
  };
8
8
  /* eslint-enable no-redeclare */
9
9
 
@@ -4015,7 +4015,7 @@ var Sao = {
4015
4015
  });
4016
4016
  }
4017
4017
  };
4018
- this._selection_prm.done(_update_selection);
4018
+ this._selection_prm.always(_update_selection);
4019
4019
  };
4020
4020
  Sao.common.selection_mixin.filter_selection = function(
4021
4021
  domain, record, field) {
@@ -8121,6 +8121,7 @@ var Sao = {
8121
8121
  this.autocompletion = {};
8122
8122
  this.exception = false;
8123
8123
  this.destroyed = false;
8124
+ this._save_prm = jQuery.when();
8124
8125
  },
8125
8126
  get modified() {
8126
8127
  if (!jQuery.isEmptyObject(this.modified_fields)) {
@@ -8134,33 +8135,28 @@ var Sao = {
8134
8135
  },
8135
8136
  save: function(force_reload=false) {
8136
8137
  var context = this.get_context();
8138
+ if (this._save_prm.state() == 'pending') {
8139
+ return this._save_prm.then(() => this.save(force_reload));
8140
+ }
8137
8141
  var prm = jQuery.when();
8138
8142
  if ((this.id < 0) || this.modified) {
8139
8143
  var values = this.get();
8140
- try {
8141
- // synchronous call to avoid multiple creation or save
8142
- if (this.id < 0) {
8143
- this.id = this.model.execute(
8144
- 'create', [[values]], context, false)[0];
8145
-
8146
- } else {
8147
- if (!jQuery.isEmptyObject(values)) {
8148
- context._timestamp = this.get_timestamp();
8149
- this.model.execute(
8150
- 'write', [[this.id], values], context, false);
8151
- }
8152
- }
8153
- } catch (e) {
8154
- if (e.promise) {
8155
- return e.then(() => this.save(force_reload));
8156
- } else {
8157
- return jQuery.Deferred().reject();
8144
+ if (this.id < 0) {
8145
+ prm = this.model.execute('create', [[values]], context)
8146
+ .then(ids => this.id = ids[0]);
8147
+ } else {
8148
+ if (!jQuery.isEmptyObject(values)) {
8149
+ context._timestamp = this.get_timestamp();
8150
+ prm = this.model.execute(
8151
+ 'write', [[this.id], values], context);
8158
8152
  }
8159
8153
  }
8160
- this.cancel();
8161
- if (force_reload) {
8162
- return this.reload();
8163
- }
8154
+ prm = prm.then(() => {
8155
+ this.cancel();
8156
+ if (force_reload) {
8157
+ return this.reload();
8158
+ }
8159
+ });
8164
8160
  if (this.group) {
8165
8161
  prm = prm.then(() => this.group.written(this.id));
8166
8162
  }
@@ -8169,6 +8165,7 @@ var Sao = {
8169
8165
  delete this.group.parent.modified_fields[this.group.child_name];
8170
8166
  prm = prm.then(() => this.group.parent.save(force_reload));
8171
8167
  }
8168
+ this._save_prm = prm;
8172
8169
  return prm;
8173
8170
  },
8174
8171
  reload: function(fields, async=true) {
@@ -11977,6 +11974,7 @@ var Sao = {
11977
11974
  }
11978
11975
  }
11979
11976
  const view_type = this.screen.current_view.view_type;
11977
+ var next_view_type = this.screen.next_view_type;
11980
11978
  const has_views = this.screen.number_of_views > 1;
11981
11979
  var buttons = ['print', 'relate', 'email', 'attach'];
11982
11980
  for (const button_id of buttons) {
@@ -11997,7 +11995,9 @@ var Sao = {
11997
11995
  set_sensitive(button_id, position && can_be_sensitive);
11998
11996
  }
11999
11997
  set_sensitive(
12000
- 'switch_', (position || (view_type == 'form')) && has_views);
11998
+ 'switch_',
11999
+ (position || (view_type == 'form') || (next_view_type != 'form')) &&
12000
+ has_views);
12001
12001
  set_sensitive('delete_', this.screen.deletable);
12002
12002
  set_sensitive('previous', this.screen.has_previous());
12003
12003
  set_sensitive('next', this.screen.has_next());
@@ -13132,6 +13132,18 @@ var Sao = {
13132
13132
  get number_of_views() {
13133
13133
  return this.views.length + this.view_to_load.length;
13134
13134
  },
13135
+ get view_index() {
13136
+ return this.views.indexOf(this.current_view);
13137
+ },
13138
+ get next_view_type() {
13139
+ var views = this.views.concat(this.view_to_load)
13140
+ var next_view_index = (this.view_index + 1) % views.length;
13141
+ var next_view = views[next_view_index];
13142
+ if (typeof next_view != 'string') {
13143
+ next_view = next_view.view_type;
13144
+ }
13145
+ return next_view;
13146
+ },
13135
13147
  switch_view: function(
13136
13148
  view_type=null, view_id=null, creatable=null, display=true) {
13137
13149
  if (view_id !== null) {
@@ -13795,7 +13807,6 @@ var Sao = {
13795
13807
  },
13796
13808
  save_current: function() {
13797
13809
  var current_record = this.current_record;
13798
- let new_record = current_record.id < 0;
13799
13810
  if (!current_record) {
13800
13811
  if (this.current_view &&
13801
13812
  (this.current_view.view_type == 'tree') &&
@@ -13806,6 +13817,7 @@ var Sao = {
13806
13817
  return jQuery.when();
13807
13818
  }
13808
13819
  }
13820
+ let new_record = current_record.id < 0;
13809
13821
  if (this.current_view) {
13810
13822
  this.current_view.set_value();
13811
13823
  var fields = this.current_view.get_fields();
@@ -14481,7 +14493,8 @@ var Sao = {
14481
14493
  return view.display(selected_nodes);
14482
14494
  } else {
14483
14495
  var record;
14484
- if (!jQuery.isEmptyObject(selected_nodes)) {
14496
+ if (!jQuery.isEmptyObject(selected_nodes) &&
14497
+ !this.current_record) {
14485
14498
  for (const id of selected_nodes[0]) {
14486
14499
  const new_record = this.group.get(id);
14487
14500
  if (!new_record) {
@@ -20054,8 +20067,7 @@ function eval_pyson(value){
20054
20067
  return this._parse(this.format, this.input.val());
20055
20068
  },
20056
20069
  set_value: function(value) {
20057
- if ((value instanceof Sao.DateTime) ||
20058
- (value instanceof Sao.Date)) {
20070
+ if (value && (value.isDate || value.isDateTime)) {
20059
20071
  value = this._format(this.format, value);
20060
20072
  } else {
20061
20073
  value = '';