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


Python Transaction.fetchone方法代码示例

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


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

示例1: get_patient_person_id

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
 def get_patient_person_id(self, name):
     cursor = Transaction().cursor
     login_user_id = self.id
     
     cursor.execute('SELECT patient FROM res_user WHERE  \
         id = %s LIMIT 1', (login_user_id,))
     patient_id = cursor.fetchone()
     cursor = Transaction().cursor
     cursor.execute('SELECT name FROM gnuhealth_patient WHERE  \
         id = %s LIMIT 1', (patient_id[0],))
     person_id = cursor.fetchone()
     if (person_id):
     	return int(person_id[0])
开发者ID:sunny414,项目名称:modules,代码行数:15,代码来源:patient.py

示例2: default_doctor

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
 def default_doctor():
     cursor = Transaction().cursor
     User = Pool().get('res.user')
     user = User(Transaction().user)
     login_user_id = int(user.id)
     cursor.execute('SELECT id FROM party_party WHERE is_healthprof=True AND \
         internal_user = %s LIMIT 1', (login_user_id,))
     partner_id = cursor.fetchone()
     if partner_id:
         cursor = Transaction().cursor
         cursor.execute('SELECT id FROM gnuhealth_healthprofessional WHERE \
             name = %s LIMIT 1', (partner_id[0],))
         doctor_id = cursor.fetchone()
         return int(doctor_id[0])
开发者ID:GabrielReusRodriguez,项目名称:gnuhealth,代码行数:16,代码来源:health_imaging.py

示例3: table_exist

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
    def table_exist(table_name):
        cursor = Transaction().connection.cursor()
        cursor.execute("SELECT sql FROM sqlite_master " "WHERE type = 'table' AND name = ?", (table_name,))
        res = cursor.fetchone()
        if not res:
            return False
        sql, = res

        # Migration from 1.6 add autoincrement

        if "AUTOINCREMENT" not in sql.upper():
            temp_sql = sql.replace(table_name, "_temp_%s" % table_name)
            cursor.execute(temp_sql)
            cursor.execute('PRAGMA table_info("' + table_name + '")')
            columns = ['"%s"' % column for _, column, _, _, _, _ in cursor.fetchall()]
            cursor.execute(
                ('INSERT INTO "_temp_%s" ' "(" + ",".join(columns) + ") " "SELECT " + ",".join(columns) + ' FROM "%s"')
                % (table_name, table_name)
            )
            cursor.execute('DROP TABLE "%s"' % table_name)
            new_sql = sql.replace("PRIMARY KEY", "PRIMARY KEY AUTOINCREMENT")
            cursor.execute(new_sql)
            cursor.execute(
                ('INSERT INTO "%s" ' "(" + ",".join(columns) + ") " "SELECT " + ",".join(columns) + ' FROM "_temp_%s"')
                % (table_name, table_name)
            )
            cursor.execute('DROP TABLE "_temp_%s"' % table_name)
        return True
开发者ID:coopengo,项目名称:trytond,代码行数:30,代码来源:table.py

示例4: check_date_overlap

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
 def check_date_overlap(self):
     cursor = Transaction().cursor
     if self.state != "done":
         return True
     cursor.execute(
         "SELECT id "
         "FROM stock_forecast "
         "WHERE ((from_date <= %s AND to_date >= %s) "
         "OR (from_date <= %s AND to_date >= %s) "
         "OR (from_date >= %s AND to_date <= %s)) "
         "AND warehouse = %s "
         "AND destination = %s "
         "AND state = 'done' "
         "AND company = %s "
         "AND id != %s",
         (
             self.from_date,
             self.from_date,
             self.to_date,
             self.to_date,
             self.from_date,
             self.to_date,
             self.warehouse.id,
             self.destination.id,
             self.company.id,
             self.id,
         ),
     )
     forecast_id = cursor.fetchone()
     if forecast_id:
         second = self.__class__(forecast_id[0])
         self.raise_user_error("date_overlap", {"first": self.rec_name, "second": second.rec_name})
开发者ID:silpol,项目名称:tryton-bef,代码行数:34,代码来源:forecast.py

