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


Python Pool.browse方法代码示例

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


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

示例1: transition_check

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
 def transition_check(self):        
     Plots = Pool().get('forest.plot')
     Preco = Pool().get('forest_work.preconisation')
     plots_succeed = []
     plots_failed = []        
     Lignes = Preco.browse(Transaction().context.get('active_ids'))
     for ligne in Lignes:            
         cursor = Transaction().cursor
         cursor.execute(
             'SELECT p.id '
             'FROM forest_plot p '                
             'WHERE p.id=%s '
             'GROUP BY p.id' % (ligne.plot.id))
         for plotid in cursor.fetchall():                
             plots = Plots.browse(plotid)                
             for plot in plots:            
                 try:
                     if plot.travaux:
                         print "plots_failed ok"
                         self.create_travaux(plot)                    
                         plots_failed.append(plot.id)                                               
                     else:
                         print "plots_succeed ok"
                         self.create_travaux(plot)                    
                         plots_succeed.append(plot.id)                            
                 except Exception, e:
                     raise            
             self.result.plots_succeed = plots_succeed
             self.result.plots_failed = plots_failed
开发者ID:silpol,项目名称:tryton-bef,代码行数:31,代码来源:forest_work.py

示例2: update_comment

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
    def update_comment(self, task_id, comment_id):
        """
        Update a specific comment.
        """
        project_obj = Pool().get('project.work')
        nereid_user_obj = Pool().get('nereid.user')

        # allow modification only if the user is an admin or the author of
        # this ticket
        task = project_obj.browse(task_id)
        comment = self.browse(comment_id)
        assert task.type == "task"
        assert comment.project.id == task.id

        # Allow only admins and author of this comment to edit it
        if nereid_user_obj.is_project_admin(request.nereid_user) or \
                comment.updated_by == request.nereid_user:
            self.write(comment_id, {'comment': request.form['comment']})
        else:
            abort(403)

        if request.is_xhr:
            comment_record = self.browse(comment_id)
            html = render_template('comment.jinja', comment=comment_record)
            return jsonify({
                'success': True,
                'html': html,
                'state': project_obj.browse(task.id).state,
            })
        return redirect(request.referrer)
开发者ID:Anoopsmohan,项目名称:nereid-project,代码行数:32,代码来源:project.py

示例3: get_avg_efficiency

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
    def get_avg_efficiency(self, ids, name):
        """
        Get average efficiency of the fuel
        """
        purchase_line_obj = Pool().get('purchase.line')
        res = {}
        for asset in self.browse(ids):
            sum_quantity = 0
            purchase_line_ids = purchase_line_obj.search([
                ('asset', '=', asset.id)
                ], order=[('id', 'DESC')], limit=100)
            for purchase_line in purchase_line_obj.browse(purchase_line_ids):
                sum_quantity += Decimal(str(purchase_line.quantity))

            if purchase_line_ids:
                # get the last purchase line for particular asset.
                last_line = purchase_line_obj.browse(
                    purchase_line_ids[-1])
                # get the first purchase line from last 100 records
                # for particular asset.
                first_line = purchase_line_obj.browse(
                    purchase_line_ids[0])
                if len(purchase_line_ids) == 1:
                    avg_efficiency = (first_line.meter_reading - \
                        0)/Decimal(str(purchase_line.quantity))
                else:
                    avg_efficiency = (first_line.meter_reading - \
                        last_line.meter_reading) / (sum_quantity)
            else:
                avg_efficiency = 0
            res[asset.id] = avg_efficiency
        return res
开发者ID:aroraumang,项目名称:fleet_management,代码行数:34,代码来源:asset.py

示例4: on_change_product

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
 def on_change_product(self, vals):
     product_obj = Pool().get('product.product')
     
     if not vals.get('product'):
         return {}
     res = {}
     product = product_obj.browse(vals['product'])
     if not vals.get('desc'):
         res['desc'] = product_obj.browse(product.id).rec_name
     
     if not vals.get('unit'):
         res['unit'] = product.default_uom.id
     
     return res
开发者ID:russelmahmud,项目名称:IDSHealth,代码行数:16,代码来源:health.py

示例5: assign_task

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
    def assign_task(self, task_id):
        """Assign task to a user

        :param task_id: Id of Task
        """
        nereid_user_obj = Pool().get('nereid.user')

        task = self.get_task(task_id)

        new_assignee = nereid_user_obj.browse(int(request.form['user']))

        if self.can_write(task.parent, new_assignee):
            self.write(task.id, {
                'assigned_to': new_assignee.id
            })

            if request.is_xhr:
                return jsonify({
                    'success': True,
                })

            flash("Task assigned to %s" % new_assignee.name)
            return redirect(request.referrer)

        flash("Only employees can be assigned to tasks.")
        return redirect(request.referrer)
