tryton-sao 7.2.15 → 7.2.16

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,9 @@
1
1
 
2
+ Version 7.2.16 - 2025-03-04
3
+ ---------------------------
4
+ * Bug fixes (see mercurial logs for details)
5
+
6
+
2
7
  Version 7.2.15 - 2025-02-16
3
8
  ---------------------------
4
9
  * 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.2.15',
6
+ __version__: '7.2.16',
7
7
  };
8
8
  /* eslint-enable no-redeclare */
9
9
 
@@ -8254,38 +8254,37 @@ var Sao = {
8254
8254
  var prm = jQuery.when();
8255
8255
  if ((this.id < 0) || this.modified) {
8256
8256
  var values = this.get();
8257
- if (this.id < 0) {
8258
- // synchronous call to avoid multiple creation
8259
- try {
8257
+ try {
8258
+ // synchronous call to avoid multiple creation or save
8259
+ if (this.id < 0) {
8260
8260
  this.id = this.model.execute(
8261
8261
  'create', [[values]], context, false)[0];
8262
- } catch (e) {
8263
- if (e.promise) {
8264
- return e.then(() => this.save(force_reload));
8265
- } else {
8266
- return jQuery.Deferred().reject();
8262
+
8263
+ } else {
8264
+ if (!jQuery.isEmptyObject(values)) {
8265
+ context._timestamp = this.get_timestamp();
8266
+ this.model.execute(
8267
+ 'write', [[this.id], values], context, false);
8267
8268
  }
8268
8269
  }
8269
- } else {
8270
- if (!jQuery.isEmptyObject(values)) {
8271
- context._timestamp = this.get_timestamp();
8272
- prm = this.model.execute('write', [[this.id], values],
8273
- context);
8270
+ } catch (e) {
8271
+ if (e.promise) {
8272
+ return e.then(() => this.save(force_reload));
8273
+ } else {
8274
+ return jQuery.Deferred().reject();
8274
8275
  }
8275
8276
  }
8276
- prm = prm.done(() => {
8277
- this.cancel();
8278
- if (force_reload) {
8279
- return this.reload();
8280
- }
8281
- });
8277
+ this.cancel();
8278
+ if (force_reload) {
8279
+ return this.reload();
8280
+ }
8282
8281
  if (this.group) {
8283
- prm = prm.done(() => this.group.written(this.id));
8282
+ prm = prm.then(() => this.group.written(this.id));
8284
8283
  }
8285
8284
  }
8286
8285
  if (this.group.parent) {
8287
8286
  delete this.group.parent.modified_fields[this.group.child_name];
8288
- prm = prm.done(() => this.group.parent.save(force_reload));
8287
+ prm = prm.then(() => this.group.parent.save(force_reload));
8289
8288
  }
8290
8289
  return prm;
8291
8290
  },
@@ -11538,7 +11537,7 @@ var Sao = {
11538
11537
  this.screen.save_tree_state();
11539
11538
  }
11540
11539
  var access = Sao.common.MODELACCESS.get(this.screen.model_name);
11541
- if (!(access.write || access.create)) {
11540
+ if (this.screen.readonly || !(access.write || access.create)) {
11542
11541
  return jQuery.Deferred().reject();
11543
11542
  }
11544
11543
  return this.screen.save_current().then(
@@ -11608,7 +11607,8 @@ var Sao = {
11608
11607
  });
11609
11608
  },
11610
11609
  delete_: function() {
11611
- if (!Sao.common.MODELACCESS.get(this.screen.model_name)['delete']) {
11610
+ if (!Sao.common.MODELACCESS.get(this.screen.model_name)['delete']
11611
+ || !this.screen.deletable) {
11612
11612
  return jQuery.when();
11613
11613
  }
11614
11614
  var msg;
@@ -13979,6 +13979,7 @@ var Sao = {
13979
13979
  },
13980
13980
  save_current: function() {
13981
13981
  var current_record = this.current_record;
13982
+ let new_record = current_record.id < 0;
13982
13983
  if (!current_record) {
13983
13984
  if (this.current_view &&
13984
13985
  (this.current_view.view_type == 'tree') &&
@@ -14016,6 +14017,9 @@ var Sao = {
14016
14017
  path.splice(-1, 1,
14017
14018
  [path[path.length - 1][0], current_record.id]);
14018
14019
  }
14020
+ if (new_record && this.switch_callback) {
14021
+ this.switch_callback();
14022
+ }
14019
14023
  return this.group.get_by_path(path).then(record => {
14020
14024
  this.current_record = record;
14021
14025
  });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "tryton-sao",
3
3
  "title": "sao",
4
4
  "description": "Tryton webclient",
5
- "version": "7.2.15",
5
+ "version": "7.2.16",
6
6
  "homepage": "http://www.tryton.org/",
7
7
  "author": {
8
8
  "name": "Tryton"
package/src/model.js CHANGED
@@ -599,38 +599,37 @@
599
599
  var prm = jQuery.when();
600
600
  if ((this.id < 0) || this.modified) {
601
601
  var values = this.get();
602
- if (this.id < 0) {
603
- // synchronous call to avoid multiple creation
604
- try {
602
+ try {
603
+ // synchronous call to avoid multiple creation or save
604
+ if (this.id < 0) {
605
605
  this.id = this.model.execute(
606
606
  'create', [[values]], context, false)[0];
607
- } catch (e) {
608
- if (e.promise) {
609
- return e.then(() => this.save(force_reload));
610
- } else {
611
- return jQuery.Deferred().reject();
607
+
608
+ } else {
609
+ if (!jQuery.isEmptyObject(values)) {
610
+ context._timestamp = this.get_timestamp();
611
+ this.model.execute(
612
+ 'write', [[this.id], values], context, false);
612
613
  }
613
614
  }
614
- } else {
615
- if (!jQuery.isEmptyObject(values)) {
616
- context._timestamp = this.get_timestamp();
617
- prm = this.model.execute('write', [[this.id], values],
618
- context);
615
+ } catch (e) {
616
+ if (e.promise) {
617
+ return e.then(() => this.save(force_reload));
618
+ } else {
619
+ return jQuery.Deferred().reject();
619
620
  }
620
621
  }
621
- prm = prm.done(() => {
622
- this.cancel();
623
- if (force_reload) {
624
- return this.reload();
625
- }
626
- });
622
+ this.cancel();
623
+ if (force_reload) {
624
+ return this.reload();
625
+ }
627
626
  if (this.group) {
628
- prm = prm.done(() => this.group.written(this.id));
627
+ prm = prm.then(() => this.group.written(this.id));
629
628
  }
630
629
  }
631
630
  if (this.group.parent) {
632
631
  delete this.group.parent.modified_fields[this.group.child_name];
633
- prm = prm.done(() => this.group.parent.save(force_reload));
632
+ prm = prm.then(() => this.group.parent.save(force_reload));
634
633
  }
635
634
  return prm;
636
635
  },
package/src/sao.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  /* eslint-disable no-redeclare */
5
5
  var Sao = {
6
- __version__: '7.2.15',
6
+ __version__: '7.2.16',
7
7
  };
8
8
  /* eslint-enable no-redeclare */
9
9
 
package/src/screen.js CHANGED
@@ -1597,6 +1597,7 @@
1597
1597
  },
1598
1598
  save_current: function() {
1599
1599
  var current_record = this.current_record;
1600
+ let new_record = current_record.id < 0;
1600
1601
  if (!current_record) {
1601
1602
  if (this.current_view &&
1602
1603
  (this.current_view.view_type == 'tree') &&
@@ -1634,6 +1635,9 @@
1634
1635
  path.splice(-1, 1,
1635
1636
  [path[path.length - 1][0], current_record.id]);
1636
1637
  }
1638
+ if (new_record && this.switch_callback) {
1639
+ this.switch_callback();
1640
+ }
1637
1641
  return this.group.get_by_path(path).then(record => {
1638
1642
  this.current_record = record;
1639
1643
  });
package/src/tab.js CHANGED
@@ -872,7 +872,7 @@
872
872
  this.screen.save_tree_state();
873
873
  }
874
874
  var access = Sao.common.MODELACCESS.get(this.screen.model_name);
875
- if (!(access.write || access.create)) {
875
+ if (this.screen.readonly || !(access.write || access.create)) {
876
876
  return jQuery.Deferred().reject();
877
877
  }
878
878
  return this.screen.save_current().then(
@@ -942,7 +942,8 @@
942
942
  });
943
943
  },
944
944
  delete_: function() {
945
- if (!Sao.common.MODELACCESS.get(this.screen.model_name)['delete']) {
945
+ if (!Sao.common.MODELACCESS.get(this.screen.model_name)['delete']
946
+ || !this.screen.deletable) {
946
947
  return jQuery.when();
947
948
  }
948
949
  var msg;