def execute(db, uid, obj, method, *args, **kw): with odoo.registry(db).cursor() as cr: check_method_name(method) res = execute_cr(cr, uid, obj, method, *args, **kw) if res is None: _logger.info('The method %s of the object %s can not return `None` !', method, obj) return res
def execute(db, uid, obj, method, *args, **kw): threading.currentThread().dbname = db with odoo.registry(db).cursor() as cr: check_method_name(method) res = execute_cr(cr, uid, obj, method, *args, **kw) if res is None: _logger.info('The method %s of the object %s can not return `None` !', method, obj) return res
def call(self, model, method, ids=None, context=None, args=None, kwargs=None, **kw): check_method_name(method) ctx = request.session.context.copy() ctx.update(context and parse_value(context) or {}) ids = ids and parse_value(ids) or [] args = args and parse_value(args) or [] kwargs = kwargs and parse_value(kwargs) or {} records = request.env[model].with_context(ctx).browse(ids) result = getattr(records, method)(*args, **kwargs) content = json.dumps(result, sort_keys=True, indent=4, cls=RecordEncoder) return Response(content, content_type='application/json;charset=utf-8', status=200)
def _call_kw(self, model, method, args, kwargs): check_method_name(method) return call_kw(request.env[model], method, args, kwargs)