Odoo - prevent button from closing wizard Odoo - prevent button from closing wizard xml xml

Odoo - prevent button from closing wizard


Solution 0

@api.multidef check_tax_id(self):    self.ensure_one()    self.name = "New name"    return {        "type": "ir.actions.do_nothing",    }

This solution was provided here by Tadeusz Karpinski.

Solution 1

You can return a new form with the same record id.

@api.multidef check_tax_id(self):    self.ensure_one()    self.name = "New name"    return {        'context': self.env.context,        'view_type': 'form',        'view_mode': 'form',        'res_model': 'model_name',        'res_id': self.id,        'view_id': False,        'type': 'ir.actions.act_window',        'target': 'new',    }

Solution 2

You can create a widget in jQuery. This will open the wizard and you can assign the behaviour you want to the buttons manually. You can use the call function to call python functions as well:

[...]new instance.web.Dialog(this, {     title: _t("Title"),     width: '95%',     buttons: [          { text: _t("First button"), click: function() { self.first_button(); }},           { text: _t("Second button"), click: function() { self.second_button(); }},          { text: _t("Close"), click: function() {  dialog.close(); }},                             ],});[...]

Solution 3

Of course you can override the create method as well to avoid the creation of the record in some cases

Solution 4

One last option. Create a workflow with a state field. Create workflow buttons in order to send signals to change the state. You can show or hide the rest of the fields using the attrs attribute and the state field. But I do not know if that would adapt to your needs.


In my case this code works.

@api.multidef test(self):    l = logging.getLogger()    l.warn("xD")    return {        "type": "ir.actions.do_nothing",    }


The simplest this to do is :

@api.multidef null_action(self):    return {        "type": "set_scrollTop",    }

As the type is used to call any method on the class ActionManager (javascript)

It's better than "type": "ir.actions.do_nothing" which generate an exception (this attribute doesn't exist)