当前位置: 首页>>代码示例>>Python>>正文


Python Pool.read方法代码示例

本文整理汇总了Python中trytond.pool.Pool.read方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.read方法的具体用法?Python Pool.read怎么用?Python Pool.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trytond.pool.Pool的用法示例。


在下文中一共展示了Pool.read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: element

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import read [as 别名]
def element(model, record_id):
    """
    GET: Retrieve a representation of the member
    PUT: Write to the record
    DELETE: Delete the record

    :param model: name of the model
    :param record_id: ID of the record
    """
    model = Pool().get(model, type='model')
    record = model(record_id)

    if request.method == 'GET':
        # Return a dictionary of the read record
        fields_names = request.args.getlist('fields_names')
        return jsonify(
            model.read([record.id], fields_names)[0]
        )

    elif request.method == 'PUT':
        # Write to the record and return the updated record
        model.write([record], request.json)
        fields_names = request.args.getlist('fields_names')
        return jsonify(
            model.read([record.id], fields_names)[0]
        )

    elif request.method == 'DELETE':
        model.delete([record])
        return jsonify({}), 205
开发者ID:GauravButola,项目名称:tryton-restful,代码行数:32,代码来源:application.py

示例2: on_change_with_consulLibres

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import read [as 别名]
	def on_change_with_consulLibres(self,values):
		objConsultorio = Pool().get('cefiro.consultorio')
		objConsulta = Pool().get('cefiro.consulta')
		consultoriosTotId = objConsultorio.search([])
		res=[]
		for cons in objConsultorio.browse(consultoriosTotId):
			estaVacio = True
			consultasIDs = cons.consultas
			
			listaDic = objConsulta.read(consultasIDs)
			for dic in listaDic:
				i1 = values.get('horaIni')
				f1 = values.get('horaFin')
				i2=dic.get('horaIni')
				f2=dic.get('horaFin')
				if not ((i1==None) or (f1==None)):
					if not((f2<i1) or (f1<i2)):
						estaVacio = False
			if estaVacio:
				res.append(cons.id)

		self.libres = res
#		objConsulta.write(self.id,{'libres':Eval('res')})		

		return res
开发者ID:guzmanico23,项目名称:cefiro,代码行数:27,代码来源:cefiro.py

示例3: on_change_with_consulLibres

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import read [as 别名]
	def on_change_with_consulLibres(self,values):
		res = []
		i1 = values.get('horaini')
		f1 = values.get('horaFin')
		#Chequeo que la entrada sea correcta
		if ((i1==None) or (f1==None)):
			return res
		else:
			if(f1 < i1):
				return res
		objConsultorio = Pool().get('cefiro.consultorio')
		objConsulta = Pool().get('cefiro.consulta')
		consultoriosTotId = objConsultorio.search([])
		for cons in objConsultorio.browse(consultoriosTotId):
			estaVacio = True
			consultasIDs = cons.consultas
			
			listaDic = objConsulta.read(consultasIDs)
			for dic in listaDic:
				i2 = dic.get('horaini')
				f2 = dic.get('horaFin')
				if not((f2<i1) or (f1<i2)):
					estaVacio = False
			if estaVacio:
				res.append(cons.id)

		self.libres = res		

		return res
开发者ID:guzmanico23,项目名称:cefiro,代码行数:31,代码来源:cefiro.py

示例4: add_to_map

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import read [as 别名]
def add_to_map(ids, model_name, list_map):
    """
    Breadth first search of dependent records,
    this function is called recursively
    ids is a set of ids
    """
    assert(isinstance(ids, set))
    if not ids or model_name[0:4] == 'res.': return False

    added = False

    if model_name not in list_map:
        list_map[model_name] = set(ids)
        added = True
    else:
        old_len = len(list_map[model_name])
        list_map[model_name] = list_map[model_name].union(ids)
        added = len(list_map[model_name]) > old_len

    if not added: return False

    model = Pool().get(model_name)
    for name, ttype in model._fields.iteritems():
        if ttype._type == 'many2one' or ttype._type == 'one2one':
            added |= add_to_map(
                    set([ val[name] for val in model.read(list(ids), [name]) if val[name] ]), 
                    ttype.model_name, list_map)
        elif ttype._type == 'many2many' or ttype._type == 'one2many':
            ido = set()
            for rec in model.read(list(ids), [name]):
                ido = ido.union( set(rec[name]) )
            added |= add_to_map( ido, ttype.get_target().__name__, list_map )
    if not added: 
        return False
    add = False
    for k, i in list_map.iteritems(): 
        if k != model_name: 
            add |= add_to_map(i, k, list_map)
    return True
开发者ID:silpol,项目名称:tryton-bef,代码行数:41,代码来源:knitr.py

示例5: on_change_with_consulLibres

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import read [as 别名]
	def on_change_with_consulLibres(self,values):
		res=[]
		d1 = values.get('fechaini')
		d2 = values.get('fechaFin')
		diaBuscado = values.get('diaSemana')
		hini = values.get('horaIni')
		hfin = values.get('horaFin')

		#if d==str(i1.weekday()):
		#	return [1]

		#Chequeo que la entrada sea correcta
		if (((d1==None) or (d2==None) or (diaBuscado==None)) or (type(hini)!=time) or (type(hfin)!=time)):
			return [1]#res
		else:
			if((d2 < d1) or ((d1==d2) and (horafin < horaini))):
				return [2]#res

		#Consigo los límites de tiempos que necesito
		diaBuscInt=int(diaBuscado)
		[tini,tfin] = self.tiempos(d1,d2,diaBuscInt,hini,hfin)

		self.dtini = tini
		self.dtfin = tfin

		objConsultorio = Pool().get('cefiro.consultorio')
		objConsulta = Pool().get('cefiro.consulta')
		consultoriosTotId = objConsultorio.search([])
		for cons in objConsultorio.browse(consultoriosTotId):
			estaVacio = True
			consultasIDs = cons.consultas
			
			listaDic = objConsulta.read(consultasIDs)
			for dic in listaDic:
				i2=dic.get('fechaini')
				f2=dic.get('fechaFin')
				for ind in range(len(tini)):
					i1=tini[ind]
					f1=tfin[ind]
					if not((f2<i1) or (f1<i2)):
						estaVacio = False
			if estaVacio:
				res.append(cons.id)

		self.libres = res		

		return res
开发者ID:guzmanico23,项目名称:cefiro,代码行数:49,代码来源:reserva.py


注:本文中的trytond.pool.Pool.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。