def evaluate(action, atype, record): ''' Evaluate the action with the record. ''' action = action.copy() if atype in ('print', 'action'): email = {} if 'pyson_email' in action: email = record.expr_eval(action['pyson_email']) if not email: email = {} if 'subject' not in email: email['subject'] = action['name'].replace('_', '') action['email'] = email elif atype == 'relate': encoder = PYSONEncoder() if 'pyson_domain' in action: action['pyson_domain'] = encoder.encode( record.expr_eval(action['pyson_domain'])) if 'pyson_context' in action: action['pyson_context'] = encoder.encode( record.expr_eval(action['pyson_context'])) else: raise NotImplementedError("Action type '%s' is not supported" % atype) return action
def add(self, model, name, domain): try: id_, = RPCExecute('model', 'ir.ui.view_search', 'create', [{ 'model': model, 'name': name, 'domain': PYSONEncoder().encode(domain), }]) except RPCException: return self.searches.setdefault(model, []).append((id_, name, domain))
def __init__(self, view, attrs): super(PYSON, self).__init__(view, attrs) self.encoder = PYSONEncoder() self.decoder = PYSONDecoder(noeval=True) self.entry.connect('key-release-event', self.validate_pyson)