Created
November 19, 2014 18:46
-
-
Save alexander-arce/a6d355be8249dcd74cb1 to your computer and use it in GitHub Desktop.
Auto reply Server Action::OpenErp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #If you need debug you variables send to python code | |
| #then modify openerp/tools/safe_eval.py | |
| #You need add opcodes for print statement in _SAFE_OPCODES variable | |
| _SAFE_OPCODES = _EXPR_OPCODES.union(set(opmap[x] for x in [ | |
| 'LOAD_NAME', 'CALL_FUNCTION', 'COMPARE_OP', 'LOAD_ATTR', | |
| 'STORE_NAME', 'GET_ITER', 'FOR_ITER', 'LIST_APPEND', 'DELETE_NAME', | |
| 'JUMP_FORWARD', 'JUMP_IF_TRUE', 'JUMP_IF_FALSE', 'JUMP_ABSOLUTE', | |
| 'MAKE_FUNCTION', 'SLICE+0', 'SLICE+1', 'SLICE+2', 'SLICE+3', | |
| # New in Python 2.7 - http://bugs.python.org/issue4715 : | |
| 'JUMP_IF_FALSE_OR_POP', 'JUMP_IF_TRUE_OR_POP', 'POP_JUMP_IF_FALSE', | |
| 'POP_JUMP_IF_TRUE', 'SETUP_EXCEPT', 'END_FINALLY', | |
| 'LOAD_FAST', 'STORE_FAST', 'DELETE_FAST', | |
| 'LOAD_GLOBAL', # Only allows access to restricted globals | |
| 'PRINT_EXPR', 'PRINT_ITEM', 'PRINT_ITEM_TO', 'PRINT_NEWLINE', 'PRINT_NEWLINE_TO', #OPCODES for print | |
| ] if x in opmap)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # You can use the following variables: | |
| # - self: ORM model of the record on which the action is triggered | |
| # - object: browse_record of the record on which the action is triggered if there is one, otherwise None | |
| # - pool: ORM model pool (i.e. self.pool) | |
| # - time: Python time module | |
| # - cr: database cursor | |
| # - uid: current user id | |
| # - context: current context | |
| # If you plan to return an action, assign: action = {...} | |
| # template_id is the id of you mail template generated | |
| # res_id is the id from object used in render template, ej. context.get('active_id') | |
| print context #for debug purpose, only if you modify openerp/tools/safe_eval.py | |
| if context.get('active_id'): | |
| self.pool.get('email.template').send_mail(cr, uid, template_id, res_id,True, context=context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment