Odoo Help


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.


how to multiplicate field.float * field.many2many ???

abdallah ghrir
on 10/17/14, 5:02 AM 626 views


how to multiplicate  field.float * field.many2many ???


You need to explain a whole lot more, because this question makes no sense now. Give some examples and provide code if you already made some. Tell us what you tried already.

Ludo - Neobis
on 10/17/14, 6:10 AM

def add_a_b(self, cr, uid, ids, name, arg, context=None): res = {} for record in self.browse(cr, uid, ids,context): res[record.id] = record.price_subtotal + record.tax_id return res _columns = { 'p_tax' : fields.function(add_a_b,string='Prix TTC'), }

abdallah ghrir
on 10/17/14, 6:28 AM


| 5 4 6
Zagreb | Karlovac, Croatia

there is only 10 kind of people the ones that understand binary ... and others

On 10/21/14, 8:24 AM

you need to understand concept of fields and what that field contains:
- field float contains a float number, usable imediatley
- many2many contains ids (from relation table) , you need to get the desired value of other model first...
so you could for example:

for m2m in many2many_field:
    res[m2m.id] = field.float * m2m.some_value_field
    # NOTE: some_value_field  need to be of type float or integer , othervise you will get an error

wich wil return a list of m2m field values multiplied with field.float...

may the source be with you!

thnaks :)

abdallah ghrir
on 10/24/14, 6:22 AM


| 5 4 7
Bengaluru, India

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

On 10/21/14, 9:44 AM

You got to understand the symentics of each data type and its behaviour...

So from your above code, I suppose you are trying to add all taxes ... But Tax_id is of type M2M, which is nothing but again a list of browse records.. hence you got to loop throug it to perform your action...

Your code should be like this....

for record in self.browse(cr, uid, ids,context):
     for tax in record.tax_id:
          res[record.id] += record.price_subtotal * tax.amount   


Do refer, standard functionality/ calculations  say Invoice, Purchase... etc so you will get a better idea of it...


thanks it works ;) ;) ;)

abdallah ghrir
on 10/24/14, 6:22 AM

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

2 follower(s)


Asked: 10/17/14, 5:02 AM
Seen: 626 times
Last updated: 3/16/15, 8:10 AM