tryton-sao 6.8.12 → 6.8.14

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 6.8.14 - 2024-05-01
3
+ ---------------------------
4
+ * Bug fixes (see mercurial logs for details)
5
+
6
+
7
+ Version 6.8.13 - 2024-04-17
8
+ ---------------------------
9
+ * Bug fixes (see mercurial logs for details)
10
+
11
+
2
12
  Version 6.8.12 - 2024-04-04
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__: '6.8.12',
6
+ __version__: '6.8.14',
7
7
  };
8
8
  /* eslint-enable no-redeclare */
9
9
 
@@ -1814,7 +1814,7 @@ var Sao = {
1814
1814
  value = new Sao.PYSON.Bool(value);
1815
1815
  }
1816
1816
  } else if (typeof value != 'boolean') {
1817
- value = Sao.PYSON.Bool(value);
1817
+ value = new Sao.PYSON.Bool(value);
1818
1818
  }
1819
1819
  this._value = value;
1820
1820
  },
@@ -1833,7 +1833,7 @@ var Sao = {
1833
1833
  });
1834
1834
 
1835
1835
  Sao.PYSON.Not.eval_ = function(value, context) {
1836
- return !value.v;
1836
+ return !Sao.PYSON.Bool.eval_(value, context);
1837
1837
  };
