-
-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] base_export_async: Migration to 16.0
- Loading branch information
Benjamin Coronel
committed
Jul 11, 2023
1 parent
6e4a890
commit a2a2dc1
Showing
9 changed files
with
129 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** @odoo-module */ | ||
|
||
import {ExportDataDialog} from "@web/views/view_dialogs/export_data_dialog"; | ||
import {patch} from "@web/core/utils/patch"; | ||
|
||
patch(ExportDataDialog.prototype, "base_export_async", { | ||
setup() { | ||
this._super(); | ||
this.state.async = false; | ||
}, | ||
onToggleExportAsync(value) { | ||
this.state.async = value; | ||
}, | ||
async onClickExportButton() { | ||
if (!this.state.exportList.length) { | ||
return this.notification.add( | ||
this.env._t("Please select fields to save export list..."), | ||
{ | ||
type: "danger", | ||
} | ||
); | ||
} | ||
await this.props.download( | ||
this.state.exportList, | ||
this.state.isCompatible, | ||
this.availableFormats[this.state.selectedFormat].tag, | ||
this.state.async | ||
); | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** @odoo-module **/ | ||
|
||
import {download} from "@web/core/network/download"; | ||
import {ListController} from "@web/views/list/list_controller"; | ||
import {patch} from "@web/core/utils/patch"; | ||
import framework from "@web.framework"; | ||
import Dialog from "@web.Dialog"; | ||
import core from "@web.core"; | ||
const _t = core._t; | ||
|
||
patch(ListController.prototype, "base_export_async", { | ||
async downloadExport(fields, import_compat, format, async = false) { | ||
let ids = false; | ||
if (!this.isDomainSelected) { | ||
const resIds = await this.getSelectedResIds(); | ||
ids = resIds.length > 0 && resIds; | ||
} | ||
const exportedFields = fields.map((field) => ({ | ||
name: field.name || field.id, | ||
label: field.label || field.string, | ||
store: field.store, | ||
type: field.field_type || field.type, | ||
})); | ||
if (import_compat) { | ||
exportedFields.unshift({name: "id", label: this.env._t("External ID")}); | ||
} | ||
if (async) { | ||
/* | ||
Call the delay export if Async is checked | ||
*/ | ||
framework.blockUI(); | ||
const args = [ | ||
{ | ||
data: JSON.stringify({ | ||
format: format, | ||
model: this.model.root.resModel, | ||
fields: exportedFields, | ||
ids: ids, | ||
domain: this.model.root.domain, | ||
context: this.props.context, | ||
import_compat: import_compat, | ||
user_ids: [this.props.context.uid], | ||
}), | ||
}, | ||
]; | ||
const orm = this.env.services.orm; | ||
orm.call("delay.export", "delay_export", args).then(function () { | ||
framework.unblockUI(); | ||
Dialog.alert( | ||
this, | ||
_t( | ||
"You will receive the export file by email as soon as it is finished." | ||
) | ||
); | ||
}); | ||
} else { | ||
await download({ | ||
data: { | ||
data: JSON.stringify({ | ||
import_compat, | ||
context: this.props.context, | ||
domain: this.model.root.domain, | ||
fields: exportedFields, | ||
groupby: this.model.root.groupBy, | ||
ids, | ||
model: this.model.root.resModel, | ||
}), | ||
}, | ||
url: `/web/export/${format}`, | ||
}); | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates id="template" xml:space="preserve"> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-extend="ExportDialog"> | ||
<t t-jquery="div.o_import_compat" t-operation="after"> | ||
<div class="form-check"> | ||
<input | ||
class="form-check-input" | ||
id="async_export" | ||
type="checkbox" | ||
name="async_export" | ||
/> | ||
<label class="form-check-label" for="async_export"> | ||
<strong | ||
>Asynchronous export </strong> (You will receive the export by email) | ||
</label> | ||
</div> | ||
</t> | ||
<t | ||
t-name="base_export_async.ExportDataDialogAsync" | ||
t-inherit="web.ExportDataDialog" | ||
t-inherit-mode="extension" | ||
> | ||
<xpath expr="//div[hasclass('o_import_compat')]" position="after"> | ||
<CheckBox | ||
id="async_export" | ||
value="state.async" | ||
onChange.bind="onToggleExportAsync" | ||
> | ||
<strong>Asynchronous export </strong> (You will receive the export by email) | ||
</CheckBox> | ||
</xpath> | ||
</t> | ||
|
||
</templates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../base_export_async |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |