Using proteus to browse / edit / .. tryton's data

(23 comments)

Going to be using this blog post to add bits and pieces of how to use proteus to handle data in tryton.

Just noticed the proteus readme is quite good: here's a link to the proteus github

IMPORTANT: One thing I noticed (the hard way) is that if you are connected with a proteus session and you add&activate a module (at least when it is not done using proteus) you need to re-connect as it does not seem to add things like extra fields added to models otherwise.

First thing: connect:

from proteus import config, Model, Wizard, Report
pcfg = config.set_trytond(database='trytond', config_file='/etc/tryton/trytond.conf')

Then we just get ourselved our parties:

Party = Model.get('party.party')
all_parties=Party.find()
for p in all_parties:
    print(p.name)
    print(p.addresses[0].full_address
    )

This will print out all names and the first full address of each.

Now to add a new one:

np = Party()
np.name='Test Customer from Proteus'
np.save()

This just creates a new party with just a name. default values that are set up (like default language) are set. Until it is saved the id (np.id) is -1. By default it also comes with one (empty address).

Here's how to edit/add:

np.addresses[0].zip='1234'
np.addresses.new(zip='2345')
np.save() # don't forget this

Extra fields from other (possibly own) can be accessed exactly the same way as the normal ones (just don't forget to reconnect - like i did ;) )

Here's how you refresh the data:

np.reload()

d

Currently unrated

Comments

Comment awaiting approval 1 week, 4 days ago

Comment awaiting approval 1 week, 3 days ago

Comment awaiting approval 1 week, 3 days ago

Comment awaiting approval 1 week, 3 days ago

Comment awaiting approval 1 week, 3 days ago

Comment awaiting approval 1 week, 3 days ago

Comment awaiting approval 1 week, 3 days ago

Comment awaiting approval 1 week, 3 days ago

Comment awaiting approval 1 week, 3 days ago

Comment awaiting approval 1 week, 3 days ago

Comment awaiting approval 1 week, 3 days ago

Comment awaiting approval 1 week, 3 days ago

Comment awaiting approval 1 week, 2 days ago

Comment awaiting approval 1 week, 2 days ago

Comment awaiting approval 1 week, 1 day ago

Comment awaiting approval 1 week, 1 day ago

Comment awaiting approval 1 week, 1 day ago

Comment awaiting approval 1 week, 1 day ago

Comment awaiting approval 1 week, 1 day ago

Comment awaiting approval 1 week ago

Comment awaiting approval 6 days, 15 hours ago

Comment awaiting approval 4 days, 3 hours ago

Comment awaiting approval 1 day, 14 hours ago

New Comment

required

required (not published)

optional

required

Recent Posts

Archive

2019
2018
2014
2012
2011
2010
2009
2008
2007

Categories

Authors

Feeds

RSS / Atom