@@ -14,6 +14,9 @@ const {onWillDestroy} = owl;
1414class CustomExportDataDialog extends ExportDataDialog {
1515 setup ( ) {
1616 super . setup ( ) ;
17+ Object . assign ( this . state , {
18+ showApplyTemplatetButton : false ,
19+ } ) ;
1720 this . title = this . env . _t ( "Select Data for Indexing" ) ;
1821 // We hack the current model from props obj to avoid patching other methods
1922 this . swapResModel = this . props . root . resModel ;
@@ -26,6 +29,29 @@ class CustomExportDataDialog extends ExportDataDialog {
2629 this . props . root . resModel = this . swapResModel ;
2730 } ) ;
2831 }
32+ async onChangeExportList ( ev ) {
33+ this . loadExportList ( ev . target . value ) ;
34+ // Show button only when there is selected saved template with different id
35+ if (
36+ this . state . templateId === this . props . context . exporter_id [ 0 ] ||
37+ this . state . templateId === "new_template"
38+ ) {
39+ this . state . showApplyTemplatetButton = false ;
40+ } else {
41+ this . state . showApplyTemplatetButton = true ;
42+ }
43+ }
44+ onQuickOverlap ( templ ) {
45+ this . props . context . overlap ( templ ) ;
46+ }
47+ onClickApplyTemplatetButton ( ) {
48+ const arrayOfTemplates = this . templates . map ( ( { id, name} ) => [ id , name ] ) ;
49+ const templ = arrayOfTemplates . find (
50+ ( subArray ) => subArray [ 0 ] === this . state . templateId
51+ ) ;
52+ this . onQuickOverlap ( templ ) ;
53+ this . props . close ( ) ;
54+ }
2955 async onUpdateExportTemplate ( ) {
3056 const oldRec = await this . orm . read (
3157 "ir.exports" ,
@@ -80,6 +106,11 @@ class IrExportWidget extends Many2OneField {
80106 this . rpc = useService ( "rpc" ) ;
81107 this . orm = useService ( "orm" ) ;
82108 this . dialogService = useService ( "dialog" ) ;
109+ this . quickOverlap = ( templ ) => {
110+ if ( templ && templ [ 0 ] && templ [ 1 ] ) {
111+ return this . props . update ( templ ) ;
112+ }
113+ } ;
83114 }
84115 async downloadExport ( ) {
85116 return true ;
@@ -97,7 +128,10 @@ class IrExportWidget extends Many2OneField {
97128 context : {
98129 ...this . props . record . context ,
99130 resModel : this . props . record . data . model_name ,
100- exporter_id : this . props . record . data . exporter_id ,
131+ exporter_id : this . props . value ,
132+ overlap : ( templ ) => {
133+ this . quickOverlap ( templ ) ;
134+ } ,
101135 } ,
102136 defaultExportList : [ ] ,
103137 download : this . downloadExport . bind ( this ) ,
0 commit comments