Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
17458 Lượt xem

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>





Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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},}

Câu trả lời hay nhất

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?

Ảnh đại diện
Huỷ bỏ

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>

Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 9 19
8056
2
thg 7 25
4490
2
thg 12 24
7668
2
thg 11 24
28431
2
thg 5 24
7403