On 27 Feb 10:10, Iasmini - Gmail wrote: > Em 27/02/2014 08:50, Cédric Krier escreveu: > >On 27 Feb 08:43, Iasmini - Gmail wrote: > >>Hi, > >> > >>I need to do something just before saving. I did this: > >> > >>class Invoice: > >> __name__ = 'account.invoice' > >>... > >> def save(self): > >> if self.rps_number == '': > >> if not self.create_rps_number(): > >> self.raise_user_error(u'xxxx!') > >> > >> super(Invoice, self).save() > >> > >>But this function is not called. Why? > >Because save is a recent method added for syntactic sugar and so it is > >not always (almost never) called. > >I think what you are looking for is the validate method: > > > > > > http://doc.tryton.org/3.0/trytond/doc/ref/models/models.html?highlight=validate#trytond.model.ModelStorage.validate > > > I did on validate(). I'm setting the value of the field numero_rps > with the created numero_rps by method gera_numero_rps() called on > validate(). But on invoice this field is getting null after saving. > Why? Save method is called after validate(), right?
No validate is called after the create/write. -- Cédric Krier - B2CK SPRL Email/Jabber: [email protected] Tel: +32 472 54 46 59 Website: http://www.b2ck.com/
pgp4bHIxzqABH.pgp
Description: PGP signature
