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

how to replace some strings to float value and do calculations?

By
vadivel
on 8/30/16, 2:38 AM 180 views

Hi friends,

I have a char field,which has formula for calculations (char field value is 0.17*(@tw)+0.6*(@tw-500) ).Here i need to replace @tw with some float value and do calculations and need to return float value.How to achieve this.

Thanks in advance.

it shows invalid syntax error on .20*@tw

vadivel
on 8/30/16, 3:07 AM

use it without @

just 0.20*tw

its working

yousif Mobark
on 8/30/16, 10:57 AM
1
yousif Mobark
On 8/30/16, 2:57 AM

hello vadivel

you can do it with "eval" method

def formula( self ):     
    tw=10 #your value
  return eval ('0.17*(tw)+0.6*(tw-500)')

Good Luck


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: 8/30/16, 2:38 AM
Seen: 180 times
Last updated: 8/30/16, 3:08 AM