Update record with Model.save() from flask tryton

Dear Tryton team,

I’m trying to update the party email from flask tryton with:

@tryton.transaction(readonly=False)
def update():
            party = Party.search(['id','=',1])[0]
            party.email = "newmail@gmail.com"
            party.email = party.email # I read from another topic that I should trigger manually
            party.save()

Doesn’t seem to work the save() for me, value is not getting updated and no error raised. am I on the right path?

Thanks for your help,

The email fields is a functional one wich does not have any setter method so it is not possible to write on it. So the save method ingores it’s values and does not try tro write on it.

You should create a contact mechanism record related to the party instead or add a setter method for this field.

I can see clearly now.
My final solution to update first email looks like:

mail = Contact.search([('party','=',1),('type','=','email')])[0]
mail.value = data["mail"]
mail.save()

I need only one email address for party = 1, so above code works for my purposes
Thank you again. now all it’s working.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.