Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

Re: Problem with computed default values

by
ClosingAp Open Source Integrators Europe, LDA, Daniel Reis
- 11/04/2016 19:04:35

FYI I used the code below.
Adding an init_hook would be nice, but I'm still evaluating if it's worth the trouble for my use case.
 

     @api.model
     def create(self, vals):
         vals['token'] = str(uuid.uuid4())
         return super(Applicant, self).create(vals)

     @api.multi
     def write(self, vals):
         if len(self) == 1 and not self.token:
             vals['token'] = str(uuid.uuid4())
         return super(Applicant, self).write(vals)

--
DR

Reference