本文整理汇总了Python中trytond.pool.Pool.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.execute方法的具体用法?Python Pool.execute怎么用?Python Pool.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.pool.Pool
的用法示例。
在下文中一共展示了Pool.execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_address_data
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import execute [as 别名]
def get_address_data(cls, uri, cache=None):
Vcard = Pool().get('party_vcarddav.party.vcard', type='report')
party_id = cls.vcard(uri)
if not party_id:
raise DAV_NotFound
return Vcard.execute([party_id],
{'id': party_id, 'ids': [party_id]},
).decode('utf-8')
示例2: get_data
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import execute [as 别名]
def get_data(cls, uri, cache=None):
Vcard = Pool().get('party_vcarddav.party.vcard', type='report')
party_id = cls.vcard(uri)
if party_id is None:
raise DAV_NotFound
if party_id:
val = Vcard.execute([party_id],
{'id': party_id, 'ids': [party_id]})
return str(val[1])
return super(Collection, cls).get_data(uri, cache=cache)
示例3: send_gift_card_as_email
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import execute [as 别名]
def send_gift_card_as_email(self):
"""
Send gift card as an attachment in the email
"""
EmailQueue = Pool().get('email.queue')
GiftCardReport = Pool().get('gift_card.gift_card', type='report')
ModelData = Pool().get('ir.model.data')
Group = Pool().get('res.group')
group_id = ModelData.get_id(
"gift_card", "gift_card_email_receivers"
)
bcc_emails = map(
lambda user: user.email,
filter(lambda user: user.email, Group(group_id).users)
)
if not self.recipient_email: # pragma: no cover
return
# Try to generate report twice
# This is needed as sometimes `unoconv` fails to convert report to pdf
for try_count in range(2):
try:
val = GiftCardReport.execute([self.id], {})
break
except: # pragma: no cover
if try_count == 0:
continue
else:
return
subject = self._get_subject_for_email()
html_template, text_template = self._get_email_templates()
sender = config.get('email', 'from')
email_gift_card = render_email(
sender, self.recipient_email,
subject,
html_template=html_template,
text_template=text_template,
attachments={"%s.%s" % (val[3], val[0]): val[1]},
card=self,
)
EmailQueue.queue_mail(
sender, [self.recipient_email] + bcc_emails,
email_gift_card.as_string()
)
self.is_email_sent = True
self.save()
示例4: download_invoice
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import execute [as 别名]
def download_invoice(self):
"""
Allow user to download invoice.
"""
Report = Pool().get('account.invoice', type='report')
if self.party != current_user.party:
abort(403)
vals = Report.execute([self.id], {})
with tempfile.NamedTemporaryFile(delete=False) as file:
file.write(vals[1])
return send_file(
file.name,
as_attachment=True,
attachment_filename=vals[3],
)
示例5: render_reports
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import execute [as 别名]
def render_reports(self, template, record):
'''Renders the reports and returns as a list of tuple
:param template: Browse Record of the template
:param record: Browse Record of the record on which the template
is to generate the data on
:return: List of tuples with:
report_type
data
the report name
'''
reports = [ ]
for report_action in template.reports:
report = Pool().get(report_action.report_name, type='report')
reports.append(report.execute([record.id], {'id': record.id}))
# The boolean for direct print in the tuple is useless for emails
return [(r[0], r[1], r[3]) for r in reports]