Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Odoo 8 computed field issue

By
Yassine TEIMI
on 11/20/15, 4:41 AM 626 views

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)
   
     @api.multi
    @api.depends('value_number','user_input_id','value_suggested_row','col_label')

     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 = record.value_suggested_row.id
                domain = [('col_label','=','Resultat'),('value_suggested_row.id','=', row_value),('user_input                 _id.token','=', id_token)]
                result = self.search(domain).value_number
                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 ...

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/20/15, 4:41 AM
Seen: 626 times
Last updated: 11/20/15, 4:41 AM