I am new in Frappe please see this code … and suggest me how to pass list data on this code
# Copyright (c) 2013, Hasan and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
def execute(filters=None):
return columns(),data(filters)
def columns():
# colums= [_('Stock ID' + ':Data:120'), _('Article Name' + ':Data:150'), _('Author' + ':Data:150'),
# _('Language' + ':Data:150'), _('ISBN' + ':Data:150'),
# _('Stock Date'':Data:150'), _('Purchase Price' + ':Data:150'), _('Quantity' + ':Data:150'),
# _('Total Amount' + ':int:150')]
Colum =[
{
"fieldname": "name",
"label": _("Stock ID"),
"fieldtype": "Data",
"width": 100,
},
{
"fieldname": "article_name",
"label": _("Article Name"),
"fieldtype": "Data",
"width": 150,
},
{
"fieldname": "Author",
"label": _("Author"),
"fieldtype": "Data",
"width": 150,
},
{
"fieldname": "Language",
"label": _("Language"),
"fieldtype": "Data",
"width": 120,
},
{
"fieldname": "ISBN",
"label": _("ISBN"),
"fieldtype": "Data",
"width": 80,
},
{
"fieldname": "stock_date",
"label": _("Stock Date"),
"fieldtype": "Data",
"width": 100,
},
{
"fieldname": "purchase_price",
"label": _("Purchase Price"),
"fieldtype": "Int",
"width": 120,
},
{
"fieldname": "quantity",
"label": _("Quantity"),
"fieldtype": "Int",
"width": 100,
},
{
"fieldname": "Total_amount",
"label": _("Total Amount"),
"fieldtype": "Float",
"width": 100,
},
]
return Colum
def data(filters):
data = []
sql=frappe.db.get_all('Stock', filters=filters, fields=['*']);
frappe.throw(str(sql))
# total_row = frappe._dict({
# "purchase_price": 0,
# "quantity": 0,
# "Total_amount": 0,
# })
for info in sql:
row = {"name": info.name}
row.update(
{
"article_name":info.article_name
}
)
row.update({"Author":info.author})
row.update({"Language":info.language})
row.update({"ISBN": info.isbn})
row.update({"stock_date": info.stock_date})
row.update({"purchase_price":info.purchase_price})
row.update({"quantity":info.quantity})
row.update({"Total_amount": Total_amount(info.purchase_price, info.quantity)})
data.append(row)
return data
def Total_amount(purchase_price, quantity):
purchase_price = purchase_price
quantity = quantity
total_price = float(purchase_price) * float(quantity)
return total_price
# total_row.update({
# "party": "'" + _("Totals") + "'",
# "currency": company_currency
# })
# data.append(total_row)