The issue with the tax line field being empty in the invoice line when using the External API may be due to a missing required value for the "account_id" field in the account move line model. In Odoo, the "account_id" field is a required field in the account move line model, and it specifies the account that will be used for the invoice line.
To resolve the issue with the empty tax line field in the invoice line, you can try adding a value for the "account_id" field in the account move line model when creating the invoice line using the External API. You can use the "account.account" model to search for the correct account to use for the invoice line, and then pass the ID of the account as the value for the "account_id" field when creating the invoice line.
For example, you can use the following code to search for the correct account to use for the invoice line, and then create the invoice line with the "account_id" field set to the ID of the found account:
# Search for the correct account to use for the invoice line
accounts = models.execute_kw(
DB, uid, ODOO_PWD,
'account.account',
'search',
[[['name', 'ilike', 'Sales']]]
)
# Get the first account that matches the search criteria
account = accounts[0]
# Create the invoice line with the "account_id" field set to the found account
invoice_line = models.execute_kw(
DB, uid, ODOO_PWD,
'account.move.line',
'create',
[{
'name': 'Product Name',
'quantity': 1,
'price_unit': 100,
'account_id': account,
}]
)
In this code, the "account.account" model is used to search for an account with the name "Sales", and the first account that matches the search criteria is used as the value for the "account_id" field when creating the invoice line. This should ensure that the invoice line is created with the correct "account_id" field value, and the tax line field in the invoice line
-