Odoo Help

Welcome!

This community 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.

0

Calculating balance

By
Arjun Khode
on 3/29/15, 2:31 AM 372 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>
        </record>                   
Py
:

class record(orm.Model):

_name="record"

_columns={

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

}

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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