When opening a pop up dialog after clicking the save button, the dialog box does not closed.
I know that I can add
<footer>
<button name="save_item" string="Save" type="object" class="oe_highlight" />
<button string="Cancel" special="cancel" class="oe_highlight" />
</footer>
And add method save_item
in the model that will return True
and close the pop up dialog.
But if I click the item on the grid (one2many widget) it will pop up with the action buttons and my custom save/cancel buttons. So the buttons will get redundant.
@api.multi
def add_item(self):
# for record in self:
return {
"type": "ir.actions.act_window",
"name": "Add Item",
"res_model": "quotation.line",
"view_type": "form",
"view_mode": "form",
"view_id": self.env.ref("prescription.view_quotation_line_form",False).id,
"target": "new",
"flags": {"form": {"action_buttons": True}},
"context": {
"default_quotation_id": self.id,
},
}
Is there a way to close the dialog pop up after clicking the default action button?
I think I have understood you, but can't you just open your pop-up with action_buttons
set to False to use only your own buttons?
@api.multi
def add_item(self):
# for record in self:
return {
"type": "ir.actions.act_window",
"name": "Add Item",
"res_model": "quotation.line",
"view_type": "form",
"view_mode": "form",
"view_id": self.env.ref("prescription.view_quotation_line_form",False).id,
"target": "new",
"flags": {"form": {"action_buttons": False}},
"context": {
"default_quotation_id": self.id,
},
}
This way users would only have the possibility to click on your buttons and you could close the pop-up in your save_item
method.
EDIT
After reading your comments, I understand that you want to get rid of your own buttons when the record is being edited because in this case you see 4 buttons, the default ones and yours. And when creating you do not have this problem. I guess you have created your own Add item button and you do not allow users to use the default One2many Add an element button, or something like that. Try with this then
...
<field name="id" invisible="1"/>
...
<footer attrs="{'invisible': [('id', '!=', False)]}">
<button name="save_item" string="Save" type="object" class="oe_highlight" />
<button string="Cancel" special="cancel" class="oe_highlight" />
</footer>