ipython loading .py files to make interactive use of tryton faster

(0 comments)

So I was busy testing tryton import scripts .. which means constantly re-setting my DB to clear it (deleting just takes 10 times longer than SQL restore)..

But since I drop and recreate the DB the ipython session also needs to disconnect... which is a bit inconvenient because of setup,..

Fortunately ipython has %load - which makes this super easy:

Screenshot of script

(screenshot to show off just how nicely everything is even highlighted too)

now here the code to copy paste if someone wants it:

import myinit

from proteus import config, Model, Wizard, Report
pcfg = config.set_trytond(database='tryton', config_file='/etc/tryton/trytond.conf')
Party = Model.get('party.party')
Addr = Model.get('party.address')
Cont = Model.get('party.contact_mechanism')
Note = Model.get('ir.note')
Lang = Model.get('ir.lang')
Categ = Model.get('party.category')
Country = Model.get('country.country')
SubD = Model.get('country.subdivision')
Cont = Model.get('party.contact_mechanism')
Ident = Model.get('party.identifier')

try:
    prm, = Party.find([('code', '=', '1')])
except:
    print('Could not load party with code 1')

myinit just contains the code to hide warnings from this stackoverflow question

This is super useful in setting up the basic types I need for my testing.

Currently unrated

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

Recent Posts

Archive

2021
2020
2019
2018
2014
2012
2011
2010
2009
2008
2007

Categories

Authors

Feeds

RSS / Atom