In the object hr.salary.rule in field amount_python_compute I need to transform a string into a integer.
I tried
int('12')
float('12')
eval('12')
import ast
ast.literal_eval("12")
but none of these works.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
In the object hr.salary.rule in field amount_python_compute I need to transform a string into a integer.
I tried
int('12')
float('12')
eval('12')
import ast
ast.literal_eval("12")
but none of these works.
you can modify the code in server\openerp\tools\safe_eval.py in function safe_eval in the dictionary variable __builtins__ add:
'int':int
this is the dictionary __builtins__ to note the available functions plus int, those are the funtions that you can use in any module that use safe_eval
__builtins__ = {
'__import__': _import,
'True': True,
'False': False,
'None': None,
'str': str,
'globals': locals,
'locals': locals,
'bool': bool,
'dict': dict,
'list': list,
'tuple': tuple,
'map': map,
'abs': abs,
'min': min,
'max': max,
'reduce': reduce,
'filter': filter,
'round': round,
'len': len,
'set' : set,
'int': int
}
In my opinion this should be implemented in a launchpad branch as I believe int function have no security risks and is a very common function
Create an account today to enjoy exclusive features and engage with our awesome community!
Přihlásit se| Related Posts | Odpovědi | Zobrazení | Aktivita | |
|---|---|---|---|---|
|
0
čvc 15
|
4094 | |||
|
0
pro 24
|
1606 | |||
|
2
bře 24
|
2685 | |||
|
0
bře 24
|
1911 | |||
|
Refer a Salary rule in another rule
Vyřešeno
|
2
úno 24
|
2545 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.
Did you make a custom module, do you change it in the XML, But most important, what is the errormessage(s) and what is in the logfile?
it just throw the exception of file hr_payroll.py of the funcion compute_rule raise osv.except_osv(_('Error!'), _('Wrong python code defined for salary rule %s (%s).')% (rule.name, rule.code))
I just found a workaround