示例5: confirmed

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
 def confirmed(cls, registrations):
     registration_id = registrations[0]
     Bed = Pool().get("gnuhealth.hospital.bed")
     cursor = Transaction().cursor
     bed_id = registration_id.bed.id
     cursor.execute(
         "SELECT COUNT(*) \
         FROM gnuhealth_inpatient_registration \
         WHERE (hospitalization_date::timestamp,discharge_date::timestamp) \
             OVERLAPS (timestamp %s, timestamp %s) \
           AND (state = %s or state = %s) \
           AND bed = CAST(%s AS INTEGER) ",
         (
             registration_id.hospitalization_date,
             registration_id.discharge_date,
             "confirmed",
             "hospitalized",
             str(bed_id),
         ),
     )
     res = cursor.fetchone()
     if registration_id.discharge_date.date() < registration_id.hospitalization_date.date():
         cls.raise_user_error(
             "The Discharge date must later than the \
             Admission"
         )
     if res[0] > 0:
         cls.raise_user_error("bed_is_not_available")
     else:
         cls.write(registrations, {"state": "confirmed"})
         Bed.write([registration_id.bed], {"state": "reserved"})
开发者ID:silpol,项目名称:tryton-bef,代码行数:33,代码来源:health_inpatient.py

示例6: __register__

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
    def __register__(cls, module_name):
        cursor = Transaction().cursor
        model_data = Table('ir_model_data')

        # Migration from 3.0: new tax rates
        if module_name == 'account_nl':
            for old_id, new_id in (
                    ('tva_vente_19_6', 'tva_vente_taux_normal'),
                    ('tva_vente_7', 'tva_vente_taux_intermediaire'),
                    ('tva_vente_intracommunautaire_19_6',
                        'tva_vente_intracommunautaire_taux_normal'),
                    ('tva_vente_intracommunautaire_7',
                        'tva_vente_intracommunautaire_taux_intermediaire'),
                    ('tva_achat_19_6', 'tva_achat_taux_normal'),
                    ('tva_achat_7', 'tva_achat_taux_intermediaire'),
                    ('tva_achat_intracommunautaire_19_6',
                        'tva_achat_intracommunautaire_taux_normal'),
                    ):
                cursor.execute(*model_data.select(model_data.id,
                        where=(model_data.fs_id == new_id)
                        & (model_data.module == module_name)))
                if cursor.fetchone():
                    continue
                cursor.execute(*model_data.update(
                        columns=[model_data.fs_id],
                        values=[new_id],
                        where=(model_data.fs_id == old_id)
                        & (model_data.module == module_name)))

        super(TaxTemplate, cls).__register__(module_name)
开发者ID:FvD,项目名称:trytond_account_nl,代码行数:32,代码来源:account.py

示例7: confirmed

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
    def confirmed(cls, surgeries):
        surgery_id = surgeries[0]
        Operating_room = Pool().get('gnuhealth.hospital.or')
        cursor = Transaction().cursor

        # Operating Room and end surgery time check
        if (not surgery_id.operating_room or not surgery_id.surgery_end_date):
            cls.raise_user_error("Operating Room and estimated end time  "
            "are needed in order to confirm the surgery")

        or_id = surgery_id.operating_room.id
        cursor.execute("SELECT COUNT(*) \
            FROM gnuhealth_surgery \
            WHERE (surgery_date::timestamp,surgery_end_date::timestamp) \
                OVERLAPS (timestamp %s, timestamp %s) \
              AND (state = %s or state = %s) \
              AND operating_room = CAST(%s AS INTEGER) ",
            (surgery_id.surgery_date,
            surgery_id.surgery_end_date,
            'confirmed', 'in_progress', str(or_id)))
        res = cursor.fetchone()
        if (surgery_id.surgery_end_date <
            surgery_id.surgery_date):
            cls.raise_user_error("The Surgery end date must later than the \
                Start")
        if res[0] > 0:
            cls.raise_user_error('or_is_not_available')
        else:
            cls.write(surgeries, {'state': 'confirmed'})
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:31,代码来源:health_surgery.py

