Community mailing list archives


Odoo 8 computed field issue

Yassine TEIMI
- 11/20/15 04:39:17

I want to create a computed field, wich multiplies two different field values : 

The first field value is on the current record.
The second field value is on another record (on the same model), and then should be searched, and retrieved, following some conditions.

(I'm trying to get two values for the same field, but on two different records, of course because the field value changes from a record to another)

Here is my code : 

from openerp import models, fields, api 

class SurveyUserInputLine(models.Model):
    _inherit = 'survey.user_input_line'
     percentage_row = fields.Float('Atteinte objectif', compute='_compute_percentage_row', store=True)
    def _compute_percentage_row(self):
        for record in self:
            if record.col_label == 'Pondera':
             pond = record.value_number
             id_token = record.user_input_id.token
             row_value =
             domain = [('col_label','=','Resultat'),('','=', row_value),('user_input_id.token','=', id_token)]
             result =
record.percentage_row = float(result*pond)/100
My problem is on the line in bold, it doesn't retrieve anything, the domain seems correct. 

Maybe there is another way to achieve my query.

For further informations, it's on the survey_user_input_line object, and I'm trying to do the multiplication of two values but not on the same record. 

Thanks for your help, I'm blocked ... 



Yassine TEIMI

Consultant & Odoo Project Manager
TEL : +212 6-27 33 30 78