How do i update my values in grand total?

please help me with this issue.i want to add a updated value which is cuming for Quotation doctyp in Grand Total Field.
formula is: quanity*cost_Price
and i want to update this in grand total.
EX:like 180 shud be display in grand_total

Can you explain in detail what you want ?

1 Like

initialy the grand total is bydefault 0.aftr calculation of particular prodycts quantity and it multply with its price it shud override the value with 0.
EX: if my product is mango,and i have taken 2 Quantity and its price for each is 10 then it shud display 20 instead of 0.i have written code in .Py file.
from future import unicode_literals
import frappe
from frappe.model.document import Document
from frappe import _ ,msgprint
from frappe import database

class Quotation(Document):
#def display_order_list(self):
def validate(self):

    fetch={}
    price=0
    #msgprint(_("111"))
    frappe.errprint(self.order_list)
    fetch = frappe.db.sql("Select selected,quantity from `tabAdd to Order` where parent = (%s);",(self.order_list))
    #grand_total_f=frappe.db.sql("Select grand_total from `tabQuotation` where order_list=(%s);",(self.order_list))
#    frappe.errprint(grand_total_f)
    for i in range(len(fetch)):
        for j in range(1):
            cost_price_f=frappe.get_value("Product Details",fetch[i][j],"cost_price")
            price=price + (cost_price_f * fetch[i][j+1])

    #msgprint(_(price))
    #price = 555
    frappe.errprint(price)
    frappe.db.sql("Update `tabQuotation` Set grand_total=(%s) Where order_list=(%s);",(price,self.order_list))
    frappe.errprint(frappe.db.sql("select order_list, grand_total from `tabQuotation`;"))

Not Display in grand total field.we hgave to add manualy .what s the solution

Your update query will not work directly, you have to set the value in a field. If you are over-riding standard fields, best to add separate fields.

1 Like

yes sir,can u please tell me how can i set the value in my field.cox i have tried with d help of
frappe.set_value(“”,“”,“”,grand_total)
it was showing nothing.

You have to set self.grand_total = value

Edit: See existing code to understand how this works.

1 Like

yeah.thank you.now it is working (y)