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


Python Pool.update方法代码示例

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


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

示例1: validate_active

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import update [as 别名]
    def validate_active(self):
        #Deactivate mandate as unit mandate on canceled state
        if (self.id > 0) and self.state=='canceled':
            condoparties = Pool().get('condo.party').__table__()
            condopayments = Pool().get('condo.payment').__table__()
            cursor = Transaction().connection.cursor()

            cursor.execute(*condopayments.select(condopayments.id,
                                        where=(condopayments.sepa_mandate == self.id) & (
                                              (condopayments.state == 'draft') | (condopayments.state == 'approved')),
                                        ))
            ids = [ids for (ids,) in cursor.fetchall()]
            if len(ids):
                self.raise_user_error('Can\'t cancel mandate "%s".\nThere are %s payments in draft or approved state with this mandate!',
                                                              (self.identification, len(ids)))

            cursor.execute(*condoparties.select(condoparties.id,
                                        where=(condoparties.sepa_mandate == self.id)))
            ids = [ids for (ids,) in cursor.fetchall()]
            if len(ids):
                self.raise_user_warning('warn_canceled_mandate',
                    'Mandate "%s" will be canceled as mean of payment in %d unit(s)/apartment(s)!', (self.identification, len(ids)))

                for sub_ids in grouped_slice(ids):
                    red_sql = reduce_ids(condoparties.id, sub_ids)
                    # Use SQL to prevent double validate loop
                    cursor.execute(*condoparties.update(
                            columns=[condoparties.sepa_mandate],
                            values=[None],
                            where=red_sql))
开发者ID:malonp,项目名称:trytond-condominium_payment_sepa,代码行数:32,代码来源:payment.py

示例2: validate_active

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import update [as 别名]
    def validate_active(self):
        #Cancel mandates with account number of this bank account.
        if (self.id > 0) and not self.active:
            mandates = Pool().get('condo.payment.sepa.mandate').__table__()
            condoparties = Pool().get('condo.party').__table__()
            cursor = Transaction().connection.cursor()

            red_sql = reduce_ids(mandates.account_number, [x.id for x in self.numbers])
            cursor.execute(*mandates.select(mandates.id,
                                            mandates.identification,
                                        where=red_sql &
                                              (mandates.state != 'canceled')))

            for id, identification in cursor.fetchall():
                cursor.execute(*condoparties.select(
                                     condoparties.id,
                                     where=(condoparties.sepa_mandate == id) &
                                           (condoparties.active == True)))

                ids = [ids for (ids,) in cursor.fetchall()]
                if len(ids):
                    self.raise_user_warning('warn_deactive_mandate.%d' % id,
                        'Mandate "%s" will be canceled and deactivate as mean of payment in %d unit(s)/apartment(s)!', (identification, len(ids)))

                    # Use SQL to prevent double validate loop
                    cursor.execute(*mandates.update(
                            columns=[mandates.state],
                            values=['canceled'],
                            where=(mandates.id == id)))

                    for sub_ids in grouped_slice(ids):
                        red_sql = reduce_ids(condoparties.id, sub_ids)
                        cursor.execute(*condoparties.update(
                                columns=[condoparties.sepa_mandate],
                                values=[None],
                                where=red_sql))
开发者ID:malonp,项目名称:trytond-condominium_payment_sepa,代码行数:38,代码来源:bank.py

示例3: validate

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import update [as 别名]
    def validate(cls, paymentgroups):
        super(CondoPaymentGroup, cls).validate(paymentgroups)

        table = cls.__table__()
        payments = Pool().get('condo.payment').__table__()

        for paymentgroup in paymentgroups:
            if paymentgroup.readonly:
                with Transaction().new_transaction(readonly=True) as transaction,\
                    transaction.connection.cursor() as cursor:
                    cursor.execute(*table.select(table.date,
                                 where=(table.id == paymentgroup.id) &
                                       (table.date != paymentgroup.date)))
                    if cursor.fetchone():
                        cls.raise_user_error('readonly_paymentgroup', (paymentgroup.reference)
                            )
                return

            cursor = Transaction().connection.cursor()
            cursor.execute(*payments.select(payments.id,
                         where=(payments.group == paymentgroup.id) &
                               (payments.date < paymentgroup.date) &
                               (payments.state != 'draft')))
            if cursor.fetchall():
                cls.raise_user_error('payments_approved', (paymentgroup.reference)
                    )

            paymentgroup.check_today()
            paymentgroup.check_businessdate()
            paymentgroup.company_has_sepa_creditor_identifier()

            #if has drafted payments with due date before new date
            #update date field of payments
            cursor.execute(*payments.select(payments.id,
                         where=(payments.group == paymentgroup.id) &
                               (payments.date < paymentgroup.date) &
                               (payments.state == 'draft')))
            ids_draft = [ids for (ids,) in cursor.fetchall()]

            if len(ids_draft):
                for sub_ids in grouped_slice(ids_draft):
                    red_sql = reduce_ids(payments.id, sub_ids)
                    # Use SQL to prevent double validate loop
                    cursor.execute(*payments.update(
                            columns=[payments.date],
                            values=[paymentgroup.date],
                            where=red_sql))
开发者ID:malonp,项目名称:trytond-condominium_payment_sepa,代码行数:49,代码来源:payment.py

示例4: validate_mandates

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import update [as 别名]
    def validate_mandates(self):
        #Cancel party's mandates on party deactivate
        if (self.id > 0) and not self.active:
            mandates = Pool().get('condo.payment.sepa.mandate').__table__()
            cursor = Transaction().connection.cursor()

            cursor.execute(*mandates.select(mandates.id,
                                        where=(mandates.party == self.id) &
                                              (mandates.state != 'canceled')))

            ids = [ids for (ids,) in cursor.fetchall()]
            if len(ids):
                self.raise_user_warning('warn_cancel_mandates_of_party.%d' % self.id,
                    '%d mandate(s) of this party will be canceled!', len(ids))

                for sub_ids in grouped_slice(ids):
                    red_sql = reduce_ids(mandates.id, sub_ids)
                    # Use SQL to prevent double validate loop
                    cursor.execute(*mandates.update(
                            columns=[mandates.state],
                            values=['canceled'],
                            where=red_sql))
开发者ID:malonp,项目名称:trytond-condominium_payment_sepa,代码行数:24,代码来源:party.py


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