This question has been flagged
3339 Views

Hi

I am devloping a module for Investors,(Investor is one of the type of Partner like custormer)for that, I want to calculate "Balance" after each successful transaction.

I am Registring the Investment for Investors, after payment if it is in 2 or more installments.

I have a TOTAL amount to return to a Investor, I want to substract the current installment just registered from the TOTAL amount to return to a Investor

I already plotted a button "Return Amount" for tracking the payment paid by the user to particular Investor

In Python module, I inherited the Receipt form view (account_voucher.view_vendor_receipt_form) to register payments.

My TOTAL amount is in another class called "invest.record"

I want my Balance inside "invest.record" then, How to get the value of Registered Payment from account.voucher class in invest.record and substract it?

Here is my Code,

--------------------------------------------------------------------------------------------------------------------------------------

investor.py

_columns={

'start_date':fields.date("Start Date"),

#'end_date':fields.date("End Date"),

'amount':fields.float("Amount Invested"),

'balance':fields.float("Balance"),

'roi':fields.float("Rate of Interest In Fraction"),

'months':fields.float("Months"),

'investor_id':fields.many2one('res.partner','Investor Name'),

'investment_id':fields.many2one('investment.model','Investment Name'),

'amt_returns':fields.float("Amount Returns "),

'account_ids':fields.one2many('account.move','record_id', string="Payments"),

'voucher_id':fields.many2one('account.voucher','Voucher'),

'amt':fields.float(compute='_get_voucher_amount',string="Voucher Amount"),

'returns':fields.function(_amount_returns, digits_compute=dp.get_precision('Account'), string='Amount to be returned',

store={

'value': (lambda self, cr, uid, ids, c={}: ids, ['amount', 'roi'], 10),

},),

Here, "amt_returns" is the TOTAL amount to substract from.

---------------------------------------------------------------------------------------------------------------------------------

investor_view.xml

The Button for Registering Payments is given as,

<button name="%(pay_investor_button_action)d" context="{'default_amount': amt_returns * -1, 'default_partner_id': investor_id}" string="Return Amount" col="2" type="action"/>

the Action for above Button is given as,

<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="vew_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>

One more thing to note, I want "Paid Amount" in the Receipt to be drawn after pressing the Validate Button in the Receipt because it may be a Partial

Payment.

Avatar
Discard