Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odoo 11 customize wizard function

i want to customize a wizard button to allow the selected items and change the done(Boolean) to True once i click the button. This is the sample view and the wizard button i had created. enter image description here

And this is my code below in the view file:

<record model="ir.actions.server" id="make_it_done">
    <field name="name">Make it done</field>
    <field name="condition">True</field>
    <field name="model_id" ref="model_todo_task"/>
    <field name="type">ir.actions.server</field>
    <field name="binding_model_id" ref="model_todo_task" />
    <field name="code">
        action = self.make_it_done()
    </field>
</record>

And this is my model file:

from odoo import api,fields, models
from odoo.addons.base.res.res_request import referenceable_models
from odoo.exceptions import ValidationError

class TodoTask(models.Model):

def make_it_done(self):
    print('Success!!')

I wish to create a wizard function that allow to update all of the selected items to "Done" (Just like the build in "Archive" function). But however based on my code, when i select the item and click the wizard function, it just do nothing.

This is the only response i received(The loading shown in picture above). Then all the checkbox would become unchecked. enter image description here

I don't know what i've missed, but it just don't run the code. Please help me to solve this problem, thank you guys in advance!!

like image 745
Kowa JiaLiang Avatar asked Sep 26 '26 12:09

Kowa JiaLiang


1 Answers

Maybe you can try to add a field named "state"

<field name="state">code</field>

inside the server action, it work for me

like image 131
KaiJun Tong Avatar answered Sep 30 '26 12:09

KaiJun Tong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!