proteus


Nameproteus JSON
Version 7.2.0 PyPI version JSON
download
home_pagehttp://www.tryton.org/
SummaryLibrary to access Tryton server as a client
upload_time2024-04-29 15:55:12
maintainerNone
docs_urlNone
authorTryton
requires_python>=3.8
licenseLGPL-3
keywords tryton library cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =======================
Tryton Scripting Client
=======================

A library to access Tryton's models like a client.

Example of usage
----------------

    >>> from proteus import config, Model, Wizard, Report

Configuration
~~~~~~~~~~~~~

Configuration to connect to a sqlite memory database using trytond as module.

    >>> config = config.set_trytond('sqlite:///:memory:')

There is also the ``config.set_xmlrpc`` method which can be used to connect
using a URL, and the ``config.set_xmlrpc_session`` method (when used as a
context manager) which connects for a session.

Activating a module
~~~~~~~~~~~~~~~~~~~

Find the module, call the activate button and run the upgrade wizard.

    >>> Module = Model.get('ir.module')
    >>> party_module, = Module.find([('name', '=', 'party')])
    >>> party_module.click('activate')
    >>> Wizard('ir.module.activate_upgrade').execute('upgrade')

Creating a party
~~~~~~~~~~~~~~~~

First instantiate a new Party:

    >>> Party = Model.get('party.party')
    >>> party = Party()
    >>> party.id < 0
    True

Fill the fields:

    >>> party.name = 'ham'

Save the instance into the server:

    >>> party.save()
    >>> party.name
    'ham'
    >>> party.id > 0
    True

Setting the language of the party
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The language on party is a ``Many2One`` relation field. So it requires to get a
``Model`` instance as value.

    >>> Lang = Model.get('ir.lang')
    >>> en, = Lang.find([('code', '=', 'en')])
    >>> party.lang = en
    >>> party.save()
    >>> party.lang.code
    'en'

Creating an address for the party
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Addresses are store on party with a ``One2Many`` field.
So the new address just needs to be appended to the list ``addresses``.

    >>> address = party.addresses.new(postal_code='42')
    >>> party.save()
    >>> party.addresses #doctest: +ELLIPSIS
    [proteus.Model.get('party.address')(...)]

Adding category to the party
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Categories are linked to party with a ``Many2Many`` field.

So first create a category

    >>> Category = Model.get('party.category')
    >>> category = Category()
    >>> category.name = 'spam'
    >>> category.save()

Append it to categories of the party

    >>> party.categories.append(category)
    >>> party.save()
    >>> party.categories #doctest: +ELLIPSIS
    [proteus.Model.get('party.category')(...)]

Print party label
~~~~~~~~~~~~~~~~~

There is a label report on ``Party``.

    >>> label = Report('party.label')

The report is executed with a list of records and some extra data.

    >>> type_, data, print_, name = label.execute([party], {})

Sorting addresses and register order
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Addresses are ordered by sequence which means they can be stored following a
specific order.
The ``set_sequence`` method stores the current order.

    >>> address = party.addresses.new(postal_code='69')
    >>> party.save()
    >>> address = party.addresses.new(postal_code='23')
    >>> party.save()

Now changing the order.

    >>> reversed_addresses = list(reversed(party.addresses))
    >>> while party.addresses:
    ...     _ = party.addresses.pop()
    >>> party.addresses.extend(reversed_addresses)
    >>> party.addresses.set_sequence()
    >>> party.save()
    >>> party.addresses == reversed_addresses
    True

Setting context
~~~~~~~~~~~~~~~

Make French translatable:

    >>> Language = Model.get('ir.lang')
    >>> french, = Language.find([('code', '=', 'fr')])
    >>> french.translatable = True
    >>> french.save()

Create a category in English:

    >>> Category = Model.get('party.category')
    >>> with config.set_context(language='en'):
    ...     category = Category(name="Category")
    ...     category.save()

Translate in French:

    >>> with config.set_context(language='fr'):
    ...     category_fr = Category(category.id)
    ...     category_fr.name = "Categorie"
    ...     category_fr.save()

Read in English:

    >>> category.reload()
    >>> category.name
    'Category'

Read in French:

    >>> category_fr.reload()
    >>> category_fr.name
    'Categorie'


            

