I have two buttons in a view. I want to add a third button called 'Mark as done'. Pressing this button should make the other two buttons invisible or greyed out. And the 'Mark as done' button itself should also become invisible
How to add the conditions for this?
Here is my code:
XML:
BUTTON ACTIONS:
<record id="register_payment_button_action" model="ir.actions.act_window">
<field name="name">Register Payment</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt')]</field>
<field name="context">{'type':'receipt'}</field>
<field name="view_id" ref="account_voucher.view_vendor_receipt_form"/>
<!-- <field name="view_id" ref="account_voucher.view_vendor_receipt_dialog_form"/> -->
<field name="target">new</field>
</record>
<record id="pay_investor_button_action" model="ir.actions.act_window">
<field name="name">Pay Investor</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="domain">[('journal_id.type', 'out', ['bank', 'cash']), ('type','=','receipt')]</field>
<field name="context">{'type':'receipt'}</field>
<field name="view_id" ref="account_voucher.view_vendor_receipt_form"/>
<field name="target">new</field>
</record>
BUTTONS:
<record id="record_form_view" model="ir.ui.view">
<field name="name">record.form.view</field>
<field name="view_type">form</field>
<field name="model">record</field>
<field name="arch" type="xml">
<form string="Record">
<group>
<field name="investment_id"/>
<field name="investor_id" domain="[('is_investor','=',True)]"/>
<field name="start_date"/>
<!-- <field name="end_date"/> -->
<field name="roi"/>
<field name="amount"/>
<field name="returns"/>
<!-- <button name="action_compute_returns" string="Compute Returns" type="object"/> -->
<button name="%(register_payment_button_action)d" context="{'default_amount': amount,'default_partner_id': investor_id'}" string="Register Payment" type="action"/>
<button name="%(pay_investor_button_action)d" context="{'default_amount': (returns * -1),'default_partner_id': investor_id'}" string="Pay Investor" type="action"/>
<!-- mark as done button code goes here -->
</group>
</form>
</field>
</record>
PYTHON:
_columns={
'investment_id':fields.many2one('investment.model','Name of Investment'),
'investor_id':fields.many2one('res.partner','Investor Name'),
'start_date':fields.date('Start Date'),
#'end_date':fields.date('End Date'),
'amount':fields.float('Amount Invested'),
#'status_paid':fields.boolean('Total Amount Paid'),
#'status_returned':fields.boolean('Total Amount Returned'),
'done':fields.boolean('Mark As Done',invisible=True),
'roi':fields.float('Rate of Interest in fraction'),
'monthly_interest':fields.float('Cumulative Monthly Interest'),
'returns':fields.function(_amount_returns, digits_compute=dp.get_precision('Account'), string='Amount to be returned',
store={
'record': (lambda self, cr, uid, ids, c={}: ids, ['amount', 'roi'], 10),
},),
<button name="credit_approve" type="object" string="Credit Approve" class="oe_highlight" attrs="{'invisible':['|','|','|','|',('credit_approved','=',True),('is_available','=',False),('credit_customer','=',False),('credit_customer','=',True)]}"/>