tryton-sao 6.0.39 → 6.0.41

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.0.41 - 2024-05-01
3
+ ---------------------------
4
+ * Bug fixes (see mercurial logs for details)
5
+
6
+
7
+ Version 6.0.40 - 2024-04-17
8
+ ---------------------------
9
+ * Bug fixes (see mercurial logs for details)
10
+
11
+
2
12
  Version 6.0.39 - 2024-04-04
3
13
  ---------------------------
4
14
  * Bug fixes (see mercurial logs for details)
@@ -1721,7 +1721,7 @@ var Sao = {};
1721
1721
  value = new Sao.PYSON.Bool(value);
1722
1722
  }
1723
1723
  } else if (typeof value != 'boolean') {
1724
- value = Sao.PYSON.Bool(value);
1724
+ value = new Sao.PYSON.Bool(value);
1725
1725
  }
1726
1726
  this._value = value;
1727
1727
  },
@@ -1740,7 +1740,7 @@ var Sao = {};
1740
1740
  });
1741
1741
 
1742
1742
  Sao.PYSON.Not.eval_ = function(value, context) {
1743
- return !value.v;
1743
+ return !Sao.PYSON.Bool.eval_(value, context);
1744
1744
  };
1745
1745
  Sao.PYSON.Not.init_from_object = function(obj) {
1746
1746
  return new Sao.PYSON.Not(obj.v);
@@ -3409,10 +3409,14 @@ var Sao = {};
3409
3409
  if (!refresh) {
3410
3410
  this._access = {};
3411
3411
  }
3412
- this._models = Sao.rpc({
3413
- 'method': 'model.ir.model.list_models',
3414
- 'params': [{}]
3415
- }, Sao.Session.current_session, false);
3412
+ try {
3413
+ this._models = Sao.rpc({
3414
+ 'method': 'model.ir.model.list_models',
3415
+ 'params': [{}]
3416
+ }, Sao.Session.current_session, false);
3417
+ } catch(e) {
3418
+ Sao.Logger.error("Unable to get model list.");
3419
+ }
3416
3420
  },
3417
3421
  get: function(model) {
3418
3422
  if (this._access[model] !== undefined) {
@@ -3426,10 +3430,23 @@ var Sao = {};
3426
3430
  var to_load = this._models.slice(
3427
3431
  Math.max(0, idx - Math.floor(this.batchnum / 2)),
3428
3432
  idx + Math.floor(this.batchnum / 2));
3429
- var access = Sao.rpc({
3430
- 'method': 'model.ir.model.access.get_access',
3431
- 'params': [to_load, {}]
3432
- }, Sao.Session.current_session, false);
3433
+ var access;
3434
+ try {
3435
+ access = Sao.rpc({
3436
+ 'method': 'model.ir.model.access.get_access',
3437
+ 'params': [to_load, {}]
3438
+ }, Sao.Session.current_session, false);
3439
+ } catch(e) {
3440
+ Sao.Logger.error(`Unable to get access for ${model}.`);
3441
+ access = {
3442
+ model: {
3443
+ 'read': true,
3444
+ 'write': false,
3445
+ 'create': false,
3446
+ 'delete': false,
3447
+ },
3448
+ };
3449
+ }
3433
3450
  this._access = jQuery.extend(this._access, access);
3434
3451
  return this._access[model];
3435
3452
  }
@@ -12931,8 +12948,12 @@ var Sao = {};
12931
12948
  set_cursor = true;
12932
12949
  }
12933
12950
  this.group.load(ids, modified);