Raw data

            {
    "_id": null,
    "home_page": "http://www.tryton.org/",
    "name": "proteus",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "tryton library cli",
    "author": "Tryton",
    "author_email": "foundation@tryton.org",
    "download_url": "https://files.pythonhosted.org/packages/89/7c/1d2899c0207d5d624a0d1996bea5b53934a2ae1fe29f9a8d181086ddf438/proteus-7.2.0.tar.gz",
    "platform": "any",
    "description": "=======================\nTryton Scripting Client\n=======================\n\nA library to access Tryton's models like a client.\n\nExample of usage\n----------------\n\n    >>> from proteus import config, Model, Wizard, Report\n\nConfiguration\n~~~~~~~~~~~~~\n\nConfiguration to connect to a sqlite memory database using trytond as module.\n\n    >>> config = config.set_trytond('sqlite:///:memory:')\n\nThere is also the ``config.set_xmlrpc`` method which can be used to connect\nusing a URL, and the ``config.set_xmlrpc_session`` method (when used as a\ncontext manager) which connects for a session.\n\nActivating a module\n~~~~~~~~~~~~~~~~~~~\n\nFind the module, call the activate button and run the upgrade wizard.\n\n    >>> Module = Model.get('ir.module')\n    >>> party_module, = Module.find([('name', '=', 'party')])\n    >>> party_module.click('activate')\n    >>> Wizard('ir.module.activate_upgrade').execute('upgrade')\n\nCreating a party\n~~~~~~~~~~~~~~~~\n\nFirst instantiate a new Party:\n\n    >>> Party = Model.get('party.party')\n    >>> party = Party()\n    >>> party.id < 0\n    True\n\nFill the fields:\n\n    >>> party.name = 'ham'\n\nSave the instance into the server:\n\n    >>> party.save()\n    >>> party.name\n    'ham'\n    >>> party.id > 0\n    True\n\nSetting the language of the party\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe language on party is a ``Many2One`` relation field. So it requires to get a\n``Model`` instance as value.\n\n    >>> Lang = Model.get('ir.lang')\n    >>> en, = Lang.find([('code', '=', 'en')])\n    >>> party.lang = en\n    >>> party.save()\n    >>> party.lang.code\n    'en'\n\nCreating an address for the party\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nAddresses are store on party with a ``One2Many`` field.\nSo the new address just needs to be appended to the list ``addresses``.\n\n    >>> address = party.addresses.new(postal_code='42')\n    >>> party.save()\n    >>> party.addresses #doctest: +ELLIPSIS\n    [proteus.Model.get('party.address')(...)]\n\nAdding category to the party\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nCategories are linked to party with a ``Many2Many`` field.\n\nSo first create a category\n\n    >>> Category = Model.get('party.category')\n    >>> category = Category()\n    >>> category.name = 'spam'\n    >>> category.save()\n\nAppend it to categories of the party\n\n    >>> party.categories.append(category)\n    >>> party.save()\n    >>> party.categories #doctest: +ELLIPSIS\n    [proteus.Model.get('party.category')(...)]\n\nPrint party label\n~~~~~~~~~~~~~~~~~\n\nThere is a label report on ``Party``.\n\n    >>> label = Report('party.label')\n\nThe report is executed with a list of records and some extra data.\n\n    >>> type_, data, print_, name = label.execute([party], {})\n\nSorting addresses and register order\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nAddresses are ordered by sequence which means they can be stored following a\nspecific order.\nThe ``set_sequence`` method stores the current order.\n\n    >>> address = party.addresses.new(postal_code='69')\n    >>> party.save()\n    >>> address = party.addresses.new(postal_code='23')\n    >>> party.save()\n\nNow changing the order.\n\n    >>> reversed_addresses = list(reversed(party.addresses))\n    >>> while party.addresses:\n    ...     _ = party.addresses.pop()\n    >>> party.addresses.extend(reversed_addresses)\n    >>> party.addresses.set_sequence()\n    >>> party.save()\n    >>> party.addresses == reversed_addresses\n    True\n\nSetting context\n~~~~~~~~~~~~~~~\n\nMake French translatable:\n\n    >>> Language = Model.get('ir.lang')\n    >>> french, = Language.find([('code', '=', 'fr')])\n    >>> french.translatable = True\n    >>> french.save()\n\nCreate a category in English:\n\n    >>> Category = Model.get('party.category')\n    >>> with config.set_context(language='en'):\n    ...     category = Category(name=\"Category\")\n    ...     category.save()\n\nTranslate in French:\n\n    >>> with config.set_context(language='fr'):\n    ...     category_fr = Category(category.id)\n    ...     category_fr.name = \"Categorie\"\n    ...     category_fr.save()\n\nRead in English:\n\n    >>> category.reload()\n    >>> category.name\n    'Category'\n\nRead in French:\n\n    >>> category_fr.reload()\n    >>> category_fr.name\n    'Categorie'\n\n",
    "bugtrack_url": null,
    "license": "LGPL-3",
    "summary": "Library to access Tryton server as a client",
    "version": "7.2.0",
    "project_urls": {
        "Bug Tracker": "https://bugs.tryton.org/",
        "Documentation": "https://docs.tryton.org/latest/client-library/",
        "Download": "http://downloads.tryton.org/7.2/",
        "Forum": "https://www.tryton.org/forum",
        "Homepage": "http://www.tryton.org/",
        "Source Code": "https://code.tryton.org/tryton"
    },
    "split_keywords": [
        "tryton",
        "library",
        "cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "955c7bfe67de7c3c3b56e9cec1c15b94e470d2b3bbb23440a5518c66288bc02f",
                "md5": "8f42b86a4521895b362b0d781c8518f7",
                "sha256": "e87ea99e779ca71afed3970132d8bc34c799b451a0f9b487172ed5c98e8f9cff"
            },
            "downloads": -1,
            "filename": "proteus-7.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8f42b86a4521895b362b0d781c8518f7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 40393,
            "upload_time": "2024-04-29T15:55:09",
            "upload_time_iso_8601": "2024-04-29T15:55:09.338918Z",
            "url": "https://files.pythonhosted.org/packages/95/5c/7bfe67de7c3c3b56e9cec1c15b94e470d2b3bbb23440a5518c66288bc02f/proteus-7.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "897c1d2899c0207d5d624a0d1996bea5b53934a2ae1fe29f9a8d181086ddf438",
                "md5": "6b2a26191284e4f5576c39e35b211242",
                "sha256": "a6ad378a4737bf71a15a82e723adfddfa53db2fc30989222e4f1b21e87eb2482"
            },
            "downloads": -1,
            "filename": "proteus-7.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6b2a26191284e4f5576c39e35b211242",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 42084,
            "upload_time": "2024-04-29T15:55:12",
            "upload_time_iso_8601": "2024-04-29T15:55:12.079268Z",
            "url": "https://files.pythonhosted.org/packages/89/7c/1d2899c0207d5d624a0d1996bea5b53934a2ae1fe29f9a8d181086ddf438/proteus-7.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-29 15:55:12",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "proteus"
}
        
Elapsed time: 0.24807s