开发者ID:Anoopsmohan,项目名称:nereid-project,代码行数:28,代码来源:project.py

示例6: download_file

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
    def download_file(self, attachment_id):
        """
        Returns the file for download. The wonership of the task or the 
        project is checked automatically.
        """
        attachment_obj = Pool().get('ir.attachment')

        work = None
        if request.args.get('project', None):
            work = self.get_project(request.args.get('project', type=int))
        if request.args.get('task', None):
            work = self.get_task(request.args.get('task', type=int))

        if not work:
            # Neither task, nor the project is specified
            raise abort(404)

        attachment_ids = attachment_obj.search([
            ('id', '=', attachment_id),
            ('resource', '=', '%s,%d' % (self._name, work.id))
        ])
        if not attachment_ids:
            raise abort(404)

        attachment = attachment_obj.browse(attachment_ids[0])
        with tempfile.NamedTemporaryFile(delete=False) as f:
            f.write(attachment.data)

        return send_file(
            f.name, attachment_filename=attachment.name, as_attachment=True
        )
开发者ID:Anoopsmohan,项目名称:nereid-project,代码行数:33,代码来源:project.py

示例7: execute

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
 def execute(cls, session, data, state_name):
     model = Pool().get('protection.area')
     records = model.browse(Transaction().context.get('active_ids'))
     for record in records:
         print record
         record.generate([record])
     return []
开发者ID:silpol,项目名称:tryton-bef,代码行数:9,代码来源:protection.py

示例8: do_return_

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
    def do_return_(self, action):
        Sale = Pool().get('sale.sale')
        action, data = super(ReturnSale, self).do_return_(action)

        Sale.write(Sale.browse(data['res_id']), {'carrier': None})

        return action, data
开发者ID:bhavana94,项目名称:trytond-shipping,代码行数:9,代码来源:sale.py

示例9: get_calendar_description

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
    def get_calendar_description(cls, uri, cache=None):
        Calendar = Pool().get('calendar.calendar')

        calendar_id = cls.calendar(uri)
        if calendar_id:
            if not (uri[10:].split('/', 1) + [None])[1]:
                if cache is not None:
                    cache.setdefault('_calendar', {})
                    cache['_calendar'].setdefault(Calendar.__name__, {})
                    ids = cache['_calendar'][Calendar.__name__].keys()
                    if calendar_id not in ids:
                        ids.append(calendar_id)
                    elif 'calendar_description' in cache['_calendar'][
                            Calendar.__name__][calendar_id]:
                        res = cache['_calendar'][Calendar.__name__][
                            calendar_id]['calendar_description']
                        if res is not None:
                            return res
                else:
                    ids = [calendar_id]
                res = None
                for calendar in Calendar.browse(ids):
                    if calendar.id == calendar_id:
                        res = calendar.description
                    if cache is not None:
                        cache['_calendar'][Calendar.__name__]\
                            .setdefault(calendar.id, {})
                        cache['_calendar'][Calendar.__name__][
                            calendar.id]['calendar_description'] = \
                                calendar.description
                if res is not None:
                    return res
        raise DAV_NotFound
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:35,代码来源:webdav.py

示例10: parse

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
    def parse(self, report, objects, datas, localcontext):
        """Get all the purchase orders lines with in the range dates
        that are given in wizard, product type as fuel and the state
        is of done or confirmed.

        :param report: BrowseRecord of the ir.action.report
        :param objects: BrowseRecordList of the records on which parse report
        :param datas: a dictionary with datas that will be set in local context
            of the report
        :param localcontext: the context used to parse the report
        """
        purchase_obj = Pool().get('purchase.purchase')
        purchase_line_obj = Pool().get('purchase.line')
        res = {}

        purchase_line_ids = purchase_line_obj.search([
            ('purchase.purchase_date', '>=',  datas['form']['begin_date']),
            ('purchase.purchase_date', '<=',  datas['form']['end_date']),
            ('purchase.state', 'in', ('done', 'confirmed')),
            ('product.fleet_management_type', '=', 'fuel')
            ])

        localcontext['purchase_lines'] = purchase_line_obj.browse(purchase_line_ids)
        localcontext['begin_date'] = datas['form']['begin_date']
        localcontext['end_date'] = datas['form']['end_date']

        return super(GenerateFuelEfficiencyReport, self).parse(report,
            objects, datas, localcontext)
