How to do area calculation in erpnext for two fields?

I want to add a custom field to the Item Group form type that is a calculated field. It is the product of the multiplication of two other fields length and width in the same form.

Here’s an example where I have two custom fields under Description on Item Group with unit in mm:
length
width

I want to add a new field called area which is the product of (length*width) /1 million to get result in metre square.

I tried the below script in custom script - Item Group Doc Type but I received the error “Item Group -Client already exist” and the script gets saved but I am unable to access the Item group form. I can understand that there is a problem in script so please check my script and advise the solutions if any.

frappe.ui.form.on(“Item Group”, {
validate: function(frm) {
if (doc.length && doc.width){
doc.area = doc.length* doc.width;
}
}
cur_frm.cscript.custom_length = compute;
cur_frm.cscript.custom_width = compute;

Hi @san_aet

Instead of doc use frm.doc or defined var doc = frm.doc
add code frm.set_value(‘area’, doc.area) after calculation part

Iike this ?

frappe.ui.form.on(“Item Group”, {
validate: function(frm) {
if (frm.doc.length && frm.doc.width){
frm.doc.area = frm.doc.length* frm.doc.width;
}
}

add code frm.set_value(‘area’, doc.area)

Hi @san_aet

Try below code

frappe.ui.form.on("Item Group", {
	validate: function(frm) {
		frm.trigger("calculate_area")
	},

	length: function(frm) {
		frm.trigger("calculate_area")
	},

	width: function(frm) {
		frm.trigger("calculate_area")
	},

	calculate_area: function(frm) {
		if (frm.doc.length && frm.doc.width){ 
			area = flt(frm.doc.length* frm.doc.width);
			frm.set_value('area', area)
		}
	}
})

It works :slight_smile: Thanks a lot !!!


Sandhya Anbu
rohit_w
March 17
Hi @san_aet
Try below code
frappe.ui.form.on(“Item Group”, {
validate: function(frm) {
frm.trigger(“calculate_area”)
},

length: function(frm) {
	frm.trigger("calculate_area")
},

width: function(frm) {
	frm.trigger("calculate_area")
},

calculate_area: function(frm) {
	if (frm.doc.length && frm.doc.width){ 
		area = flt(frm.doc.length* frm.doc.width);
		frm.set_value('area', area)
	}
}

})


Visit Topic or reply to this email to respond.

In Reply To
san_aet
March 17
Iike this ?

frappe.ui.form.on(“Item Group”, { validate: function(frm) { if (frm.doc.length && frm.doc.width){ frm.doc.area = frm.doc.length* frm.doc.width; } }

add code frm.set_value(‘area’, doc.area)

1 Like

Hi Rohit,

In this page, i am able to search the sales order only with the title name but i want to search with SO numbers. How can i do that? Also, i want to change the column fields or i want to include more columns. Please advise.

Regards,
Sandhya


Sandhya Anbu
rohit_w
March 17
Hi @san_aet
Try below code
frappe.ui.form.on(“Item Group”, {
validate: function(frm) {
frm.trigger(“calculate_area”)
},

length: function(frm) {
	frm.trigger("calculate_area")
},

width: function(frm) {
	frm.trigger("calculate_area")
},

calculate_area: function(frm) {
	if (frm.doc.length && frm.doc.width){ 
		area = flt(frm.doc.length* frm.doc.width);
		frm.set_value('area', area)
	}
}

})


Visit Topic or reply to this email to respond.

In Reply To
san_aet
March 17
Iike this ?

frappe.ui.form.on(“Item Group”, { validate: function(frm) { if (frm.doc.length && frm.doc.width){ frm.doc.area = frm.doc.length* frm.doc.width; } }

add code frm.set_value(‘area’, doc.area)

Add a filter and choose name

Thanks


Sandhya Anbu
JoEz
March 19
Add a filter and choose name

Visit Topic or reply to this email to respond.

In Reply To
san_aet
March 19
Hi Rohit,

In this page, i am able to search the sales order only with the title name but i want to search with SO numbers. How can i do that? Also, i want to change the column fields or i want to include more columns. Please advise.

Regards, Sandhya

– Sandhya Anbu rohit_w March 17 Hi @san_a

I want to create a table for the fields under carton details. How can i create a table?

Regards,
san


Sandhya Anbu
JoEz
March 19
Add a filter and choose name

Visit Topic or reply to this email to respond.

In Reply To
san_aet
March 19
Hi Rohit,

In this page, i am able to search the sales order only with the title name but i want to search with SO numbers. How can i do that? Also, i want to change the column fields or i want to include more columns. Please advise.

Regards, Sandhya

– Sandhya Anbu rohit_w March 17 Hi @san_a

Can anybody advise ?


Sandhya Anbu
JoEz
March 19
Add a filter and choose name

Visit Topic or reply to this email to respond.

In Reply To
san_aet
March 19
Hi Rohit,

In this page, i am able to search the sales order only with the title name but i want to search with SO numbers. How can i do that? Also, i want to change the column fields or i want to include more columns. Please advise.

Regards, Sandhya

– Sandhya Anbu rohit_w March 17 Hi @san_a

  1. Make new custom doctype(example: Test Child Doc) and enable Is Child Table option in the doctype.

  2. Create custom field for stock entry doctype with field type as Table and options as name of the above doctype(example: Test Child Doc)

Check how to make custom doctype here

Thanks.

Please advise…

I created an Item group named PCB but i am getting the error("Server error: please check ur server logs or contact tech support ") when i save this page after entering data in fields.
I doubt the way i created item groups.

  1. Could you please advise on how to create item groups ?
  2. After creating groups, How can i fetch the bunch of data (Product description) from item group form to another form Quotation?

rohit_w
March 20

Sandhya Anbu san_aet:

I want to create a table for the fields under carton details. How can i create a table?

Make new custom doctype(example: Test Child Doc) and enable Is Child Table option in the doctype.
*
Create custom field for stock entry doctype with field type as Table and options as name of the above doctype(example: Test Child Doc)
Check how to make custom doctype here

Visit Topic or reply to this email to respond.

In Reply To
san_aet
March 20
I want to create a table for the fields under carton details. How can i create a table?

Regards, san

– Sandhya Anbu JoEz March 19 Add a filter and choose name

Visit Topic or reply to this email to respond.
In Reply To san_aet March 19 Hi Rohit,

In this page, i am able to search the sale…

I created an Item group named PCB but i am getting the error("Server error: please check ur server logs or contact tech support ") when i save this page after entering data in fields.I doubt the way i created item groups.

  1. please advise on how to create item groups ?
  2. After creating groups, How can i fetch the bunch of data (Product description) from item group form to another form Quotation?

Can anybody advise on the below problem?

I created an Item group named PCB but i am getting the error("Server error: please check ur server logs or contact tech support ") when i save this page after entering data in fields.
I doubt the way i created item groups.

  1. Could you please advise on how to create item groups ?
  2. After creating groups, How can i fetch the bunch of data (Product description) from item group form to another form Quotation?

rohit_w
March 20

Sandhya Anbu san_aet:

I want to create a table for the fields under carton details. How can i create a table?

Make new custom doctype(example: Test Child Doc) and enable Is Child Table option in the doctype.
*
Create custom field for stock entry doctype with field type as Table and options as name of the above doctype(example: Test Child Doc)
Check how to make custom doctype here

Visit Topic or reply to this email to respond.

In Reply To
san_aet
March 20
I want to create a table for the fields under carton details. How can i create a table?

Regards, san

– Sandhya Anbu JoEz March 19 Add a filter and choose name

Visit Topic or reply to this email to respond.
In Reply To san_aet March 19 Hi Rohit,

In this page, i am able to search the sale…

Rohit,

Could u please advise what i need to do on the below error?

Hi @san_aet

Did you added any custom field on the quotation form?

https://frappe.github.io/erpnext/user/manual/en/stock/setup/item-group

https://frappe.github.io/erpnext/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/custom-script-fetch-values-from-master

I added many custom fields but i did not receive error at that time. I receive this error suddenly after creating item and when i wanted to do quotation.

I added many custom fields and the form got saved properly. Now it shows error when i want to save the quotation

How to set default quantity numbers
for stock levels in erp next?

I am receiving “none type object not callable” error in quotation form. Please advise on what can be done…