tryton-sao 7.0.9 → 7.0.11
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 +10 -0
- package/dist/tryton-sao.js +111 -57
- package/dist/tryton-sao.min.js +2 -2
- package/package.json +1 -1
- package/src/common.js +26 -9
- package/src/pyson.js +2 -2
- package/src/sao.js +1 -1
- package/src/screen.js +72 -39
- package/src/tab.js +4 -2
- package/src/view/tree.js +5 -3
- package/src/window.js +1 -1
- package/tests/sao.js +18 -0
package/CHANGELOG
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
Version 7.0.11 - 2024-05-01
|
|
3
|
+
---------------------------
|
|
4
|
+
* Bug fixes (see mercurial logs for details)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Version 7.0.10 - 2024-04-17
|
|
8
|
+
---------------------------
|
|
9
|
+
* Bug fixes (see mercurial logs for details)
|
|
10
|
+
|
|
11
|
+
|
|
2
12
|
Version 7.0.9 - 2024-04-04
|
|
3
13
|
--------------------------
|
|
4
14
|
* Bug fixes (see mercurial logs for details)
|
package/dist/tryton-sao.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
/* eslint-disable no-redeclare */
|
|
5
5
|
var Sao = {
|
|
6
|
-
__version__: '7.0.
|
|
6
|
+
__version__: '7.0.11',
|
|
7
7
|
};
|
|
8
8
|
/* eslint-enable no-redeclare */
|
|
9
9
|
|
|
@@ -1815,7 +1815,7 @@ var Sao = {
|
|
|
1815
1815
|
value = new Sao.PYSON.Bool(value);
|
|
1816
1816
|
}
|
|
1817
1817
|
} else if (typeof value != 'boolean') {
|
|
1818
|
-
value = Sao.PYSON.Bool(value);
|
|
1818
|
+
value = new Sao.PYSON.Bool(value);
|
|
1819
1819
|
}
|
|
1820
1820
|
this._value = value;
|
|
1821
1821
|
},
|
|
@@ -1834,7 +1834,7 @@ var Sao = {
|
|
|
1834
1834
|
});
|
|
1835
1835
|
|
|
1836
1836
|
Sao.PYSON.Not.eval_ = function(value, context) {
|
|
1837
|
-
return !value
|
|
1837
|
+
return !Sao.PYSON.Bool.eval_(value, context);
|
|
1838
1838
|
};
|
|
1839
1839
|
Sao.PYSON.Not.init_from_object = function(obj) {
|
|
1840
1840
|
return new Sao.PYSON.Not(obj.v);
|
|
@@ -3663,10 +3663,14 @@ var Sao = {
|
|
|
3663
3663
|
if (!refresh) {
|
|
3664
3664
|
this._access = {};
|
|
3665
3665
|
}
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3666
|
+
try {
|
|
3667
|
+
this._models = Sao.rpc({
|
|
3668
|
+
'method': 'model.ir.model.list_models',
|
|
3669
|
+
'params': [{}]
|
|
3670
|
+
}, Sao.Session.current_session, false);
|
|
3671
|
+
} catch(e) {
|
|
3672
|
+
Sao.Logger.error("Unable to get model list.");
|
|
3673
|
+
}
|
|
3670
3674
|
},
|
|
3671
3675
|
get: function(model) {
|
|
3672
3676
|
if (this._access[model] !== undefined) {
|
|
@@ -3680,10 +3684,23 @@ var Sao = {
|
|
|
3680
3684
|
var to_load = this._models.slice(
|
|
3681
3685
|
Math.max(0, idx - Math.floor(this.batchnum / 2)),
|
|
3682
3686
|
idx + Math.floor(this.batchnum / 2));
|
|
3683
|
-
var access
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
+
var access;
|
|
3688
|
+
try {
|
|
3689
|
+
access = Sao.rpc({
|
|
3690
|
+
'method': 'model.ir.model.access.get_access',
|
|
3691
|
+
'params': [to_load, {}]
|
|
3692
|
+
}, Sao.Session.current_session, false);
|
|
3693
|
+
} catch(e) {
|
|
3694
|
+
Sao.Logger.error(`Unable to get access for ${model}.`);
|
|
3695
|
+
access = {
|
|
3696
|
+
model: {
|
|
3697
|
+
'read': true,
|
|
3698
|
+
'write': false,
|
|
3699
|
+
'create': false,
|
|
3700
|
+
'delete': false,
|
|
3701
|
+
},
|
|
3702
|
+
};
|
|
3703
|
+
}
|
|
3687
3704
|
this._access = jQuery.extend(this._access, access);
|
|
3688
3705
|
return this._access[model];
|
|
3689
3706
|
}
|
|
@@ -7060,7 +7077,7 @@ var Sao = {
|
|
|
7060
7077
|
});
|
|
7061
7078
|
},
|
|
7062
7079
|
function() {
|
|
7063
|
-
Sao.Logger.
|
|
7080
|
+
Sao.Logger.warn(
|
|
7064
7081
|
"Unable to search for completion of %s", model);
|
|
7065
7082
|
});
|
|
7066
7083
|
};
|
|
@@ -10992,8 +11009,10 @@ var Sao = {
|
|
|
10992
11009
|
attributes.res_id = [attributes.res_id];
|
|
10993
11010
|
}
|
|
10994
11011
|
screen.load(attributes.res_id);
|
|
10995
|
-
|
|
10996
|
-
|
|
11012
|
+
if (attributes.res_id.length) {
|
|
11013
|
+
screen.current_record = screen.group.get(
|
|
11014
|
+
attributes.res_id[0]);
|
|
11015
|
+
}
|
|
10997
11016
|
screen.display();
|
|
10998
11017
|
} else {
|
|
10999
11018
|
if (screen.current_view.view_type == 'form') {
|
|
@@ -13479,13 +13498,15 @@ var Sao = {
|
|
|
13479
13498
|
},
|
|
13480
13499
|
load: function(ids, set_cursor=true, modified=false, position=-1) {
|
|
13481
13500
|
this.group.load(ids, modified, position);
|
|
13482
|
-
this.current_view
|
|
13501
|
+
if (this.current_view) {
|
|
13502
|
+
this.current_view.reset();
|
|
13503
|
+
}
|
|
13483
13504
|
this.current_record = null;
|
|
13484
13505
|
return this.display(set_cursor);
|
|
13485
13506
|
},
|
|
13486
13507
|
display: function(set_cursor) {
|
|
13487
13508
|
var deferreds = [];
|
|
13488
|
-
if (this.views) {
|
|
13509
|
+
if (this.views && this.current_view) {
|
|
13489
13510
|
var search_prm = this.search_active(
|
|
13490
13511
|
~['tree', 'graph', 'calendar'].indexOf(
|
|
13491
13512
|
this.current_view.view_type));
|
|
@@ -13521,8 +13542,9 @@ var Sao = {
|
|
|
13521
13542
|
},
|
|
13522
13543
|
_get_next_record: function() {
|
|
13523
13544
|
var view = this.current_view;
|
|
13524
|
-
if (
|
|
13525
|
-
|
|
13545
|
+
if (view &&
|
|
13546
|
+
~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
|
|
13547
|
+
this.current_record && this.current_record.group) {
|
|
13526
13548
|
var group = this.current_record.group;
|
|
13527
13549
|
var record = this.current_record;
|
|
13528
13550
|
while (group) {
|
|
@@ -13551,16 +13573,19 @@ var Sao = {
|
|
|
13551
13573
|
},
|
|
13552
13574
|
display_next: function() {
|
|
13553
13575
|
var view = this.current_view;
|
|
13554
|
-
view
|
|
13576
|
+
if (view) {
|
|
13577
|
+
view.set_value();
|
|
13578
|
+
}
|
|
13555
13579
|
this.set_cursor(false, false);
|
|
13556
13580
|
this.current_record = this._get_next_record();
|
|
13557
13581
|
this.set_cursor(false, false);
|
|
13558
|
-
return view.display();
|
|
13582
|
+
return view ? view.display() : jQuery.when();
|
|
13559
13583
|
},
|
|
13560
13584
|
_get_previous_record: function() {
|
|
13561
13585
|
var view = this.current_view;
|
|
13562
|
-
if (
|
|
13563
|
-
|
|
13586
|
+
if (view &&
|
|
13587
|
+
~['tree', 'form', 'list-form'].indexOf(view.view_type) &&
|
|
13588
|
+
this.current_record && this.current_record.group) {
|
|
13564
13589
|
var group = this.current_record.group;
|
|
13565
13590
|
var record = this.current_record;
|
|
13566
13591
|
while (group) {
|
|
@@ -13589,11 +13614,13 @@ var Sao = {
|
|
|
13589
13614
|
},
|
|
13590
13615
|
display_previous: function() {
|
|
13591
13616
|
var view = this.current_view;
|
|
13592
|
-
view
|
|
13617
|
+
if (view) {
|
|
13618
|
+
view.set_value();
|
|
13619
|
+
}
|
|
13593
13620
|
this.set_cursor(false, false);
|
|
13594
13621
|
this.current_record = this._get_previous_record();
|
|
13595
13622
|
this.set_cursor(false, false);
|
|
13596
|
-
return view.display();
|
|
13623
|
+
return view ? view.display() : jQuery.when();
|
|
13597
13624
|
},
|
|
13598
13625
|
get selected_records() {
|
|
13599
13626
|
if (this.current_view) {
|
|
@@ -13631,8 +13658,9 @@ var Sao = {
|
|
|
13631
13658
|
});
|
|
13632
13659
|
},
|
|
13633
13660
|
default_row_activate: function() {
|
|
13634
|
-
if (
|
|
13635
|
-
|
|
13661
|
+
if (this.current_view &&
|
|
13662
|
+
(this.current_view.view_type == 'tree') &&
|
|
13663
|
+
(this.current_view.attributes.keyword_open == 1)) {
|
|
13636
13664
|
const id = this.get_id();
|
|
13637
13665
|
if (id) {
|
|
13638
13666
|
Sao.Action.exec_keyword('tree_open', {
|
|
@@ -13655,14 +13683,15 @@ var Sao = {
|
|
|
13655
13683
|
new_: function(default_=true, defaults=null) {
|
|
13656
13684
|
var previous_view = this.current_view;
|
|
13657
13685
|
var prm = jQuery.when();
|
|
13658
|
-
if (this.current_view
|
|
13686
|
+
if (this.current_view &&
|
|
13687
|
+
this.current_view.view_type == 'calendar') {
|
|
13659
13688
|
var selected_date = this.current_view.get_selected_date();
|
|
13660
13689
|
}
|
|
13661
13690
|
if (this.current_view && !this.current_view.creatable) {
|
|
13662
13691
|
prm = this.switch_view('form', undefined, true, false);
|
|
13663
13692
|
}
|
|
13664
13693
|
return prm.then(() => {
|
|
13665
|
-
if (!this.current_view.editable) {
|
|
13694
|
+
if (!this.current_view || !this.current_view.editable) {
|
|
13666
13695
|
return;
|
|
13667
13696
|
}
|
|
13668
13697
|
var group;
|
|
@@ -13743,23 +13772,26 @@ var Sao = {
|
|
|
13743
13772
|
save_current: function() {
|
|
13744
13773
|
var current_record = this.current_record;
|
|
13745
13774
|
if (!current_record) {
|
|
13746
|
-
if (
|
|
13747
|
-
|
|
13775
|
+
if (this.current_view &&
|
|
13776
|
+
(this.current_view.view_type == 'tree') &&
|
|
13777
|
+
this.group && this.group.length) {
|
|
13748
13778
|
this.current_record = this.group[0];
|
|
13749
13779
|
current_record = this.current_record;
|
|
13750
13780
|
} else {
|
|
13751
13781
|
return jQuery.when();
|
|
13752
13782
|
}
|
|
13753
13783
|
}
|
|
13754
|
-
this.current_view
|
|
13755
|
-
|
|
13784
|
+
if (this.current_view) {
|
|
13785
|
+
this.current_view.set_value();
|
|
13786
|
+
var fields = this.current_view.get_fields();
|
|
13787
|
+
}
|
|
13756
13788
|
var path = current_record.get_path(this.group);
|
|
13757
13789
|
var prm = jQuery.Deferred();
|
|
13758
|
-
if (this.current_view.view_type == 'tree') {
|
|
13790
|
+
if (this.current_view && (this.current_view.view_type == 'tree')) {
|
|
13759
13791
|
prm = this.group.save().then(() => this.current_record);
|
|
13760
13792
|
} else if (current_record.validate(fields, null, null, true)) {
|
|
13761
13793
|
prm = current_record.save().then(() => current_record);
|
|
13762
|
-
} else {
|
|
13794
|
+
} else if (this.current_view) {
|
|
13763
13795
|
return this.current_view.display().then(() => {
|
|
13764
13796
|
this.set_cursor();
|
|
13765
13797
|
return jQuery.Deferred().reject();
|
|
@@ -13793,7 +13825,7 @@ var Sao = {
|
|
|
13793
13825
|
var test = function(record) {
|
|
13794
13826
|
return (record.modified || record.id < 0);
|
|
13795
13827
|
};
|
|
13796
|
-
if (this.current_view.view_type != 'tree') {
|
|
13828
|
+
if (this.current_view && (this.current_view.view_type != 'tree')) {
|
|
13797
13829
|
if (this.current_record) {
|
|
13798
13830
|
if (test(this.current_record)) {
|
|
13799
13831
|
return true;
|
|
@@ -13804,20 +13836,24 @@ var Sao = {
|
|
|
13804
13836
|
return true;
|
|
13805
13837
|
}
|
|
13806
13838
|
}
|
|
13807
|
-
if (this.current_view.modified) {
|
|
13839
|
+
if (this.current_view && this.current_view.modified) {
|
|
13808
13840
|
return true;
|
|
13809
13841
|
}
|
|
13810
13842
|
return false;
|
|
13811
13843
|
},
|
|
13812
13844
|
unremove: function() {
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
|
|
13845
|
+
if (this.current_view) {
|
|
13846
|
+
var records = this.current_view.selected_records;
|
|
13847
|
+
for (const record of records) {
|
|
13848
|
+
record.group.unremove(record);
|
|
13849
|
+
}
|
|
13816
13850
|
}
|
|
13817
13851
|
},
|
|
13818
13852
|
remove: function(delete_, remove, force_remove, records) {
|
|
13819
13853
|
var prm = jQuery.when();
|
|
13820
|
-
|
|
13854
|
+
if (!records && this.current_view) {
|
|
13855
|
+
records = this.current_view.selected_records;
|
|
13856
|
+
}
|
|
13821
13857
|
if (jQuery.isEmptyObject(records)) {
|
|
13822
13858
|
return prm;
|
|
13823
13859
|
}
|
|
@@ -13858,7 +13894,8 @@ var Sao = {
|
|
|
13858
13894
|
},
|
|
13859
13895
|
copy: function() {
|
|
13860
13896
|
var dfd = jQuery.Deferred();
|
|
13861
|
-
var records =
|
|
13897
|
+
var records = (
|
|
13898
|
+
this.current_view ? this.current_view.selected_records : []);
|
|
13862
13899
|
this.model.copy(records, this.context)
|
|
13863
13900
|
.then(new_ids => {
|
|
13864
13901
|
this.group.load(new_ids, false, this.new_position);
|
|
@@ -14039,14 +14076,18 @@ var Sao = {
|
|
|
14039
14076
|
if (!this.current_record) {
|
|
14040
14077
|
return null;
|
|
14041
14078
|
}
|
|
14042
|
-
this.current_view
|
|
14079
|
+
if (this.current_view) {
|
|
14080
|
+
this.current_view.set_value();
|
|
14081
|
+
}
|
|
14043
14082
|
return this.current_record.get();
|
|
14044
14083
|
},
|
|
14045
14084
|
get_on_change_value: function() {
|
|
14046
14085
|
if (!this.current_record) {
|
|
14047
14086
|
return null;
|
|
14048
14087
|
}
|
|
14049
|
-
this.current_view
|
|
14088
|
+
if (this.current_view) {
|
|
14089
|
+
this.current_view.set_value();
|
|
14090
|
+
}
|
|
14050
14091
|
return this.current_record.get_on_change_value();
|
|
14051
14092
|
},
|
|
14052
14093
|
reload: function(ids, written) {
|
|
@@ -14059,15 +14100,17 @@ var Sao = {
|
|
|
14059
14100
|
promises.push(this.group.parent.root_parent.reload());
|
|
14060
14101
|
}
|
|
14061
14102
|
return jQuery.when.apply(jQuery, promises).then(() => {
|
|
14062
|
-
this.display();
|
|
14103
|
+
return this.display();
|
|
14063
14104
|
});
|
|
14064
14105
|
},
|
|
14065
14106
|
get_buttons: function() {
|
|
14066
|
-
var selected_records =
|
|
14107
|
+
var selected_records = (
|
|
14108
|
+
this.current_view ? this.current_view.selected_records : []);
|
|
14067
14109
|
if (jQuery.isEmptyObject(selected_records)) {
|
|
14068
14110
|
return [];
|
|
14069
14111
|
}
|
|
14070
|
-
var buttons =
|
|
14112
|
+
var buttons = (
|
|
14113
|
+
this.current_view ? this.current_view.get_buttons() : []);
|
|
14071
14114
|
for (const record of selected_records) {
|
|
14072
14115
|
buttons = buttons.filter(function(button) {
|
|
14073
14116
|
if (button.attributes.type === 'instance') {
|
|
@@ -14094,12 +14137,15 @@ var Sao = {
|
|
|
14094
14137
|
ids: ids
|
|
14095
14138
|
}, null, this.context, true);
|
|
14096
14139
|
}
|
|
14140
|
+
this.record_saved();
|
|
14097
14141
|
});
|
|
14098
14142
|
};
|
|
14099
14143
|
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14144
|
+
if (this.current_view) {
|
|
14145
|
+
var selected_records = this.current_view.selected_records;
|
|
14146
|
+
this.current_view.set_value();
|
|
14147
|
+
var fields = this.current_view.get_fields();
|
|
14148
|
+
}
|
|
14103
14149
|
|
|
14104
14150
|
var prms = [];
|
|
14105
14151
|
const reset_state = record => {
|
|
@@ -14191,7 +14237,8 @@ var Sao = {
|
|
|
14191
14237
|
} else if (action.startsWith('switch')) {
|
|
14192
14238
|
this.switch_view.apply(this, action.split(' ', 3).slice(1));
|
|
14193
14239
|
} else if (action == 'reload') {
|
|
14194
|
-
if (
|
|
14240
|
+
if (this.current_view &&
|
|
14241
|
+
~['tree', 'graph', 'calendar'].indexOf(this.current_view.view_type) &&
|
|
14195
14242
|
!this.group.parent) {
|
|
14196
14243
|
this.search_filter();
|
|
14197
14244
|
}
|
|
@@ -14230,7 +14277,7 @@ var Sao = {
|
|
|
14230
14277
|
var path = ['model', this.model_name];
|
|
14231
14278
|
var view_ids = this.views.map(
|
|
14232
14279
|
function(v) {return v.view_id;}).concat(this.view_ids);
|
|
14233
|
-
if (this.current_view.view_type != 'form') {
|
|
14280
|
+
if (this.current_view && (this.current_view.view_type != 'form')) {
|
|
14234
14281
|
var search_value;
|
|
14235
14282
|
if (this.attributes.search_value) {
|
|
14236
14283
|
search_value = this.attributes.search_value;
|
|
@@ -14243,8 +14290,10 @@ var Sao = {
|
|
|
14243
14290
|
}
|
|
14244
14291
|
} else if (this.current_record && (this.current_record.id > -1)) {
|
|
14245
14292
|
path.push(this.current_record.id);
|
|
14246
|
-
|
|
14247
|
-
|
|
14293
|
+
if (this.current_view) {
|
|
14294
|
+
var i = view_ids.indexOf(this.current_view.view_id);
|
|
14295
|
+
view_ids = view_ids.slice(i).concat(view_ids.slice(0, i));
|
|
14296
|
+
}
|
|
14248
14297
|
}
|
|
14249
14298
|
if (!jQuery.isEmptyObject(view_ids)) {
|
|
14250
14299
|
query_string.push(['views', dumps(view_ids)]);
|
|
@@ -14338,6 +14387,9 @@ var Sao = {
|
|
|
14338
14387
|
set_tree_state: function() {
|
|
14339
14388
|
var parent_, state, state_prm, tree_state_model;
|
|
14340
14389
|
var view = this.current_view;
|
|
14390
|
+
if (!view) {
|
|
14391
|
+
return jQuery.when();
|
|
14392
|
+
}
|
|
14341
14393
|
if (!~['tree', 'form', 'list-form'].indexOf(view.view_type)) {
|
|
14342
14394
|
return jQuery.when();
|
|
14343
14395
|
}
|
|
@@ -20204,7 +20256,10 @@ function eval_pyson(value){
|
|
|
20204
20256
|
this.columns = [];
|
|
20205
20257
|
this.selection_mode = (screen.attributes.selection_mode ||
|
|
20206
20258
|
Sao.common.SELECTION_MULTIPLE);
|
|
20207
|
-
this.el = jQuery('<div/>')
|
|
20259
|
+
this.el = jQuery('<div/>')
|
|
20260
|
+
// Prevent Chrome based browser to compute a min-content
|
|
20261
|
+
// such that only this table has scrollbar if needed
|
|
20262
|
+
.css('display', 'grid');
|
|
20208
20263
|
this.scrollbar = jQuery('<div/>')
|
|
20209
20264
|
.appendTo(jQuery('<div/>', {
|
|
20210
20265
|
'class': 'scrollbar responsive',
|
|
@@ -21888,8 +21943,7 @@ function eval_pyson(value){
|
|
|
21888
21943
|
collapse_children: function() {
|
|
21889
21944
|
for (const row of this.rows) {
|
|
21890
21945
|
row.collapse_children();
|
|
21891
|
-
|
|
21892
|
-
node.parentNode.removeChild(node);
|
|
21946
|
+
row.el.remove();
|
|
21893
21947
|
}
|
|
21894
21948
|
this.rows = [];
|
|
21895
21949
|
},
|
|
@@ -25102,7 +25156,7 @@ function eval_pyson(value){
|
|
|
25102
25156
|
record.modified_fields.id = added;
|
|
25103
25157
|
}
|
|
25104
25158
|
} else {
|
|
25105
|
-
result = response_id != 'RESPONSE_CANCEL';
|
|
25159
|
+
result = (response_id != 'RESPONSE_CANCEL') && !readonly;
|
|
25106
25160
|
}
|
|
25107
25161
|
(cancel_prm || jQuery.when()).then(() => {
|
|
25108
25162
|
if (this.callback) {
|