Sometime Python file not working on live server

Hello All,

Currently i am facing big problem with erpnext.

Problem : i called function of py file form js file for my doctype but it’s not working suddenly on my server. Also it’s working properly on my local server as well as it’s proper work in other doctype on live server.

Also even i put a frappe throw in that python file on validate method but it’s also not working in that doctype.same is working on some doctype.

So please assist me how to resolve this problem.

Regards,
Harsh Mehta

Was it working before, and suddenly stopped? Have you made any other changes recently, such as updating bench/frappe/erpnext?

Could you share your code?

Also, are there any messages in the web console when you think the method is supposed to be called?

1 Like

Hello @alec,

Thanks for your quick reply.

It was still working proper in some doctype.i haven’t updated bench. just now i created one doctype and i just put throw alert on validate function in py file but it not showing me any alert. same functionality working in other doctype.Also my function is whitelisted but it’s not calling from JS file.

Hi @Harsh_Mehta Please restart supervisor of the server
using command sudo supervisorctl reload
and check all the field names

1 Like

Hello @ravindra,

Ok I will try and reply to you ASAP.

@Harsh_Mehta if you are making changes in a production server, you will need to restart python processes. Dev server automatically restarts on file change, but production server isn’t designed to do that.

1 Like

Hello Anand,

I made changes on development server and my development mode is also enabled.

Is the validate function hooked into (hooks.py), called from a js handler (frappe.ui.form.on(…)), or added into the standard validate function?

Hello @ravindra,

I have tried but still my problem was not resolved.

@alec : Not a single validate function but any function of my python file is not called from JS file of that doctype. Also insome doctype it’s working and in some doctype it’s not working.

Could you share your code?

Hello @alec,

Below is my code

# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document


class BranchTransfer(Document):
	def validate(self):
		frappe.throw("Hello")

Hello @alec,

Same code is working in my another doctype and below is the working doctype code. So i am little bit confuse that how it’s possible in erpnext.

Same Code that is working in another doctype

# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
import random

class AIJoining(Document):
	def validate(self):
		frappe.throw("Hello")

Is it possible that the non-functional doctype was created as “custom” (check doctype master), and the working doctype was created in developer mode?

Hello @alec,

Both doctype was created in developer mode. Also you can see attached file as my both doctype was not custom checked and master is already selected.

Hello,

Sometimes i got this error in console firebug. So anyone tell me due to this below error i am facing this issue ?

Error : Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/

Hello All,

Is anyone know my error solution ?

Ignore this warning for now

Hello All,

Currently i am facing problem with erpnext.

Problem :i had uploaded my project files to server ,after uploaded when i am try to modify .py files in server its not responding .

Also even i put a frappe throw in that python file on validate method but it’s also not working in that doctype.same is working on some doctype.

So please assist me how to resolve this problem.

Regards,
sunil

Can you check your environment of ERPNext. Also please check your permission of py & pyc file. If it is in production environment then please run command sudo supervisorctl reload from frappe-bench directory and if it is in development environment then your pyc file should generate based on your request.

i will check and update u