示例8: get_translation_4_nereid

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
    def get_translation_4_nereid(cls, module, ttype, lang, source):
        "Return translation for source"
        ttype = unicode(ttype)
        lang = unicode(lang)
        source = unicode(source)

        cache_key = (lang, ttype, source, module)

        trans = cls._nereid_translation_cache.get(cache_key, -1)
        if trans != -1:
            return trans

        cursor = Transaction().cursor
        table = cls.__table__()
        where = (
            (table.lang == lang) &
            (table.type == ttype) &
            (table.value != '') &
            (table.value != None) &
            (table.fuzzy == False) &
            (table.src == source)
        )
        if module is not None:
            where &= (table.module == module)

        cursor.execute(*table.select(table.value, where=where))
        res = cursor.fetchone()
        if res:
            cls._nereid_translation_cache.set(cache_key, res[0])
            return res[0]
        else:
            cls._nereid_translation_cache.set(cache_key, False)
            return None
开发者ID:priyankajain18,项目名称:nereid,代码行数:35,代码来源:translation.py

示例9: __register__

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
    def __register__(cls, module_name):
        TableHandler = backend.get('TableHandler')
        cursor = Transaction().cursor
        table = TableHandler(cursor, cls, module_name)
        sql_table = cls.__table__()

        # Migration from 2.2 new field currency
        created_currency = table.column_exist('currency')

        super(ProductSupplier, cls).__register__(module_name)

        # Migration from 2.2 fill currency
        if not created_currency:
            Company = Pool().get('company.company')
            company = Company.__table__()
            limit = cursor.IN_MAX
            cursor.execute(*sql_table.select(Count(sql_table.id)))
            product_supplier_count, = cursor.fetchone()
            for offset in range(0, product_supplier_count, limit):
                cursor.execute(*sql_table.join(company,
                        condition=sql_table.company == company.id
                        ).select(sql_table.id, company.currency,
                        order_by=sql_table.id,
                        limit=limit, offset=offset))
                for product_supplier_id, currency_id in cursor.fetchall():
                    cursor.execute(*sql_table.update(
                            columns=[sql_table.currency],
                            values=[currency_id],
                            where=sql_table.id == product_supplier_id))

        # Migration from 2.4: drop required on sequence
        table.not_null_action('sequence', action='remove')

        # Migration from 2.6: drop required on delivery_time
        table.not_null_action('delivery_time', action='remove')
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:37,代码来源:product.py

示例10: count

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
    def count(self):
        "Return the count of the Items"
        from trytond.transaction import Transaction

        # XXX: Ideal case should make a copy of Select query
        #
        # https://code.google.com/p/python-sql/issues/detail?id=22
        query = self.query
        query.columns = (Count(Distinct(self.primary_table.id)), )

        cursor = Transaction().connection.cursor()

        # temporarily remove order_by
        order_by = query.order_by
        query.order_by = None
        try:
            cursor.execute(*query)
        finally:
            # XXX: This can be removed when SQL queries can be copied
            # See comment above
            query.order_by = order_by
        res = cursor.fetchone()
        if res:
            return res[0]
        # There can be a case when query return None and then count
        # will be zero
        return 0
开发者ID:fulfilio,项目名称:nereid,代码行数:29,代码来源:pagination.py

示例11: restore_default_party_lang_from_4_2

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
    def restore_default_party_lang_from_4_2(cls):
        from trytond.transaction import Transaction
        from sql import Null, Table, Cast
        from sql.operators import Concat
        from trytond.pool import Pool

        TableHandler = backend.get('TableHandler')
        if not TableHandler.table_exist('ir_property'):
            return

        pool = Pool()
        property = Table('ir_property')
        Lang = pool.get('ir.lang')
        field = pool.get('ir.model.field').__table__()
        lang = Lang.__table__()
        cursor = Transaction().connection.cursor()

        query_table = property.join(lang, condition=(
                property.value == Concat('ir.lang,', Cast(lang.id, 'VARCHAR'))
                )).join(field, condition=((property.field == field.id) &
                        (field.name == 'lang')))

        cursor.execute(
            *query_table.select(lang.id, where=property.res == Null))
        result = cursor.fetchone()
        if result:
            result = list(result)
            default_lang = Lang(result[0])
            print('Default Language restored [%s]' % default_lang.rec_name)
            pool.get('party.configuration.party_lang'
                ).create([{'party_lang': default_lang}])
        else:
            print('No default language on party configuration found')
