Odoo Help


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.


Register payment automatically

on 10/21/15, 6:17 AM 574 views

Hallo, I'm implementing Odoo for a business where they need to register payment automatically, given these values:

  • payment date = invoice date

  • paid amount = invoice total amount

  • payment type = bank

I tried with the following code, but it fails with an error 

ValueError: "" while evaluating action_register_payment() 

It's likely I'm missing something about creating the voucher, which is a part that actually I don't know.


In the invoice view: added a button 

<button name="invoice_paid" states="open" string="Invoice paid" class="oe_highlight" groups="base.group_user" />

that calls a transition by its signal

<record id="open_to_paid" model="workflow.transition">
<field name="act_from" ref="account.act_open"/>
<field name="act_to" ref="account.act_paid"/>
<field name="signal">invoice_paid</field>

the action of the act_paid activity has been improved

<record id="account.act_paid" model="workflow.activity">
<field name="action">action_register_payment()

 and finally the action_register_payment():

def action_register_payment(self):
for inv in self:
journal_pool = self.env['account.journal']
journal_id = journal_pool.search([('company_id','=',inv.company_id.id), ('code','=','BNK2')])[0].id
journal = journal_pool.browse(journal_id)
account_id = journal.default_debit_account_id.id
vals = {
'currency_id': inv.currency_id.id,
'partner_id': inv.partner_id.id,
'amount': inv.amount_total,
'reference': inv.name,
'name': inv.number,
'type': 'payment',
'date': inv.date_invoice,
'period_id': inv.period_id.id,
'journal_id': journal_id,
'account_id': account_id,
'writeoff_amount': 0.0,
'paid': True,
'narration': 'Automatically set to paid'
id = voucher_pool.create(vals)
voucher_id = voucher_pool.browse(id)
voucher_pool = self.env['account.voucher']

Kinner Vachhani
On 10/21/15, 10:21 AM


The error seems to be coming form create method. Put an ipdb statement before 

id = voucher_pool.create(vals)

Could you paste the stack trace? 

I have installed Odoo via apt-get: do I need to launch it from terminal to get the trace of ipdb? If so, how can I launch Odoo manually?

on 10/22/15, 6:00 AM

Hi Raffaele, You need a manual start. I you can't then there is an alternative way to debug Print values thought logger.info(val) before voucher code create. Connect database through erppeek (pip install erppeek). $erppeek -d $voucher_obj = model('account.voucher') $voucher_obj.create(vals) Check the error message. Retry creating voucher until you get it right.

Kinner Vachhani
on 10/22/15, 8:47 AM

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)


Asked: 10/21/15, 6:17 AM
Seen: 574 times
Last updated: 10/21/15, 10:23 AM