Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
2700 มุมมอง

Hey

I am trying to implement safe_eval to calculate some formulas but when I try to "import math" it gives me an error  


safe_eval('aoc = math.pi * (radius**2)',{'radius': 3},mode='exec',nocopy= True)
Any suggestions would be greatly appreciated

Thanks


อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

I  blacklisted the import function somewhere in tools.py and now I can import math function

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,
Can you try importing the library “from odoo.tools.safe_eval import safe_eval” instead of using math library and then use the function safe_eval

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ค. 23
1504
1
ก.ย. 22
3078
3
พ.ค. 23
6911
0
พ.ย. 22
2111
0
ต.ค. 22
2680