Library to access Tryton server as a client
Project description
A library to access Tryton’s models like a client.
Installing
See INSTALL
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:')
Installing 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 instanciate 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 u'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 u'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(zip='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], {})
Support
If you encounter any problems with Tryton, please don’t hesitate to ask questions on the Tryton bug tracker, mailing list, wiki or IRC channel:
http://bugs.tryton.org/ http://groups.tryton.org/ http://wiki.tryton.org/ irc://irc.freenode.net/tryton
License
See LICENSE
Copyright
See COPYRIGHT
For more information please visit the Tryton web site:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file proteus-4.2.5.tar.gz
.
File metadata
- Download URL: proteus-4.2.5.tar.gz
- Upload date:
- Size: 38.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/36.7.2 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00421879a4a2657f165cc7769aaa60cf92b3cd577470f96233590d181990dac9 |
|
MD5 | f3182e4c792b99c33a13396cc9bf927f |
|
BLAKE2b-256 | 831082f3d6baab5f42b5f22c1e9df834592e0db02c284221e78fbc4d16c56d2f |
Provenance
File details
Details for the file proteus-4.2.5-py3-none-any.whl
.
File metadata
- Download URL: proteus-4.2.5-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/36.7.2 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c8b77c1fbe7b8b5124319a002f423c377676bda9a39c01f485e9d4a455d61cd |
|
MD5 | f2ff4c3d91b9477ee24d24abf13b8464 |
|
BLAKE2b-256 | fde119f125410fc176e73bb9e64db99d9cd4f8f5879dba7e11e1f5284a620323 |
Provenance
File details
Details for the file proteus-4.2.5-py2-none-any.whl
.
File metadata
- Download URL: proteus-4.2.5-py2-none-any.whl
- Upload date:
- Size: 25.8 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/36.7.2 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d4989e2a2e85d13e59d5baf001931d1e5df54798e0c36e2d9e596d2a624b65a |
|
MD5 | 4d09ab53b4ed6af1ad8a337257322895 |
|
BLAKE2b-256 | 2727c87585b8d465b00c7f0a1956e9d2f8fbfbda910c7f59fdf09e9f95c6c4bd |