本文整理汇总了Python中models.Report.filter方法的典型用法代码示例。如果您正苦于以下问题:Python Report.filter方法的具体用法?Python Report.filter怎么用?Python Report.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Report
的用法示例。
在下文中一共展示了Report.filter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_data_for
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import filter [as 别名]
def set_data_for(self, on, end):
reports = []
if end:
# self.parent.current_period.setText(self.parent.format_period(on,
# end))
reports = Report.filter(date__gte=date_on_or_end(on),
date__lte=date_on_or_end(end, on=False)).order_by(Report.date.desc())
self.data = [(rap.product, rap.remaining, rap.selling_price,
rap.remaining * rap.selling_price,
rap.qty * (rap.selling_price - rap.selling_price))
for rap in reports]
示例2: write_invoice_xls
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import filter [as 别名]
def write_invoice_xls(file_name, invoice):
book = xlwt.Workbook(encoding='ascii')
sheet = book.add_sheet(u"Commande %s" % Config.NAME_ORGA)
sheet.col(1).width = 0x0d00 * 3
# sheet.col(4).width = 0x0d00 * 1.5
rowx = 0
sheet.write_merge(rowx, rowx + 1, 0, 3,
u"Facture de %s" % Config.NAME_ORGA, style_title)
rowx += 3
date = "Bko le %s" % invoice.date.strftime("%d/%m/%Y")
sheet.write_merge(rowx, rowx, 2, 3, date)
hheaders = [u"Quantité", u"Désignation", u"Prix Unitaire",
u"Montant"]
rowx += 2
for colx, val_center in enumerate(hheaders):
sheet.write(rowx, colx, val_center, style_t_table)
rowx += 1
data = [(item.qty, item.product.name, item.selling_price,
item.qty * item.selling_price) for item in Report.filter(invoice=invoice)]
for prod in data:
col = 0
for val_center in prod:
if isinstance(val_center, str):
style_ = style
else:
style_ = int_style
sheet.write_merge(rowx, rowx, col, col, val_center, style_)
col += 1
rowx += 1
book.save(file_name)
openFile(file_name)
示例3: pdf_view
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import filter [as 别名]
def pdf_view(filename, order):
"""
cette views est cree pour la generation du PDF
"""
if not filename:
filename = get_temp_filename('pdf')
# on recupere la facture a afficher
invoice = order
# on recupere les items de la facture
items_invoice = Report.filter(invoice=invoice)
# Static source pdf to be overlayed
PDF_SOURCE = 'tools/fact_source.pdf'
TMP_FILE = 'tools/tmp.pdf'
DATE_FORMAT = u"%d/%m/%Y"
DEFAULT_FONT_SIZE = 10
FONT = 'Courier-Bold'
# A simple function to return a leading 0 on any single digit int.
def double_zero(value):
try:
return '%02d' % value
except TypeError:
return value
# setup the empty canvas
from pyPdf import PdfFileWriter, PdfFileReader
# PDF en entrée
input1 = PdfFileReader(file(PDF_SOURCE, "rb"))
# PDF en sortie
output = PdfFileWriter()
# Récupération du nombre de pages
n_pages = input1.getNumPages()
# Pour chaque page
for i in range(n_pages):
# Récupération de la page du doc initial (input1)
page = input1.getPage(i)
# p = canvas.Canvas(buffer, pagesize=A4)
p = canvas.Canvas(TMP_FILE, pagesize=A4)
p.setFont(FONT, DEFAULT_FONT_SIZE)
# Création de l'objet PDF, en utilisant l'objet de réponse comme "fichier"
# on afffiche l'image de l'orgamisation
try:
p.drawImage(u'%s' % Config.APP_LOGO, 60, 740)
except:
print(u"logo non disponible!")
pass
p.drawString(370, 735, unicode(Config.NAME_ORGA))
# On trace Une ligne horizontale
p.line(60, 730, 535, 730)
p.drawString(59, 25, Config.NAME_ORGA + " - tel : " +
str(Config.TEL_ORGA) + " - " + unicode(Config.ADRESS_ORGA))
legal_infos, legal_infos1 = controle_caratere(Config.BP, 55, 55)
p.drawString(90, 14, legal_infos)
p.drawString(90, 6, legal_infos1)
p.drawString(
60, 706, str(invoice.type_) + " N°: " + str(invoice.number))
p.drawString(370, 706, "Date: " + str(invoice.date.strftime(DATE_FORMAT)) +
" à " + str(invoice.location))
p.drawString(60, 690, "Doit: " + (invoice.client))
if invoice.subject:
p.drawString(60, 664, "Objet: " + str(invoice.subject))
# On ecrit les invoiceitem
x, y = 40, 600
for i in items_invoice:
p.drawString(x, y, str(i.qty).rjust(10, ' '))
p.drawString(x + 75, y, (i.product.__str__()))
p.drawString(x + 340, y, str(i.selling_price).rjust(10, ' '))
p.drawString(
x + 435, y, str(i.selling_price * i.qty).rjust(10, ' '))
y -= 20
# on teste le type
if invoice.type_ == "Facture":
p.drawString(59, 95, "Pour acquit: ")
else:
p.drawString(59, 95, "Pour acceptation: ")
p.drawString(435, 95, "Le Providers: ")
# On calcul le montant total hors taxe et sa conversion en lettre
ht = 0
for i in items_invoice:
montant = i.selling_price * i.qty
ht += montant
p.drawString(476, 204, str(ht).rjust(10, ' '))
ht_en_lettre = cel(ht)
# Calcul du TTC avec le TVA s'il existe
if invoice.tax:
TVA = (invoice.tax_rate * ht) / 100
p.drawString(476, 183.5, str(TVA).rjust(10, ' '))
#.........这里部分代码省略.........
示例4: pdf_view
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import filter [as 别名]
def pdf_view(filename, invoice):
"""
cette views est cree pour la generation du PDF
"""
if not filename:
filename = get_temp_filename('pdf')
# print(filename)
# on recupere les items de la facture
items_invoice = Report.filter(invoice=invoice)
# Static source pdf to be overlayed
PDFSOURCE = Config.INV_TEMPLATE_PDF
TMP_FILE = os.path.join(Config.ROOT_DIR, 'tmp.pdf')
DATE_FORMAT = u"%d/%m/%Y"
DEFAULT_FONT_SIZE = 11
FONT = 'Times-Roman'
# PDF en entrée
input1 = PdfFileReader(file(PDFSOURCE, "rb"))
# PDF en sortie
output = PdfFileWriter()
# Récupération du nombre de pages
n_pages = input1.getNumPages()
# Pour chaque page
for i in range(n_pages):
# Récupération de la page du doc initial (input1)
page = input1.getPage(i)
p = canvas.Canvas(TMP_FILE, pagesize=A4)
p.setFont(FONT, DEFAULT_FONT_SIZE)
p.drawString(115, 639, str(invoice.number))
p.drawString(82, 625, (invoice.client.name))
p.drawString(445, 625, str(invoice.date.strftime(DATE_FORMAT)))
# On ecrit les invoiceitem
x, y = 122, 574
x_qty = x
x_description = x + 10
x_price = x + 340
x_amount = x + 433
for i in items_invoice:
p.drawRightString(x_qty, y, str(i.qty))
p.drawString(x_description, y, str(i.product.name))
p.drawRightString(x_price, y, str(
formatted_number(i.selling_price)))
p.drawRightString(x_amount, y, str(formatted_number(
i.selling_price * i.qty)))
y -= 17
# On calcul le montant total hors taxe et sa conversion en lettre
ht = sum([(val.selling_price * val.qty) for val in items_invoice])
tax_rate = invoice.tax_rate if invoice.tax else 0
mt_tax = int((ht * tax_rate) / 100)
htt = mt_tax + ht
ht_en_lettre = num2words(ht, lang="fr")
ht_en_lettre1, ht_en_lettre2 = controle_caratere(
ht_en_lettre + " francs CFA", 50, 50)
p.drawString(260, 191, (ht_en_lettre1))
p.drawString(50, 175, (ht_en_lettre2))
p.setFont('Times-Bold', 11)
p.drawString(52, 639, "Facture N° :")
p.drawString(x_price - 20, 248, str(tax_rate) + "%")
# TVA
p.drawRightString(x_amount, 248, device_amount(mt_tax))
# Hors Taxe
p.drawRightString(x_amount, 265, str(device_amount(ht)))
# Tout Taxe
p.drawRightString(x_amount, 232, str(device_amount(htt)))
x_foot = 145
p.drawString(50, x_foot, "Acceptation" if invoice.type_ ==
"Proforma" else "Acquit")
p.drawString(490, x_foot, "Fournisseur")
p.showPage()
# Sauvegarde de la page
p.save()
# Création du watermark
watermark = PdfFileReader(file(TMP_FILE, "rb"))
# Création page_initiale+watermark
page.mergePage(watermark.getPage(0))
# Création de la nouvelle page
output.addPage(page)
# Nouveau pdf
file_dest = filename + ".pdf"
try:
outputStream = file(file_dest, u"wb")
output.write(outputStream)
outputStream.close()
return file_dest
except OSError as e:
from Common.ui.util import raise_error
raise_error(u"Impossible de lancer le PDF", """
Car un autre en cours d'utilistation. Kill le \n{}""".format(e))
return