I am trying to add the cash rounding line via API and wonder whether it is possible. I have created the invoice and define the cash rounding method but it will not add the cash rounding line as invoice_line is added later. I wonder whether there is a method to trigger the cash rounding like compute_tax. Below is the code I use, for testing purpose i have include adding invoice_line as part of the code.
@app.route("/create_invoice")
def create_invoice():
date_invoice = request.args.get("date_invoice")
invoice_id = models.execute_kw(db, uid, password, 'account.invoice', 'create', [{
'date_invoice':date_invoice,
'type': 'out_invoice',
'partner_id': 92,
'account_id': 38,
'cash_rounding_id': 1,
}])
product_id = request.args.get("product_id")
name = request.args.get("name")
quantity = request.args.get("quantity")
price_unit = request.args.get("price_unit")
account_id = request.args.get("account_id")
invoice_line_id = models.execute_kw(db, uid, password, 'account.invoice.line', 'create', [{
'invoice_id': invoice_id,
'product_id': product_id,
'name': name,
'quantity': quantity,
'price_unit': price_unit,
'account_id': account_id,
'invoice_line_tax_ids': [ (4,6) ],
}])
invoice_tax_id = models.execute_kw(db, uid, password, 'account.invoice', 'compute_taxes', [(invoice_id)])
return jsonify(invoice_id)