开发者ID:aroraumang,项目名称:fleet_management,代码行数:30,代码来源:purchase.py

示例11: get_context

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
    def get_context(cls, objects, data):
        Product = Pool().get('product.product')
        Locations = Pool().get('stock.location')

        report_context = super(ProductLedgerReport, cls).get_context(
            objects, data
        )
        records = []
        summary = {}
        for product_id in data['products']:
            product = Product(product_id)
            record = {
                'product': product,
                'purchases': cls.get_purchases(product.id, data),
                'productions': cls.get_productions(product.id, data),
                'customers': cls.get_customers(product.id, data),
                'lost_and_founds': cls.get_lost_and_founds(product.id, data),
                'consumed': cls.get_consumed(product.id, data)
            }
            records.append(record)
            summary[product] = cls.get_summary(record, data)

        report_context['summary'] = summary
        report_context['warehouses'] = Locations.browse(data['warehouses'])
        return report_context
开发者ID:fulfilio,项目名称:trytond-report-html-stock,代码行数:27,代码来源:report_html_stock.py

示例12: read

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
 def read(cls, ids, fields_names=None):
     # Add moves from purchase_request as they can have only one origin
     PurchaseRequest = Pool().get('purchase.request')
     added = False
     if 'moves' in fields_names or []:
         if 'purchase_request' not in fields_names:
             fields_names = fields_names[:]
             fields_names.append('purchase_request')
             added = True
     values = super(SaleLine, cls).read(ids, fields_names=fields_names)
     if 'moves' in fields_names or []:
         with Transaction().set_user(0, set_context=True):
             purchase_requests = PurchaseRequest.browse(
                 list(set(v['purchase_request']
                         for v in values if v['purchase_request'])))
             id2purchase_requests = dict((p.id, p)
                 for p in purchase_requests)
         for value in values:
             if value['purchase_request']:
                 purchase_request = id2purchase_requests[
                     value['purchase_request']]
                 if (purchase_request.customer
                         and purchase_request.purchase_line):
                     move_ids = tuple(m.id
                         for m in purchase_request.purchase_line.moves)
                     if value['moves'] is None:
                         value['moves'] = move_ids
                     else:
                         value['moves'] += move_ids
             if added:
                 del value['purchase_request']
     return values
开发者ID:silpol,项目名称:tryton-bef,代码行数:34,代码来源:sale.py

示例13: parse

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
    def parse(cls, report, records, data, localcontext):
        """
        Data must always contain a key 'productions' if records is None
        """
        Production = Pool().get('production')

        key = attrgetter('reporting_date')

        if not records:
            records = Production.browse(data['productions'])

        productions = Production.search([
            ('id', 'in', map(int, records)),
            ('reporting_date', '!=', None)
        ], order=[('reporting_date', 'ASC')])

        # Raise UserError if no productions were found
        if not productions:  # pragma: no cover
            raise UserError(
                "No Productions found for the given date range"
            )

        matrix = []
        for reporting_date, prod_on_date in groupby(productions, key=key):
            matrix.append([reporting_date] + list(prod_on_date))

        localcontext.update({
            'productions_by_date': matrix
        })

        return super(ProductionScheduleReport, cls).parse(
            report, records, data, localcontext
        )
开发者ID:sharoonthomas,项目名称:trytond-production-report,代码行数:35,代码来源:production.py

示例14: transition_check

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [as 别名]
    def transition_check(self):
        Party = Pool().get('party.party')

        parties_succeed = []
        parties_failed = []
        parties = Party.browse(Transaction().context.get('active_ids'))
        for party in parties:
            for identifier in party.identifiers:
                if identifier.type != 'eu_vat':
                    continue
                try:
                    if not vat.check_vies(identifier.code):
                        parties_failed.append(party.id)
                    else:
                        parties_succeed.append(party.id)
                except Exception, e:
                    if hasattr(e, 'faultstring') \
                            and hasattr(e.faultstring, 'find'):
                        if e.faultstring.find('INVALID_INPUT'):
                            parties_failed.append(party.id)
                            continue
                        if e.faultstring.find('SERVICE_UNAVAILABLE') \
                                or e.faultstring.find('MS_UNAVAILABLE') \
                                or e.faultstring.find('TIMEOUT') \
                                or e.faultstring.find('SERVER_BUSY'):
                            self.raise_user_error('vies_unavailable')
                    raise
开发者ID:kret0s,项目名称:tryton3_8,代码行数:29,代码来源:party.py

示例15: on_change_with_consulLibres

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import browse [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


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