title: Odoo : Computed fields, don't update in some case?
body: <p>I have a computed field, that has to be updated when a field is updated.
  So I use <code>@api.depends('field1')</code> and link the function </p>
  
  <pre><code>field_to_compute: fields.integer(compute='the_function' store=True)
  </code></pre>
  
  <p>It works fine.</p>
  
  <p>But know I'd like to update it when <code>field1</code> take value <code>A</code> and to remain the same when <code>field1</code> take the value <code>B</code>. But the old value of <code>field_to_compute</code> was imported from a database and wasn't computed.</p>
  
  <p>So I have two problems:</p>
  
  <ul>
  <li>How can I allow the user to set the value himself. (I can modify it,
  but when I create a new member, it will be computed and only after
  the first save I can modify it in UI)</li>
  <li><p>How can I make something like:</p>
  
  <pre><code>@api.depends('field1')
  def the_function(self): 
       value = self.field1
       if value == A:
           field_to_compute = 123123
       elif value == B: 
           field_to_compute = stored_field_to_compute #field_to_compute
  </code></pre>
  
  <p>keep the same value as the one stored before</p></li>
  </ul>
  
  <p><strong>EDIT (example):</strong></p>
  
  <p>I'm in a res.partner in the current model, inheriting of res.partner.
  I've a field in it : </p>
  
  <pre><code>'model_state': field.char(compute='compute_type', string = 'Demand', store=True, readonly=True)
  </code></pre>
  
  <p>In a second res.partner inheriting of res.partner too, in an other module, I have 2 fields : <code>grade</code> and  <code>status</code>, respectively an int, and a many2one. Computing the same compute_type as model_state, the same way.</p>
  
  <p>I also in this res.partner, have a one2many field : <code>link_ids</code></p>
  
  <p>So my function is : </p>
  
  <pre><code>@api.depends('link_ids.type', 'link_ids.result')
  def compute_type(self):
      for record in self:
         if self.link_ids:
             if self.link_ids.result == 'A':
                 if self.link_ids.type == 'type1':
                     record.model_state = 'Mytext'
                     record.grade = 15
                     record.state = 1 #this is an id
                 elif self.link_ids.result == 'B':
                     record.model_state = 'MySecondText'
                     record.state = 2 #this is an id
  </code></pre>
  
  <p>I won't put everything because it's like 25 elif (not all about the same if etc etc) so it wouldn't be pertinent. I checked a lot of time if nothing was modifying record.grade if nothing is done on it, in else or dunno, but it's just being emptied.</p>
  
  <p>Basically, simplified, I'd like to do something if the result is "OK" to a vote. And change the id of the state to "accepted", give a text (like a title), and give him a better grade, and if it's not, he have an id of the state "denied", give an other text, and keep the same grade as he has actually.</p>