I call this code from route.py and I have error at last command sale.process([sale])
The error is trytond.exceptions.UserError: There is no "Account Category" defined on the product "Product name"
The problem is that your product is not correctly configured. You are missing an Account Category on it or the account category does not have any Receivable Account
Note that this is required to process the sale as in this case an invoice is created.
Another option is to use the invoice method based on shipment. This will fix the problem but it will be raised latter when finishing the shipment.
So the best is to configure the products properly.
I see you have the company hard coded. So I’m guessing that it is not set in the context.
So depending of the version, the code can not get the company-related multivalue where the account is stored.
The same error again
If I use the web interface (sao), all steps work fine. I have seen the code :
modules/sale/sale.py", line 885, in process
modules/sale/sale.py", line 724, in create_invoice
modules/sale/sale.py", line 1337, in get_invoice_line
modules/account_product/product.py", line 49, in prop
modules/account_product/product.py", line 38, in wrapper
error.py", line 74, in raise_user_error
I do not know what it means but you must set the company in the context in version 5.0 for sure. It is so old that multi-company was not really supported.
If you consider the option to upgrade to newer series, on 6.0 we implemented the multi-company support so with that version it will be easier to manage such cases.