Odoo Help


Inheriting the 'Register Payment Menu'

Arjun Khode
on 3/13/15, 4:48 AM 983 views

I am making a module in which payment entries should be directly dumped to the journal entries, without any invoice or order. In order to do this, I have created a button called 'register payment'.

This button has the following code:

        <record id="register_payment_button_action" model="ir.actions.act_window">
            <field name="name">Register Payment</field>
            <field name="res_model">account.voucher</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="view_id" ref="account_voucher.view_vendor_receipt_dialog_form"/>
            <field name="target">new</field>

Here is my record class:

class record(osv.Model):
              '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')
             # 'returns':fields.float('Amount to be returned'),

Now my problem is this:

How do I get my 'amount' field from my manually defined class called 'record' to show in the variable called 'amount' in account.voucher, which will then show as the paid amount in 'register payment' window.Right now my journal entries show 0.0 for any record registered. How can my journal entry get some amount registered for that user so that when I open register payment window by clicking the button, the paid amount should automatically get filled in ?


Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--

| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 3/14/15, 2:34 PM


I suppose the button is part of your class record view.

Just add in your button definition in xml: context="{'default_amount': amount}"

update your module and refresh browser page.

update :

<record id="register_payment_button_action" model="ir.actions.act_window">

     <field name="name">Customer Payments</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', 'in', ['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>



Arjun Khode
On 3/15/15, 3:45 AM

Hi Cyril, thank you for the help. Your solution worked. However, I have another problem..

In the 'Register Payment' menu, it is taking the paid amount correctly and it sets the payment method to 'Bank' by default. But it shows the 'Difference Amount' the same as 'Paid Amount' . So when I click on pay, the corresponding journal entry still shows 0.0 amount in it.

Is there a solution for this?

Thank you so much Cyril. The code works perfectly.

I have one more question to ask you..

I have two buttons: Register Payment (which you solved) and 'Pay Investor'

In register payment, the customer pays to us.

In pay investor, we are paying to the customer. ..

Can this be done through receipt? What changes would I have to make in the register payment code?

hi, in your button, you should call the same action like when you push the menu action_vendor_receipt, not directly the ir.actions.act_window you created, and more, the view you call is an old view unused, comment in the code for this view : "Register Payment Form (old Pay Invoice wizard)". The menu call action_vendor_receipt which has in context "'line_type': receipt" (important to define type of voucher) and display view view_vendor_receipt_form. In this view, the button proforma voucher call the function proforma_voucher (and not button_proforma_voucher in old view). Try with this changes, in function proforma_voucher add at the beginning a print for context and ids, verify values are the same type than if you created a voucher by using the menu action_vendor_receipt, and let me know the result.

Cyril Gaspard (GEM)
on 3/15/15, 5:51 AM

Hi, thanks! But I'm getting a bit confused. If not the ir.actions.act_window, then how do I assign an action to the button? Can you please show some code of what u are explaining?

Arjun Khode
on 3/16/15, 3:40 AM

Hi try with ir action I set in my answer. Bye

Cyril Gaspard (GEM)
on 3/16/15, 6:37 PM

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/13/15, 4:48 AM
Seen: 983 times
Last updated: 3/17/15, 8:11 AM