Contributors mailing list archives

contributors@odoo-community.org

Re: Problem with computed default values

by
ThinkOpen Solutions Portugal, Daniel Reis
- 11/04/2016 17: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