1838
1838
  Sao.PYSON.Not.init_from_object = function(obj) {
1839
1839
  return new Sao.PYSON.Not(obj.v);
@@ -3654,10 +3654,14 @@ var Sao = {
3654
3654
  if (!refresh) {
3655
3655
  this._access = {};
3656
3656
  }
3657
- this._models = Sao.rpc({
3658
- 'method': 'model.ir.model.list_models',
3659
- 'params': [{}]
3660
- }, Sao.Session.current_session, false);
3657
+ try {
3658
+ this._models = Sao.rpc({
3659
+ 'method': 'model.ir.model.list_models',
3660
+ 'params': [{}]
3661
+ }, Sao.Session.current_session, false);
3662
+ } catch(e) {
3663
+ Sao.Logger.error("Unable to get model list.");
3664
+ }
3661
3665
  },
3662
3666
  get: function(model) {
3663
3667
  if (this._access[model] !== undefined) {
@@ -3671,10 +3675,23 @@ var Sao = {
3671
3675
  var to_load = this._models.slice(
3672
3676
  Math.max(0, idx - Math.floor(this.batchnum / 2)),
3673
3677
  idx + Math.floor(this.batchnum / 2));
3674
- var access = Sao.rpc({
3675
- 'method': 'model.ir.model.access.get_access',
3676
- 'params': [to_load, {}]
3677
- }, Sao.Session.current_session, false);
3678
+ var access;
3679
+ try {
3680
+ access = Sao.rpc({
3681
+ 'method': 'model.ir.model.access.get_access',
3682
+ 'params': [to_load, {}]
3683
+ }, Sao.Session.current_session, false);
3684
+ } catch(e) {
3685
+ Sao.Logger.error(`Unable to get access for ${model}.`);
3686
+ access = {
3687
+ model: {
3688
+ 'read': true,
3689
+ 'write': false,
3690
+ 'create': false,
3691
+ 'delete': false,
3692
+ },
3693
+ };
3694
+ }
3678
3695
  this._access = jQuery.extend(this._access, access);
3679
3696
  return this._access[model];
3680
3697
  }
@@ -13324,7 +13341,9 @@ var Sao = {
13324
13341
  },
13325
13342
  load: function(ids, set_cursor=true, modified=false, position=-1) {
13326
13343
  this.group.load(ids, modified, position);
13327
- this.current_view.reset();
13344
+ if (this.current_view) {
13345
+ this.current_view.reset();
13346
+ }
13328
13347
  this.current_record = null;
13329
13348
  return this.display().then(() => {
13330
13349
  if (set_cursor) {
@@ -13342,7 +13361,7 @@ var Sao = {
13342
13361
  } else {
13343
13362
  this.current_record = null;
13344
13363
  }
13345
- if (this.views) {
13364
+ if (this.views && this.current_view) {
13346
13365
  var search_prm = this.search_active(
13347
13366
  ~['tree', 'graph', 'calendar'].indexOf(
13348
13367
  this.current_view.view_type));
@@ -13378,8 +13397,9 @@ var Sao = {
13378
13397
  },
13379
13398
  _get_next_record: function() {
13380
13399
  var view = this.current_view;
13381
- if (~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13382
- this.current_record && this.current_record.group) {
13400
+ if (view &&
13401
+ ~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13402
+ this.current_record && this.current_record.group) {
13383
13403
  var group = this.current_record.group;
13384
13404
  var record = this.current_record;
13385
13405
  while (group) {
@@ -13408,16 +13428,19 @@ var Sao = {
13408
13428
  },
13409
13429
  display_next: function() {
13410
13430
  var view = this.current_view;
13411
- view.set_value();
13431
+ if (view) {
13432
+ view.set_value();
13433
+ }
13412
13434
  this.set_cursor(false, false);
13413
13435
  this.current_record = this._get_next_record();
13414
13436
  this.set_cursor(false, false);
13415
- return view.display();
13437
+ return view ? view.display() : jQuery.when();
13416
13438
  },
13417
13439
  _get_previous_record: function() {
13418
13440
  var view = this.current_view;
13419
- if (~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13420
- this.current_record && this.current_record.group) {
13441
+ if (view &&
13442
+ ~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13443
+ this.current_record && this.current_record.group) {
13421
13444
  var group = this.current_record.group;
13422
13445
  var record = this.current_record;
13423
13446
  while (group) {
@@ -13446,11 +13469,13 @@ var Sao = {
13446
13469
  },
13447
13470
  display_previous: function() {
13448
13471
  var view = this.current_view;
13449
- view.set_value();
13472
+ if (view) {
13473
+ view.set_value();
13474
+ }
13450
13475
  this.set_cursor(false, false);
13451
13476
  this.current_record = this._get_previous_record();
13452
13477
  this.set_cursor(false, false);
13453
- return view.display();
13478
+ return view ? view.display() : jQuery.when();
13454
13479
  },
13455
13480
  get selected_records() {
13456
13481
  if (this.current_view) {
@@ -13488,8 +13513,9 @@ var Sao = {
13488
13513
  });
13489
13514
  },
13490
13515
  default_row_activate: function() {
13491
- if ((this.current_view.view_type == 'tree') &&
13492
- (this.current_view.attributes.keyword_open == 1)) {
13516
+ if (this.current_view &&
13517
+ (this.current_view.view_type == 'tree') &&
13518
+ (this.current_view.attributes.keyword_open == 1)) {
13493
13519
  const id = this.get_id();
13494
13520
  if (id) {
13495
13521
  Sao.Action.exec_keyword('tree_open', {
@@ -13512,14 +13538,15 @@ var Sao = {
13512
13538
  new_: function(default_=true, rec_name=null) {
13513
13539
  var previous_view = this.current_view;
13514
13540
  var prm = jQuery.when();
13515
- if (this.current_view.view_type == 'calendar') {
13541
+ if (this.current_view &&
13542
+ this.current_view.view_type == 'calendar') {
13516
13543
  var selected_date = this.current_view.get_selected_date();
13517
13544
  }
13518
13545
  if (this.current_view && !this.current_view.creatable) {
13519
13546
  prm = this.switch_view('form', undefined, true, false);
13520
13547
  }
13521
13548
  return prm.then(() => {
13522
- if (!this.current_view.editable) {
13549
+ if (!this.current_view || !this.current_view.editable) {
13523
13550
  return;
13524
13551
  }
13525
13552
  var group;
@@ -13600,23 +13627,26 @@ var Sao = {
13600
13627
  save_current: function() {
13601
13628
  var current_record = this.current_record;
13602
13629
  if (!current_record) {
13603
- if ((this.current_view.view_type == 'tree') &&
13604
- this.group && this.group.length) {
13630
+ if (this.current_view &&
13631
+ (this.current_view.view_type == 'tree') &&
13632
+ this.group && this.group.length) {
13605
13633
  this.current_record = this.group[0];
13606
13634
  current_record = this.current_record;
13607
13635
  } else {
13608
13636
  return jQuery.when();
13609
13637
  }
13610
13638
  }
13611
- this.current_view.set_value();
13612
- var fields = this.current_view.get_fields();
13639
+ if (this.current_view) {
13640
+ this.current_view.set_value();
13641
+ var fields = this.current_view.get_fields();
13642
+ }
13613
13643
  var path = current_record.get_path(this.group);
13614
13644
  var prm = jQuery.Deferred();
13615
- if (this.current_view.view_type == 'tree') {
13645
+ if (this.current_view && (this.current_view.view_type == 'tree')) {
13616
13646
  prm = this.group.save().then(() => this.current_record);
13617
13647
  } else if (current_record.validate(fields, null, null, true)) {
13618
13648
  prm = current_record.save().then(() => current_record);
13619
- } else {
13649
+ } else if (this.current_view) {
13620
13650
  return this.current_view.display().then(() => {
13621
13651
  this.set_cursor();
13622
13652
  return jQuery.Deferred().reject();
@@ -13650,7 +13680,7 @@ var Sao = {
13650
13680
  var test = function(record) {
13651
13681
  return (record.modified || record.id < 0);
13652
13682
  };
13653
- if (this.current_view.view_type != 'tree') {
13683
+ if (this.current_view && (this.current_view.view_type != 'tree')) {
13654
13684
  if (this.current_record) {
13655
13685
  if (test(this.current_record)) {
13656
13686
  return true;
@@ -13661,20 +13691,24 @@ var Sao = {
13661
13691
  return true;
13662
13692
  }
13663
13693
  }
13664
- if (this.current_view.modified) {
13694
+ if (this.current_view && this.current_view.modified) {
13665
13695
  return true;
13666
13696
  }
13667
13697
  return false;
13668
13698
  },
13669
13699
  unremove: function() {
13670
- var records = this.current_view.selected_records;
13671
- for (const record of records) {
13672
- record.group.unremove(record);
13700
+ if (this.current_view) {
13701
+ var records = this.current_view.selected_records;
13702
+ for (const record of records) {
13703
+ record.group.unremove(record);
13704
+ }
13673
13705
  }
13674
13706
  },
13675
13707
  remove: function(delete_, remove, force_remove, records) {
13676
13708
  var prm = jQuery.when();
13677
- records = records || this.current_view.selected_records;
13709
+ if (!records && this.current_view) {
13710
+ records = this.current_view.selected_records;
13711
+ }
13678
13712
  if (jQuery.isEmptyObject(records)) {
13679
13713
  return prm;
13680
13714
  }
@@ -13715,7 +13749,8 @@ var Sao = {
13715
13749
  },
13716
13750
  copy: function() {
13717
13751
  var dfd = jQuery.Deferred();
13718
- var records = this.current_view.selected_records;
13752
+ var records = (
13753
+ this.current_view ? this.current_view.selected_records : []);
13719
13754
  this.model.copy(records, this.context)
13720
13755
  .then(new_ids => {
13721
13756
  this.group.load(new_ids, false, this.new_position);
@@ -13896,14 +13931,18 @@ var Sao = {
13896
13931
  if (!this.current_record) {
13897
13932
  return null;
13898
13933
  }
13899
- this.current_view.set_value();
13934
+ if (this.current_view) {
13935
+ this.current_view.set_value();
13936
+ }
13900
13937
  return this.current_record.get();
13901
13938
  },
13902
13939
  get_on_change_value: function() {
13903
13940
  if (!this.current_record) {
13904
13941
  return null;
13905
13942
  }
13906
- this.current_view.set_value();
13943
+ if (this.current_view) {
13944
+ this.current_view.set_value();
13945
+ }
13907
13946
  return this.current_record.get_on_change_value();
13908
13947
  },
13909
13948
  reload: function(ids, written) {
@@ -13916,15 +13955,17 @@ var Sao = {
13916
13955
  promises.push(this.group.parent.root_parent.reload());
13917
13956
  }
13918
13957
  return jQuery.when.apply(jQuery, promises).then(() => {
13919
- this.display();
13958
+ return this.display();
13920
13959
  });
13921
13960
  },
13922
13961
  get_buttons: function() {
13923
- var selected_records = this.current_view.selected_records;
13962
+ var selected_records = (
13963
+ this.current_view ? this.current_view.selected_records : []);
13924
13964
  if (jQuery.isEmptyObject(selected_records)) {
13925
13965
  return [];
13926
13966
  }
13927
- var buttons = this.current_view.get_buttons();
13967
+ var buttons = (
13968
+ this.current_view ? this.current_view.get_buttons() : []);
13928
13969
  for (const record of selected_records) {
13929
13970
  buttons = buttons.filter(function(button) {
13930
13971
  if (button.attributes.type === 'instance') {
@@ -13951,12 +13992,15 @@ var Sao = {
13951
13992
  ids: ids
13952
13993
  }, null, this.context, true);
13953
13994
  }
13995
+ this.record_saved();
13954
13996
  });
13955
13997
  };
13956
13998
 
13957
- var selected_records = this.current_view.selected_records;
13958
- this.current_view.set_value();
13959
- var fields = this.current_view.get_fields();
13999
+ if (this.current_view) {
14000
+ var selected_records = this.current_view.selected_records;
14001
+ this.current_view.set_value();
14002
+ var fields = this.current_view.get_fields();
14003
+ }
13960
14004
 
13961
14005
  var prms = [];
13962
14006
  const reset_state = record => {
@@ -14052,7 +14096,8 @@ var Sao = {
14052
14096
  } else if (action.startsWith('switch')) {
14053
14097
  this.switch_view.apply(this, action.split(' ', 3).slice(1));
14054
14098
  } else if (action == 'reload') {
14055
- if (~['tree', 'graph', 'calendar'].indexOf(this.current_view.view_type) &&
14099
+ if (this.current_view &&
14100
+ ~['tree', 'graph', 'calendar'].indexOf(this.current_view.view_type) &&
14056
14101
  !this.group.parent) {
14057
14102
  this.search_filter();
14058
14103
  }
@@ -14091,7 +14136,7 @@ var Sao = {
14091
14136
  var path = ['model', this.model_name];
14092
14137
  var view_ids = this.views.map(
14093
14138
  function(v) {return v.view_id;}).concat(this.view_ids);
14094
- if (this.current_view.view_type != 'form') {
14139
+ if (this.current_view && (this.current_view.view_type != 'form')) {
14095
14140
  var search_value;
14096
14141
  if (this.attributes.search_value) {
14097
14142
  search_value = this.attributes.search_value;
@@ -14104,8 +14149,10 @@ var Sao = {
14104
14149
  }
14105
14150
  } else if (this.current_record && (this.current_record.id > -1)) {
14106
14151
  path.push(this.current_record.id);
14107
- var i = view_ids.indexOf(this.current_view.view_id);
14108
- view_ids = view_ids.slice(i).concat(view_ids.slice(0, i));
14152
+ if (this.current_view) {
14153
+ var i = view_ids.indexOf(this.current_view.view_id);
14154
+ view_ids = view_ids.slice(i).concat(view_ids.slice(0, i));
14155
+ }
14109
14156
  }
14110
14157
  if (!jQuery.isEmptyObject(view_ids)) {
14111
14158
  query_string.push(['views', dumps(view_ids)]);
@@ -14199,6 +14246,9 @@ var Sao = {
14199
14246
  set_tree_state: function() {
14200
14247
  var parent_, state, state_prm, tree_state_model;
14201
14248
  var view = this.current_view;
14249
+ if (!view) {
14250
+ return jQuery.when();
14251
+ }
14202
14252
  if (!~['tree', 'form', 'list-form'].indexOf(view.view_type)) {
14203
14253
  return jQuery.when();
14204
14254
  }
@@ -21643,8 +21693,7 @@ function eval_pyson(value){
21643
21693
  collapse_children: function() {
21644
21694
  for (const row of this.rows) {
21645
21695
  row.collapse_children();
21646
- var node = row.el[0];
21647
- node.parentNode.removeChild(node);
21696
+ row.el.remove();
21648
21697
  }
21649
21698
  this.rows = [];
21650
21699
  },
@@ -24811,7 +24860,7 @@ function eval_pyson(value){
24811
24860
  record.modified_fields.id = added;
24812
24861
  }
24813
24862
  } else {
24814
- result = response_id != 'RESPONSE_CANCEL';
24863
+ result = (response_id != 'RESPONSE_CANCEL') && !readonly;
24815
24864
  }
24816
24865
  (cancel_prm || jQuery.when()).then(() => {
24817
24866
  if (this.callback) {