Skip to Content
Menu
This question has been flagged
2 Replies
6475 Views

Hi, I'm actually strungling with the creation of an Invoice using the external API. I'm able to create a product with the external api as I'm also able to create a partner.

But when i'm trying to create an invoice with thoses lines:

#create invoice
id_partner = '54'
invoice_id = models.execute_kw(db, uid, password,
'account.move', 'create', [{
'partner_id' : id_partner,
}])

I'm just getting an ERROR 500 from my Odoo server.
I'm also strugling creating an invoice_line in an already existing Invoice.



Any help would be appreciated.

ps: Is this way to do a good way or should I do it differently?

Avatar
Discard
Best Answer

Hi Guys,

I solve the same problem celestin ,
with this function

    def invoiceAdd(self, invoiceNam):
        invoice_id = self.ODOO_OBJECT.execute_kw(
            self.DATA
            , self.UID
            , self.PASS
            , 'account.move'
            , 'create'
            , invoiceNam
            ,
            )
        if invoice_id:
            return invoice_id
        else:
            return None
que j'appelle avec ceci 
invoiceNam = [{
        'partner_id' : partner_id
        , 'state' : 'draft'
        , 'type' : 'out_invoice'
        # , 'journal_id' : '1'
        # , 'date_invoice' : date.today()
        , 'invoice_payment_term_id' : '1'
        # , 'date_due': dat
    }]
    invoice_line = [(0,True, {'product_id': product_id,'quantity':2})]
    # list_inv=od.invSe()
    # print(list_inv)
    print(invoiceNam)
    print(invoice_line)
    invoice_id = od.invoiceAdd(invoiceNam)

but i find the solution of invoice_line

Avatar
Discard
Best Answer

Hi Célestine,

Please try to identify what fields are required when you create an invoice from the user interface. And then propose the same fields when creating from the API.

Avatar
Discard