Odoo Help


pay an invoice generated by code

on 4/9/13, 11:00 AM 599 views


i succeeded in generating a supplier invoice. The problem i have now is that i can not pay the invoice i create (by code). It seems it is due to the incorrect account being used for payment ?

Nothing happens when i pay even the state doesn't change to paid

Here is my code:

    for commission in self.browse(cr, uid, ids, context=context):
        if commission.supplier_invoice.id:
        journal_ids = self.pool.get('account.journal').search(cr, uid,
                                                              [('type', '=', 'purchase'),
                                                               ('company_id', '=',
        if not journal_ids:
            raise osv.except_osv(_('Error!'),  # TODO change text message
                                 _('Please define sales journal for this company: "%s" (id:%d).') % (
                                     'dummy', 'dummy'))
        invoice_line = {
            'name': 'commission',
            'sequence': 5,
            'invoice_id': False,
            'account_id': commission.salesperson.partner_id.property_account_receivable.id,
            'price_unit': commission.commission_total,
            'quantity': 1.0,

        invoice_line_id = self.pool.get('account.invoice.line').create(cr, uid, invoice_line, context=context)
        new_invoice = {
            'name': 'commission on sale',
            'type': 'in_invoice',
            'reference': '',
            'account_id': commission.salesperson.partner_id.property_account_receivable.id,
            'partner_id': commission.salesperson.partner_id.id,
            'journal_id': journal_ids[0],
            'invoice_line': [(6, 0, [invoice_line_id])],
            'currency_id': commission.invoice.currency_id.id,
            'comment': 'test',
            'fiscal_position': commission.salesperson.partner_id.property_account_position.id,
            'company_id': commission.invoice.company_id.id,
            'user_id': uid
        invoice_id = self.pool.get('account.invoice').create(cr, uid, new_invoice, context=context)

                   {'supplier_invoice': invoice_id},

what error message do you get when you try to pay the invoice?

on 4/9/13, 11:50 AM

i dont have any error message ,but it does not do anything either

on 4/9/13, 12:00 PM

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 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

0 follower(s)


Asked: 4/9/13, 11:00 AM
Seen: 599 times
Last updated: 3/16/15, 8:10 AM