Odoo Help


Calculating balance

Arjun Khode
on 3/29/15, 2:31 AM 678 views

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>

class record(orm.Model):



'monthly_interest':fields.float('Return amount'),


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/29/15, 2:31 AM
Seen: 678 times
Last updated: 3/29/15, 2:31 AM