I have a field called 'monthly_interest'(float) in a custom model called 'record'. I have a button that registers payments through 'vendor_receipt_form'.
I want to take the amount entered in vendor_receipt_form (which is in account.voucher) and subtract it from monthly_interest(which is in record). The resultant field will be called 'balance' (which should be in record). Every time a payment is registered, balance should decrease accordingly.
Can you help me with this code?
CODE: xml
<button name="%(pay_investor_button_action)d" context="{'default_amount': (monthly_interest * -1),'default_partner_id': investor_id'}" string="Return Investment" col="2" type="action"/>
<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>
Py:
class record(orm.Model):
_name="record"
_columns={
'monthly_interest':fields.float('Return amount'),
}