summaryrefslogtreecommitdiff
path: root/addons/base_import/static/src/xml/base_import.xml
blob: 4bee0203c30e3e930504bfaae3253d536272de62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<templates>
    <t t-name="base_import.ImportMenu" owl="1">
        <li class="o_menu_item o_import_menu" role="menuitem">
            <button type="button" class="dropdown-item" t-on-click="_onImportClick">
                Import records
            </button>
        </li>
    </t>

    <t t-name="ImportView">
        <t t-set="_id" t-value="_.uniqueId('export')"/>
        <form action="" method="post" enctype="multipart/form-data" class="oe_import">
            <input type="hidden" name="csrf_token" t-att-value="csrf_token"/>
            <input type="hidden" name="import_id"/>
            <div class="oe_import_box d-none">
                <input accept=".csv, .xls, .xlsx, .xlsm, .ods" t-attf-id="file_#{_id}"
                      name="file" class="oe_import_file" type="file" style="display:none;"/>
                <div class="oe_import_with_file row">
                    <a href="#" class="oe_import_toggle col-sm-12">
                        Formatting Options…</a>
                        <div class="row col-sm-12">
                            <div class="oe_import_toggled oe_import_options js_import_options col-md-6 col-lg-4">
                                <p t-foreach="widget.opts" t-as="option">
                                    <!-- no @name, avoid submission when file_update called -->
                                    <label t-attf-for="#{option.name}_#{_id}">
                                        <t t-esc="option.label"/></label>
                                    <input t-attf-id="#{option.name}_#{_id}"
                                           t-attf-class="oe_import_#{option.name}"
                                           style="width: 50%;"
                                           t-att-value="option.value"/>
                                </p>
                            </div>
                            <div t-foreach="[widget.parse_opts_formats, widget.parse_opts_separators]" t-as="options" class="oe_import_toggled oe_import_options col-md-6 col-lg-4">
                                <p t-foreach="options" t-as="option">
                                    <!-- no @name, avoid submission when file_update called -->
                                    <label t-attf-for="#{option.name}_#{_id}">
                                        <t t-esc="option.label"/></label>
                                    <input t-attf-id="#{option.name}_#{_id}"
                                           t-attf-class="oe_import_#{option.name}"
                                           style="width: 50%;"
                                           t-att-value="option.value"/>
                                </p>
                            </div>
                        </div>
                </div>
            </div>
            <div class="o_import_batch_alert alert alert-warning d-none">
                Due to its large size, the file will be imported by batches.
            </div>
            <div class="o_import_partial_alert alert alert-warning d-none">
                Click 'Resume' to proceed with the import, resuming at line
                <span class="o_import_partial_count">0</span>.<br/>
                You can test or reload your file before resuming the import.
            </div>

            <div class="oe_import_with_file d-none">
                <h2>Map your columns to import</h2>
                <div class="oe_import_debug_options">
                    <div title="If the model uses openchatter, history tracking will set up subscriptions and send notifications during the import, but lead to a slower import." class="oe_import_debug_option">
                        <input type="checkbox" id="oe_import_tracking"/>
                        <label for="oe_import_tracking">
                            Track history during import
                        </label>
                    </div>

                    <div class="oe_import_has_multiple_sheets js_import_options">
                        <label for="oe_import_sheet">Selected Sheet:</label>
                        <input class="oe_import_sheet" id="oe_import_sheet"/>
                    </div>

                    <div>
                        <input type="checkbox" class="oe_import_has_header"
                               id="oe_import_has_header" checked="checked"/>
                        <label for="oe_import_has_header">The first row
                         contains the label of the column</label>
                    </div>
                    <div class="js_import_options oe_import_debug_option oe_import_batch_limit">
                        <label for="oe_import_batch_limit">Batch limit</label>
                        <input id="oe_import_batch_limit" value="2000"/>
                    </div>
                    <div class="js_import_options oe_import_debug_option" title="Warning: ignores the labels line, empty lines and
                            lines composed only of empty cells">
                        <label for="oe_import_row_start">Start at line</label>
                        <input id="oe_import_row_start" value="1"/>
                    </div>
                    <div class="oe_import_debug_option">
                        <input type="checkbox" class="oe_import_advanced_mode" checked="checked"
                               id="oe_import_advanced_mode"/>
                        <label for="oe_import_advanced_mode">Show fields of relation fields (advanced)</label>
                    </div>
                </div>
                <p class="oe_import_noheaders text-muted">If the file contains
                the column names, Odoo can try auto-detecting the
                field corresponding to the column. This makes imports
                simpler especially when the file has many columns.</p>

                <div class="oe_import_error_report"></div>
                <div class="table-responsive">
                    <table class="table-striped table-bordered oe_import_grid bg-white" />
                </div>
                <h6 class="oe_padding">This is a preview of the first 10 rows of your file</h6>
            </div>
            <div class="o_view_nocontent">
                <div class="o_nocontent_help">
                    <p class="o_view_nocontent_smiling_face">
                        Select a CSV or Excel file to import.
                    </p>
                    <p>
                        Excel files are recommended as fields formatting is automatic.
                    </p>
                    <div class="mt16 mb4">Need Help?</div>
                    <div t-foreach="widget.importTemplates" t-as="template">
                        <a t-att-href="template.template" aria-label="Download" title="Download">
                            <i class="fa fa-download"/> <span><t t-esc="template.label"/></span>
                        </a>
                    </div>
                    <a href="https://www.odoo.com/documentation/14.0/applications/general/base_import/import_faq.html" target="new">Import FAQ</a>
                </div>
            </div>
        </form>
    </t>

    <t t-name="ImportView.buttons">
        <button type="button" class="btn btn-primary o_import_import o_import_import_full d-none">Import</button>
        <button type="button" class="btn btn-primary o_import_import o_import_import_partial d-none">Resume</button>
        <button type="button" class="btn btn-secondary o_import_validate d-none">Test</button>
        <button type="button" class="btn btn-primary oe_import_file">Load File</button>
        <button type="button" class="btn btn-secondary o_import_cancel">Cancel</button>
    </t>

    <t t-name="ImportView.create_record_option">
        <div class="mt4">
            <label title="Creates new records if they can't be found (instead of failing to import). Note that the value in the column will be used as the new record's 'name', and assumes this is sufficient to create the record.">
                <input type="checkbox" class="o_import_create_option"/>
                Create if doesn't exist
            </label>
        </div>
    </t>

    <t t-name="ImportView.preview">
        <thead>
            <tr t-if="headers" class="oe_import_grid-header">
                <td t-foreach="headers" t-as="header" class="oe_import_grid-cell"
                    ><span class="o_import_header_name o_single_line_text" t-att-title="header"><t t-esc="header"/></span></td>
            </tr>
            <tr class="oe_import_fields">
                <!-- Iterate on first row to ensure we have all columns -->
                <td t-foreach="preview[0]" t-as="column">
                    <input class="oe_import_match_field"/>
                </td>
            </tr>
        </thead>
        <tbody>
            <tr t-foreach="preview" t-as="row" class="oe_import_grid-row">
                <td t-foreach="row" t-as="cell" class="oe_import_grid-cell">
                    <!-- content can be displayed on several lines if it contains whitespaces -->
                    <!-- in that case, we only display the 120 first characters -->
                    <!-- otherwise, we let the text-overflow: ellipsis do the job -->
                    <t t-set="multiline" t-value="cell.includes(' ')"/>
                    <t t-set="content" t-value="(multiline &amp;&amp; cell.length &gt; 120) ? (cell.substring(0, 120) + '...') : cell"/>
                    <span t-attf-class="#{multiline ? 'o_multi_line_text' : 'o_single_line_text'}">
                        <t t-esc="content"/>
                    </span>
                </td>
            </tr>
        </tbody>
    </t>
    <t t-name="ImportView.preview.error">
        <div class="oe_import_report alert alert-danger">
            <p>Import preview failed due to: <t t-esc="error"/>.</p>
            <p>For CSV files, you may need to select the correct separator.</p>
            <p t-if="preview">Here is the start of the file we could not import:</p>
        </div>
        <pre t-if="preview"><t t-esc="preview"/></pre>
    </t>
    <ul t-name="ImportView.error">
        <li t-foreach="errors" t-as="error"
            t-attf-class="oe_import_report alert alert-#{error_value[0].type}">
            <t t-if="error_value.length gt 1">
                <t t-call="ImportView.error.multi.header">
                    <t t-set="error" t-value="error_value[0]"/>
                    <t t-set="error_length" t-value="error_value.length"/>
                </t>
                <ul>
                    <t t-foreach="error_value.length" t-as="index">
                        <li t-att-class="index gt 4 ? 'oe_import_report_more':''">
                            <t t-call="ImportView.error.multi.body">
                                <t t-set="error" t-value="error_value[index]"/>
                                <t t-set="index" t-value="index"/>
                            </t>
                        </li>
                        <li t-if="error_value.length gt 5 and index == 4" style="display: block;">
                            <a href="#" class="oe_import_report_count">
                                <t t-esc="more(error_value.length - 5)"/>
                            </a>
                        </li>
                    </t>
                </ul>
                <t t-if="error_value[0].moreinfo" t-raw="info(error_value[0].moreinfo)"/>

            </t>
            <t t-else="">
                <t t-call="ImportView.error.single">
                    <t t-set="error" t-value="error_value[0]"/>
                </t>
            </t>
        </li>
    </ul>
    <t t-name="ImportView.error.multi.header">
        <span class="oe_import_report_message">
            <t t-esc="error.message"/>
            <t t-esc="at_multi_header(error_length)"/>
        </span>
    </t>
    <t t-name="ImportView.error.multi.body">
        <span class="oe_import_report_message" t-if="error.rows">
            <t t-esc="at_multi(error.rows)"/>
        </span>
    </t>
    <t t-name="ImportView.error.single">
        <span class="oe_import_report_message">
            <t t-esc="error.message"/>
        </span>
        <t t-if="error.rows"  t-esc="at(error.rows)"/>
        <t t-if="error.moreinfo" t-raw="info(error.moreinfo)"/>
    </t>
</templates>