Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
3 Antwoorden
1770 Weergaven

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
Avatar
Annuleer
Auteur

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

Beste antwoord

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.

Avatar
Annuleer
Beste antwoord

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.

Avatar
Annuleer
Beste antwoord

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 

Avatar
Annuleer

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);
},
}
);
});
}

Gerelateerde posts Antwoorden Weergaven Activiteit
0
mrt. 25
657
1
jun. 23
1935
1
mei 23
1880
1
dec. 22
3231
1
okt. 22
4025