Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2686 Lượt xem

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


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 5 23
1499
1
thg 9 22
3074
3
thg 5 23
6882
0
thg 11 22
2102
0
thg 10 22
2663