Importing Parties

10 views
Skip to first unread message

Kurt Miebach

unread,
Jan 26, 2011, 7:58:27 AM1/26/11
to Tryton
Hi,

I am preparing to import a lot of parties using the "tryton as a
module" code from this example:

http://code.google.com/p/tryton/wiki/HowToUseTrytondAsAModule#Version_1.8

I am using this example to add new parties, and it seems to work
because after each loop I receive an incremented new_party_id
(3,4,5,...):

for party in myparties:
with Transaction().start(DBNAME, user, None):
new_party_id = party_obj.create({'name': party.name})


But in the Tryton Client there are no parties visible when I search. I
suspect I need to add more fields? Or do I need to add adresses to the
parties? Or maybe connect them to a company?

Thank You
Kurt Miebach

Sharoon Thomas

unread,
Jan 26, 2011, 8:36:26 AM1/26/11
to try...@googlegroups.com
Hello Kurt,

You need to manually commit the changes.

and it is better to start the transaction once and put all the records in at once and then commit.

party_obj = self.pool.get('party.party')
with Transaction().start(DBNAME, user, None):
    for party in myparties:
        party_obj.create({'name': party.name})
    Transaction().cursor.commit()


--
try...@googlegroups.com mailing list



--
Sharoon Thomas
Business Analyst & Open Source ERP Consultant
Founder & CEO @ http://openlabs.co.in

Kurt Miebach

unread,
Jan 26, 2011, 5:42:52 PM1/26/11
to Tryton
Thank you Sharoon, now it works.

In the Tryton 1.8 example at google code that I copied the commit
statement is already missing. I added a comment on that page.

Kurt Miebach

On Jan 26, 2:36 pm, Sharoon Thomas <sharoontho...@teagarden.in> wrote:
> Hello Kurt,
>
> You need to manually commit the changes.
>
> and it is better to start the transaction once and put all the records in at
> once and then commit.
>
> party_obj = self.pool.get('party.party')
> with Transaction().start(DBNAME, user, None):
> for party in myparties:
> party_obj.create({'name': party.name})
> Transaction().cursor.commit()
>
> On Wed, Jan 26, 2011 at 6:28 PM, Kurt Miebach <kwmieb...@gmail.com> wrote:
> > I am preparing to import a lot of parties using the "tryton as a
> > module" code from this example:
>
> >http://code.google.com/p/tryton/wiki/HowToUseTrytondAsAModule#Version...
>
> > I am using this example to add new parties, and it seems to work
> > because after each loop I receive an incremented new_party_id
> > (3,4,5,...):
>
> > for party in myparties:
> > with Transaction().start(DBNAME, user, None):
> > new_party_id = party_obj.create({'name': party.name})
>
> > But in the Tryton Client there are no parties visible when I search. I
> > suspect I need to add more fields? Or do I need to add adresses to the
> > parties? Or maybe connect them to a company?

Cédric Krier

unread,
Jan 26, 2011, 5:56:08 PM1/26/11
to try...@googlegroups.com
On 26/01/11 14:42 -0800, Kurt Miebach wrote:
> Thank you Sharoon, now it works.
>
> In the Tryton 1.8 example at google code that I copied the commit
> statement is already missing. I added a comment on that page.

Fixed.

--
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: cedric...@b2ck.com
Website: http://www.b2ck.com/

Reply all
Reply to author
Forward
0 new messages