Skip to Content
Menu
This question has been flagged
3 Replies
15781 Views

Hi,

In v9 i was created popup form and added my custom Save and Cancel buttons, now in v10 that form shows both, my created Save  Cancel and default Save Cancel

.

how to hide default buttons? i have tried on .py file which calls form add:

'flags': {'form': {'action_buttons': False},}

but nothing changed.


my code:

return 
{
'name': _('Choose agreement type'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'sale.order',
'view_id': form.id,
'type': 'ir.actions.act_window',
'target': 'new',
'res_id': self.id,
'flags': {'form': {'action_buttons': False},}
}

form:

<record id="wizard_state_agreement" model="ir.ui.view">            
<field name="name">sale.order.wizard_state_agreement</field>
<field name="model">sale.order</field>
<field name="arch" type="xml">
<form string="Please chose agreement type">
<sheet>
<group>
<field name="agreement_choose"/>
</group>
</sheet> <div>
<button name="change_state_agreement" string="Save" type="object" class="btn btn-primary"/>
<button special="cancel" string="Cancel" class="btn btn-default"/>
</div>
</form>
</field>
</record>





Avatar
Discard
Best Answer

Hi FarmingWolf,

Please include the following code in your wizard's form view to replace Odoo's default footer with your custom one.

<footer>

​<button name="<your custom method>" string="Save" type="object" class="btn btn-primary"/>

​<button special="cancel" string="Cancel" class="btn btn-default"/>

</footer>

Thanks

Avatar
Discard
Best Answer

Try  to replace :

this is the code that add save and cancel buttons,

<footer> <button name="write" type="object" string="Save"/> or <button name="cancel" string="Cancel" special="cancel" class="oe_link"/> </footer>

so replace the footer using xpath

Avatar
Discard
Author

Hello, i have tried xpath, but it wont work. Worked for me only changing wizard view <footer>

<button name="change_state_agreement" string="Save" type="object" class="btn btn-primary"/>

<button special="cancel" string="Cancel" class="btn btn-default"/>

</footer>

you can replace the the footer then by <xpath expr="//footer" position = "replace"></xpath>

also try the action by removing 'flags': {'form': {'action_buttons': False},}

Best Answer

Hello, zilvinas,

I have a similar problem. I added my own button, and I want to hide the default button.

Have you resolved that problem?

Avatar
Discard

Hi FarmingWolf,

Please include the following code in your wizard's form view to replace Odoo's default footer with your custom one.

<footer>

​<button name="<your custom method>" string="Save" type="object" class="btn btn-primary"/>

​<button special="cancel" string="Cancel" class="btn btn-default"/>

</footer>

Thanks

Hi Yatrik Chauhan,
Thank you for your reply!
This is my popup window source code, would you please indicate where the footer code should be added, or maybe in other source file? Thanks a lot!
<?xml version="1.0" encoding="utf-8"?>

<templates xml:space="preserve">

<t t-name="estate_lease_contract.ContractTerminateAction">
<div class="ms-1 mt-1">
<div class="align-self-center" style="display: flex; justify-content: center;">
<div>
<span>Data record will be terminated and archived!</span><br/>
</div>
</div>
<div class="align-self-center" style="display: flex; justify-content: center;">
<div class="col-sm-5 mt16" style="display: flex; justify-content: center;">
<button class="btn btn-primary mb16" t-on-click="() => this.onClickTerminateContract()" t-att-disabled="this.confirm_button_disable()">
<div class="mb16 mt16"> Terminate </div>
</button>
</div>
</div>
</div>
</t>
</templates>

※I have tried the followings:
1. adding the footer code in the <t> mark , and the default footer and button are still there.
2. adding the footer code out of the <t> mark, page error comes up:Failed to load resource: the server responded with a status of 404 (NOT FOUND)
3.adding the footer code in the popup's parent form view , and nothing changed...

Hello FamingWolf,
Can you please try to change this code.

<?xml version="1.0" encoding="utf-8"?>

<templates xml:space="preserve">

<t t-name="estate_lease_contract.ContractTerminateAction">
<div class="ms-1 mt-1">
<div class="align-self-center" style="display: flex; justify-content: center;">
<div>
<span>Data record will be terminated and archived!</span><br/>
</div>
</div>
<div class="align-self-center" style="display: flex; justify-content: center;">
<div class="col-sm-5 mt16" style="display: flex; justify-content: center;">
</div>
</div>
</div>
<button class="btn btn-primary mb16" t-on-click="() => this.onClickTerminateContract()" t-att-disabled="this.confirm_button_disable()">
<div class="mb16 mt16"> Terminate </div>
</button>
</t>
</templates>

Related Posts Replies Views Activity
5
Sep 19
6740
2
Nov 24
25064
2
May 24
5511
3
Mar 24
4961
0
Mar 24
261