RETURN VALUE in FRAPPE

Good Evening,

I am a newbie here and i am trying to get a value into another value in frappe. Below is the Screenshot.
i already have a predefined figure for Dollars (360) so i want my result field to carry the Result from 360 * any entered amount but it seems i am doing some thing wrong.

class CurrencyConverter(Document):

def validate(self):

	self.amount = 0
	self.result = 0

	if self.currency == 'Dollars':
		self.result = 360 * self.amount
		print(self.result)

Any help please

As you want to populate the value in a field, it’s better to use JS than python.

eg:

frappe.ui.form.on('CurrencyConverter', {
       amount: function(frm){
             if(frm.doc.currency=='USD'){
                      var total = 0;
                      total = frm.doc.amount*360;
                      frm.set_value("result", total);
             }
             
       }
})

2 Likes

Thank you @saurabh6790 this works very fine
I just have to complete the line of codes with other remaining option.