Hi, I'm trying to write a module that calculates interest on a certain principal amount given a rate of interest, and displays the new amount to be returned in a field.
This is my python code:
class record(osv.Model):
_name="record"
_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 Paid'),
'roi':fields.float('Rate of Interest in fraction'),
'returns':fields.float('Amount to be returned')
}
I want 'returns' field to be like: returns=amount+amount*roi
Here is my XML:
<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"/>
<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" string="Register Payment" type="action"/>
<button name="%(pay_investor_button_action)d" string="Pay Investor" type="action"/>
</group>
</form>
</field>
</record>
How to write or modify my code so that it will calculate the 'returns' field?
I also want to display the updated value of return.