本文整理汇总了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))
示例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))
示例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))
示例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))