I have a transient model that serves as a dialog. In my form view I have a button like this:
<footer states="partnerId">
<button name="check_tax_id" string="Tovább" type="object"/>
</footer>
The button invokes this function (I can confirm it actually invokes):
@api.one
def check_tax_id(self, context=None):
self.state = "partnerDetails"
return None;
My problem is that the dialog window is closed immediately once I click this button! What am I doing wrong?
yesterday I bumped on this same issue. I needed to show a button to do something without submitting the whole wizaard. I worked around it by not using a button at all. It's pretty simple and effective. What you need:
invisible="1"
and a label to be styled as a buttonHere's the code:
source_it = fields.Boolean(string='Source')
[...]
def action_source(self):
# do stuff
@api.onchange('source_it')
def onchange_source_it(self):
if self.env.context.get('sourcing_now') or not self.source_it:
return
self.action_source()
[...]
<label for="source_it" class="pull-left btn btn-success" />
<field name="source_it" invisible="1" />
The trick works because when a label has for
attribute is going to act like the checkbox itself, so if you click on the label you are actually switching the checkbox.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With