proteus


Nameproteus JSON
Version 7.4.0 PyPI version JSON
download
home_pagehttp://www.tryton.org/
SummaryLibrary to access Tryton server as a client
upload_time2024-11-04 17:47:15
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/ff/10/e686018fd2926c9e11034efdb367f865ec6b0a6f1d888d4f704118f2c323/proteus-7.4.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.4.0",
    "project_urls": {
        "Bug Tracker": "https://bugs.tryton.org/",
        "Documentation": "https://docs.tryton.org/latest/client-library/",
        "Download": "http://downloads.tryton.org/7.4/",
        "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": "60660b4c7e776e4edd8f0560939ccd9301c35913f35ea0e2402802d22942fa29",
                "md5": "392ceebc79a98cbd9241214a78a397c6",
                "sha256": "4c4b10f88253325ebf113d83c759f36a39272f6564b41fec95056f1742945ba5"
            },
            "downloads": -1,
            "filename": "proteus-7.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "392ceebc79a98cbd9241214a78a397c6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 40419,
            "upload_time": "2024-11-04T17:47:13",
            "upload_time_iso_8601": "2024-11-04T17:47:13.524976Z",
            "url": "https://files.pythonhosted.org/packages/60/66/0b4c7e776e4edd8f0560939ccd9301c35913f35ea0e2402802d22942fa29/proteus-7.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff10e686018fd2926c9e11034efdb367f865ec6b0a6f1d888d4f704118f2c323",
                "md5": "f9d78a34039a6aae3a3dd92b14716dc5",
                "sha256": "e04eefa6e68cddf1ff00688308e636bc330031a390dd83cf3bf41090ef326ad1"
            },
            "downloads": -1,
            "filename": "proteus-7.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f9d78a34039a6aae3a3dd92b14716dc5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 42106,
            "upload_time": "2024-11-04T17:47:15",
            "upload_time_iso_8601": "2024-11-04T17:47:15.015221Z",
            "url": "https://files.pythonhosted.org/packages/ff/10/e686018fd2926c9e11034efdb367f865ec6b0a6f1d888d4f704118f2c323/proteus-7.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-04 17:47:15",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "proteus"
}
        
Elapsed time: 0.44866s