12934
- this.current_view.reset();
12935
- if (ids.length && this.current_view.view_type != 'calendar') {
12951
+ if (this.current_view) {
12952
+ this.current_view.reset();
12953
+ }
12954
+ if (ids.length &&
12955
+ this.current_view &&
12956
+ this.current_view.view_type != 'calendar') {
12936
12957
  this.current_record = this.group.get(ids[0]);
12937
12958
  } else {
12938
12959
  this.current_record = null;
@@ -12953,7 +12974,7 @@ var Sao = {};
12953
12974
  } else {
12954
12975
  this.current_record = null;
12955
12976
  }
12956
- if (this.views) {
12977
+ if (this.views && this.current_view) {
12957
12978
  var search_prm = this.search_active(
12958
12979
  ~['tree', 'graph', 'calendar'].indexOf(
12959
12980
  this.current_view.view_type));
@@ -12992,7 +13013,8 @@ var Sao = {};
12992
13013
  var view = this.current_view;
12993
13014
  view.set_value();
12994
13015
  this.set_cursor(false, false);
12995
- if (~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13016
+ if (view &&
13017
+ ~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
12996
13018
  this.current_record && this.current_record.group) {
12997
13019
  var group = this.current_record.group;
12998
13020
  var record = this.current_record;
@@ -13019,9 +13041,12 @@ var Sao = {};
13019
13041
  },
13020
13042
  display_previous: function() {
13021
13043
  var view = this.current_view;
13022
- view.set_value();
13044
+ if (view) {
13045
+ view.set_value();
13046
+ }
13023
13047
  this.set_cursor(false, false);
13024
- if (~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13048
+ if (view &&
13049
+ ~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
13025
13050
  this.current_record && this.current_record.group) {
13026
13051
  var group = this.current_record.group;
13027
13052
  var record = this.current_record;
@@ -13044,7 +13069,7 @@ var Sao = {};
13044
13069
  this.current_record = this.group[0];
13045
13070
  }
13046
13071
  this.set_cursor(false, false);
13047
- return view.display();
13072
+ return view ? view.display() : jQuery.when();
13048
13073
  },
13049
13074
  get selected_records() {
13050
13075
  if (this.current_view) {
@@ -13080,7 +13105,8 @@ var Sao = {};
13080
13105
  });
13081
13106
  },
13082
13107
  default_row_activate: function() {
13083
- if ((this.current_view.view_type == 'tree') &&
13108
+ if (this.current_view &&
13109
+ (this.current_view.view_type == 'tree') &&
13084
13110
  (this.current_view.attributes.keyword_open == 1)) {
13085
13111
  var id = this.get_id();
13086
13112
  if (id) {
@@ -13107,7 +13133,8 @@ var Sao = {};
13107
13133
  default_ = true;
13108
13134
  }
13109
13135
  var prm = jQuery.when();
13110
- if (this.current_view.view_type == 'calendar') {
13136
+ if (this.current_view &&
13137
+ this.current_view.view_type == 'calendar') {
13111
13138
  var selected_date = this.current_view.get_selected_date();
13112
13139
  prm = this.switch_view('form', undefined, false);
13113
13140
  }
@@ -13118,7 +13145,7 @@ var Sao = {};
13118
13145
  prm = this.switch_view('form', undefined, false);
13119
13146
  }
13120
13147
  return prm.then(function() {
13121
- if (!this.current_view.editable) {
13148
+ if (!this.current_view || !this.current_view.editable) {
13122
13149
  return;
13123
13150
  }
13124
13151
  var group;
@@ -13199,19 +13226,22 @@ var Sao = {};
13199
13226
  save_current: function() {
13200
13227
  var current_record = this.current_record;
13201
13228
  if (!current_record) {
13202
- if ((this.current_view.view_type == 'tree') &&
13203
- this.group && this.group.length) {
13229
+ if (this.current_view &&
13230
+ (this.current_view.view_type == 'tree') &&
13231
+ this.group && this.group.length) {
13204
13232
  this.current_record = this.group[0];
13205
13233
  current_record = this.current_record;
13206
13234
  } else {
13207
13235
  return jQuery.when();
13208
13236
  }
13209
13237
  }
13210
- this.current_view.set_value();
13211
- var fields = this.current_view.get_fields();
13238
+ if (this.current_view) {
13239
+ this.current_view.set_value();
13240
+ var fields = this.current_view.get_fields();
13241
+ }
13212
13242
  var path = current_record.get_path(this.group);
13213
13243
  var prm = jQuery.Deferred();
13214
- if (this.current_view.view_type == 'tree') {
13244
+ if (this.current_view && (this.current_view.view_type == 'tree')) {
13215
13245
  prm = this.group.save().then(function() {
13216
13246
  return this.current_record;
13217
13247
  }.bind(this));
@@ -13219,7 +13249,7 @@ var Sao = {};
13219
13249
  prm = current_record.save().then(function() {
13220
13250
  return current_record;
13221
13251
  });
13222
- } else {
13252
+ } else if (this.current_view) {
13223
13253
  return this.current_view.display().then(function() {
13224
13254
  this.set_cursor();
13225
13255
  return jQuery.Deferred().reject();
@@ -13255,7 +13285,7 @@ var Sao = {};
13255
13285
  var test = function(record) {
13256
13286
  return (record.has_changed() || record.id < 0);
13257
13287
  };
13258
- if (this.current_view.view_type != 'tree') {
13288
+ if (this.current_view && (this.current_view.view_type != 'tree')) {
13259
13289
  if (this.current_record) {
13260
13290
  if (test(this.current_record)) {
13261
13291
  return true;
@@ -13266,20 +13296,24 @@ var Sao = {};
13266
13296
  return true;
13267
13297
  }
13268
13298
  }
13269
- if (this.current_view.modified) {
13299
+ if (this.current_view && this.current_view.modified) {
13270
13300
  return true;
13271
13301
  }
13272
13302
  return false;
13273
13303
  },
13274
13304
  unremove: function() {
13275
- var records = this.current_view.selected_records;
13276
- records.forEach(function(record) {
13277
- record.group.unremove(record);
13278
- });
13305
+ if (this.current_view) {
13306
+ var records = this.current_view.selected_records;
13307
+ records.forEach(function(record) {
13308
+ record.group.unremove(record);
13309
+ });
13310
+ }
13279
13311
  },
13280
13312
  remove: function(delete_, remove, force_remove, records) {
13281
13313
  var prm = jQuery.when();
13282
- records = records || this.current_view.selected_records;
13314
+ if (!records && this.current_view) {
13315
+ records = this.current_view.selected_records;
13316
+ }
13283
13317
  if (jQuery.isEmptyObject(records)) {
13284
13318
  return prm;
13285
13319
  }
@@ -13337,7 +13371,8 @@ var Sao = {};
13337
13371
  },
13338
13372
  copy: function() {
13339
13373
  var dfd = jQuery.Deferred();
13340
- var records = this.current_view.selected_records;
13374
+ var records = (
13375
+ this.current_view ? this.current_view.selected_records : []);
13341
13376
  this.model.copy(records, this.context)
13342
13377
  .then(function(new_ids) {
13343
13378
  this.group.load(new_ids, false, this.new_position);
@@ -13522,14 +13557,18 @@ var Sao = {};
13522
13557
  if (!this.current_record) {
13523
13558
  return null;
13524
13559
  }
13525
- this.current_view.set_value();
13560
+ if (this.current_view) {
13561
+ this.current_view.set_value();
13562
+ }
13526
13563
  return this.current_record.get();
13527
13564
  },
13528
13565
  get_on_change_value: function() {
13529
13566
  if (!this.current_record) {
13530
13567
  return null;
13531
13568
  }
13532
- this.current_view.set_value();
13569
+ if (this.current_view) {
13570
+ this.current_view.set_value();
13571
+ }
13533
13572
  return this.current_record.get_on_change_value();
13534
13573
  },
13535
13574
  reload: function(ids, written) {
@@ -13542,15 +13581,17 @@ var Sao = {};
13542
13581
  promises.push(this.group.parent.root_parent.reload());
13543
13582
  }
13544
13583
  return jQuery.when.apply(jQuery, promises).then(function() {
13545
- this.display();
13584
+ return this.display();
13546
13585
  }.bind(this));
13547
13586
  },
13548
13587
  get_buttons: function() {
13549
- var selected_records = this.current_view.selected_records;
13588
+ var selected_records = (
13589
+ this.current_view ? this.current_view.selected_records : []);
13550
13590
  if (jQuery.isEmptyObject(selected_records)) {
13551
13591
  return [];
13552
13592
  }
13553
- var buttons = this.current_view.get_buttons();
13593
+ var buttons = (
13594
+ this.current_view ? this.current_view.get_buttons() : []);
13554
13595
  selected_records.forEach(function(record) {
13555
13596
  buttons = buttons.filter(function(button) {
13556
13597
  if (button.attributes.type === 'instance') {
@@ -13580,9 +13621,11 @@ var Sao = {};
13580
13621
  }.bind(this));
13581
13622
  };
13582
13623
 
13583
- var selected_records = this.current_view.selected_records;
13584
- this.current_view.set_value();
13585
- var fields = this.current_view.get_fields();
13624
+ if (this.current_view) {
13625
+ var selected_records = this.current_view.selected_records;
13626
+ this.current_view.set_value();
13627
+ var fields = this.current_view.get_fields();
13628
+ }
13586
13629
 
13587
13630
  var prms = [];
13588
13631
  var reset_state = function(record) {
@@ -13681,7 +13724,8 @@ var Sao = {};
13681
13724
  } else if (action.startsWith('switch')) {
13682
13725
  this.switch_view.apply(this, action.split(' ', 3).slice(1));
13683
13726
  } else if (action == 'reload') {
13684
- if (~['tree', 'graph', 'calendar'].indexOf(this.current_view.view_type) &&
13727
+ if (this.current_view &&
13728
+ ~['tree', 'graph', 'calendar'].indexOf(this.current_view.view_type) &&
13685
13729
  !this.group.parent) {
13686
13730
  this.search_filter();
13687
13731
  }
@@ -13720,7 +13764,7 @@ var Sao = {};
13720
13764
  var path = ['model', this.model_name];
13721
13765
  var view_ids = this.views.map(
13722
13766
  function(v) {return v.view_id;}).concat(this.view_ids);
13723
- if (this.current_view.view_type != 'form') {
13767
+ if (this.current_view && (this.current_view.view_type != 'form')) {
13724
13768
  var search_value;
13725
13769
  if (this.attributes.search_value) {
13726
13770
  search_value = this.attributes.search_value;
@@ -13733,8 +13777,10 @@ var Sao = {};
13733
13777
  }
13734
13778
  } else if (this.current_record && (this.current_record.id > -1)) {
13735
13779
  path.push(this.current_record.id);
13736
- var i = view_ids.indexOf(this.current_view.view_id);
13737
- view_ids = view_ids.slice(i).concat(view_ids.slice(0, i));
13780
+ if (this.current_view) {
13781
+ var i = view_ids.indexOf(this.current_view.view_id);
13782
+ view_ids = view_ids.slice(i).concat(view_ids.slice(0, i));
13783
+ }
13738
13784
  }
13739
13785
  if (!jQuery.isEmptyObject(view_ids)) {
13740
13786
  query_string.push(['views', dumps(view_ids)]);
@@ -13818,6 +13864,9 @@ var Sao = {};
13818
13864
  set_tree_state: function() {
13819
13865
  var parent_, state, state_prm, tree_state_model;
13820
13866
  var view = this.current_view;
13867
+ if (!view) {
13868
+ return jQuery.when();
13869
+ }
13821
13870
  if (!~['tree', 'form'].indexOf(view.view_type)) {
13822
13871
  return jQuery.when();
13823
13872
  }
@@ -20843,8 +20892,7 @@ function eval_pyson(value){
20843
20892
  collapse_children: function() {
20844
20893
  this.rows.forEach(function(row, pos, rows) {
20845
20894
  row.collapse_children();
20846
- var node = row.el[0];
20847
- node.parentNode.removeChild(node);
20895
+ row.el.remove();
20848
20896
  });
20849
20897
  this.rows = [];
20850
20898
  },
@@ -23757,7 +23805,7 @@ function eval_pyson(value){
23757
23805
  record._changed.id = added;
23758
23806
  }
23759
23807
  } else {
23760
- result = response_id != 'RESPONSE_CANCEL';
23808
+ result = (response_id != 'RESPONSE_CANCEL') && !readonly;
23761
23809
  }
23762
23810
  (cancel_prm || jQuery.when()).then(function() {
23763
23811
  this.callback(result);