This question has been flagged
2 Replies
3327 Views

Hi, I have a button that registers payment from a customer.

I want it to be greyed out from the view once the payment has been registered. How to do that?

This is my button code:

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

View Code:

    <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,'default_partner_id': investor_id'}"  string="Pay Investor" type="action"/>
                                           
                </group>
                </form>           
               </field>
        </record>

Can someone help me out?

Avatar
Discard
Author Best Answer

Hi chesucr, thanks for your help.

How can I let the button know that the state has been now changed to 'done'?

Its necessary for me to have partial payments in my register payment button. So that after 'n' number of payments when the full amount has been paid, then the state should become 'Done' and button should be greyed out or invisible.

My button action is in model 'account.voucher' and my amounts to be paid are in model 'record'. How can I link the two and write a condition accordingly?

Avatar
Discard
Best Answer

 You can put the button invisible instead disable. You can add something like this in the button

attrs="{'invisible':[('state','=','done')]}"
Avatar
Discard