开发者ID:coopengo,项目名称:party,代码行数:35,代码来源:configuration.py

示例12: __register__

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
    def __register__(cls, module_name):
        pool = Pool()
        Move = pool.get('stock.move')
        PurchaseLine = pool.get('purchase.line')
        PurchaseRequest = pool.get('purchase.request')
        SaleLine = pool.get('sale.line')
        Location = pool.get('stock.location')
        move = Move.__table__()
        purchase_line = PurchaseLine.__table__()
        purchase_request = PurchaseRequest.__table__()
        sale_line = SaleLine.__table__()
        location = Location.__table__()
        cursor = Transaction().cursor

        super(ShipmentDrop, cls).__register__(module_name)

        # Migration from 3.6
        cursor.execute(*location.select(Count(location.id),
                where=(location.type == 'drop')))
        has_drop_shipment, = cursor.fetchone()

        if not has_drop_shipment:
            drop_shipment = Location(name='Migration Drop Shipment',
                type='drop', active=False)
            drop_shipment.save()
            drop_shipment_location = drop_shipment.id

            move_sale_query = move.join(purchase_line,
                condition=move.origin == Concat('purchase.line,',
                    purchase_line.id)
                ).join(purchase_request,
                condition=purchase_request.purchase_line == purchase_line.id
                ).join(sale_line,
                condition=sale_line.purchase_request == purchase_request.id
                ).select(
                    move.id, move.to_location, sale_line.id,
                    where=move.shipment.like('stock.shipment.drop,%'))
            cursor.execute(*move_sale_query)
            move_sales = cursor.fetchall()

            for sub_move in grouped_slice(move_sales):
                sub_ids = [s[0] for s in sub_move]
                cursor.execute(*move.update(
                        columns=[move.to_location],
                        values=[drop_shipment_location],
                        where=move.id.in_(sub_ids)))

            create_move = move.insert(values=move.select(
                    where=move.shipment.like('stock.shipment.drop,%')))
            cursor.execute(*create_move)

            for move_id, customer_location, line_id in move_sales:
                cursor.execute(move.update(
                        columns=[move.origin, move.from_location,
                            move.to_location],
                        values=[Concat('sale.line,', str(line_id)),
                            drop_shipment_location, customer_location],
                        where=(move.id == move_id)))
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:60,代码来源:stock.py

示例13: check_patient_current_pregnancy

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
 def check_patient_current_pregnancy(self):
     ''' Check for only one current pregnancy in the patient '''
     cursor = Transaction().cursor
     cursor.execute("SELECT count(name) "
         "FROM " + self._table + "  \
         WHERE (name = %s AND current_pregnancy)",
         (str(self.name.id),))
     if cursor.fetchone()[0] > 1:
         self.raise_user_error('patient_already_pregnant')
开发者ID:GabrielReusRodriguez,项目名称:gnuhealth,代码行数:11,代码来源:health_gyneco.py

示例14: delete

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
 def delete(cls, invoices):
     cursor = Transaction().cursor
     if invoices:
         cursor.execute('SELECT id FROM purchase_invoices_rel '
             'WHERE invoice IN (' + ','.join(('%s',) * len(invoices)) + ')',
             [i.id for i in invoices])
         if cursor.fetchone():
             cls.raise_user_error('delete_purchase_invoice')
     super(Invoice, cls).delete(invoices)
开发者ID:silpol,项目名称:tryton-bef,代码行数:11,代码来源:invoice.py

示例15: check_patient_current_mv

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import fetchone [as 别名]
 def check_patient_current_mv(self):
     # Check for only one current mechanical ventilation on patient
     cursor = Transaction().cursor
     cursor.execute("SELECT count(name) "
         "FROM " + self._table + "  \
         WHERE (name = %s AND current_mv)",
         (str(self.name.id),))
     if cursor.fetchone()[0] > 1:
         self.raise_user_error('patient_already_on_mv')
开发者ID:bharathi26,项目名称:gnuhealth,代码行数:11,代码来源:health_icu.py


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