Log in with external script fails

Hi,

As this is in python, I’m assuming there is a good reason why you are not using proteus for this?

This probably won’t be as fast (until Issue 7783: Allow to use session key instead of login/password - Tryton issue tracker), it uses xmlrpc instead of json-rpc, and is for 5.2 (but should work for 4.8):

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from proteus import Model, config

# Tryton server connection settings
HOST = 'demo5.2.tryton.org'
PORT = '8000'
DB = 'demo5.2'
USER = 'admin'
PASSWORD = 'admin'


if __name__ == '__main__':
    config.set_xmlrpc(
        url='http://{user}:{password}@{host}:{port}/{db}/'.format(
            user=USER, password=PASSWORD, host=HOST, port=PORT, db=DB))

    Sale = Model.get('sale.sale')

    domain = [('state', '=', 'processing')]
    max_num_of_records = 2
    sales = Sale.find(domain, limit=max_num_of_records)
    for sale in sales:
        print("{number}: {date} {party} ({lines}) {currency}{value}".format(
            number=sale.number, date=sale.sale_date, party=sale.party.rec_name,
            lines=len(sale.lines), currency=sale.currency.symbol,
            value=sale.total_amount))