Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
1764 Переглядів

I have opened the wizard from JS , now i need the wizard to return value to JS.


Code
async openWizard() {
return new Promise((resolve) => {
var value = this.actionService.doAction(
{
type: "ir.actions.act_window",
res_model: "employee_link",
view_mode: "form",
view_type: "form",
views: [[false, "form"]],
target: "new",
},
{
onClose: () => resolve(value),
}
);
​console.log(value)
});
},

on cosole it is printing :
    [[Prototype]]: Promise
    [[PromiseState]]: "fulfilled"
    [[PromiseResult]]: undefined
Аватар
Відмінити
Автор

Thanks, but how can I store the wizard record ID mentioned in the answer?

const recordId = this.wizardRecordId; // Assuming you store the wizard record ID somewhere

Найкраща відповідь

I encountered a similar problem where I was getting "undefined" when trying to retrieve the result from a wizard in Odoo. I resolved it by using a Promise and capturing the result within the onClose callback. This ensured that I had the correct value after the wizard closed. If you can provide more details about your specific setup, I might be able to assist you further.

Аватар
Відмінити
Найкраща відповідь

Hi,

To resolving the problem of promise, we need to use async and await in our code to get the data.

Use the following code as a reference to do the same for your problem:

async openWizard() {

    return new Promise((resolve) => {

        this.actionService.doAction(

            {

                type: "ir.actions.act_window",

                res_model: "employee_link",

                view_mode: "form",

                view_type: "form",

                views: [[false, "form"]],

                target: "new",

            },

            {

                onClose: async () => {

                    // Fetch the data you want to return here

                    const linkData = await this._fetchWizardData();

                    resolve(linkData);

                }

            }

        );

    });

},


// Helper function to fetch data from the wizard

async _fetchWizardData() {

    const recordId = this.wizardRecordId; // Assuming you store the wizard record ID somewhere

    // Here you can write the logic to get the data, like an orm call.

    })    // Return the data

}


Hope it helps.

Аватар
Відмінити
Найкраща відповідь

Hello Jayaram,


To identify the issue that you have mentioned. let's update the code.

However, the value is being logged as undefined because it is not set before the resolve call. 

You need to update value within the onClose callback to capture the necessary information when the wizard closes.

// Code In Comment //

I Hope this information proves helpful to you.

Thanks & Regards,

Email:   odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari 

Аватар
Відмінити

Code:

async openWizard() {
return new Promise((resolve) => {
this.actionService.doAction(
{
type: "ir.actions.act_window",
res_model: "employee_link",
view_mode: "form",
view_type: "form",
views: [[false, "form"]],
target: "new",
},
{
onClose: (result) => {
var value = result; // Capture the result or value from the wizard
resolve(value);
},
}
);
});
}

Related Posts Відповіді Переглядів Дія
0
бер. 25
656
1
черв. 23
1934
1
трав. 23
1878
1
груд. 22
3229
1
жовт. 22
4023