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.


pay an invoice generated by code

on 4/9/13, 11:00 AM 542 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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)


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