This question has been flagged
3128 Views

Hi! I was able to create an invoice with the API.

The documentation I'm using is this one:

https://www.odoo.com/

documentation/10.0/api_

integration.html

The problem is that taxes aren't being calculated. Also the Invoice is created as draft so I don't know how to call a "confirm" method to achieve this.

This is the code snippet I'm using:


                // invoiceId 
final Integer id = (Integer) models.execute("execute_kw", asList(
db, uid, password,
"account.invoice", "create",
asList(new HashMap() {
{
put("name", "New Partner");
put("date", "2018-04-13");
put("account_id", 595);
put("partner_id", 7); 
}
})));
System.out.println("invoiceId:" + id);

// invoiceTaxId
final Integer taxId = (Integer) models.execute("execute_kw", asList(
db, uid, password,
"account.invoice.tax", "create",
asList(new HashMap() {
{
put("invoice_id", id);
put("tax_id", 1);
put("name", "IVA 21% (Bienes)");
put("account_id", 595);
}
})));
System.out.println("taxId: " + taxId);

                // itemId
final Integer itemId = (Integer) models.execute("execute_kw", asList(
db, uid, password,
"account.invoice.line", "create",
asList(new HashMap() {
{
put("invoice_id", id);
put("name", "LICENSE");
put("account_id", 595);
put("price_unit", 49.99d);
put("invoice_line_tax_ids", asList(taxId));
}
})));
System.out.println(itemId);


Avatar
Discard