Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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!
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...
About This Community
This platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 10/17/14, 5:02 AM|
|Seen: 963 times|
|Last updated: 3/16/15, 8:10 AM|