Skip to Content
Menu
This question has been flagged
4 Replies
5987 Views

Hi all,


I'm new in Odoo.

I have this question about wizard and the "compute" parameter.

I have defined this simple custom wizard however the _get_login method is not called and I can't figured why.

Furthermore the rendered view don't have the login field.... ( https://ibb.co/7JCnmPH )

Is there anyone can help me?

Is possible to use compute with wizard???

from odoo import api, fields, models

class FooBarWizard(models.TransientModel):

_name = "foo.bar.wizard"

login = fields.Char(compute="_get_login")
password = fields.Char()
email = fields.Char()

def _get_login(self):
for item in self:
item.login='Foo'
Avatar
Discard
Author

@subbarao

thank you again .

I tried but it still doesn't work.......

Author

HI all,

Now my code is:

from odoo import api, fields, models

class FooBarWizard(models.TransientModel):

_name = "foo.bar.wizard"

@api.multi

def _get_login(self):

for item in self:

item.login = 'Foo'

login = fields.Char(compute="_get_login")

password = fields.Char()

email = fields.Char()

but it still doesn't work.

I putted a breakpoint in pycharm debugger on "_get_login" mehod but it's ignored.

I setted "item.login = 'Foo'" because at a later moment I want to replace it with a code that use environment variables........

Author

@Justin Chen

Thank you Justin now it work with default=get_login instead of compute.....

Is there anyone can tell me why compute in my case doesn't function?

Best Answer

Hi, Could you try define the "_get_login" method before the line you define field "login"?

And also, use the @api.multi decorator for "_get_login".

Btw, if what you are doing is to hard coding 'Foo' to the field, use default="_get_login", and make the method return 'Foo'.

Avatar
Discard
Best Answer

Hi Paul

Have you called the function '_get_login' in the xml view?

some thing like the following

<record model="ir.ui.view" id="my_wizard_form_view">
            <field name="name">wizard.form</field>
            <field name="model">foo.bar.wizard</field>
            <field name="arch" type="xml">
                <form string="Wizard">
                    <group>
                        <field name="login"/>
                        <field name="password"/>
                    </group>
                    <footer>
                        <button name="_get_login" type="object" string="Login" class="oe_highlight"/>
                        <button special="cancel" string="Cancel"/>
                    </footer>
                </form>
            </field>
        </record>

Avatar
Discard
Best Answer

Hello Paul San,

try this one 

@api.multi
def _get_login(self):
for item in self:
item.login='Foo'
Avatar
Discard
Related Posts Replies Views Activity
1
Dec 19
4147
1
Feb 24
10257
2
Mar 24
479
1
Nov 24
18019
1
Sep 23
1203