<commit_before># Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe.utils import cint, cstr, flt, nowdate, nowtime
from frappe import _
from erpnext.accounts.accounts_custom_methods import stock_entry_for_out
import datetime
from tools.custom_data_methods import get_user_branch, get_branch_cost_center, get_branch_warehouse, update_serial_no

class Trials(Document):
	def validate(self):
		self.finished_all_trials_for_SelectedProcess()
		self.make_event_for_trials()
		self.autoOperation()
		self.update_trials_status()
		# self.update_branch_of_warehouse()

	def finished_all_trials_for_SelectedProcess(self):
		if self.finish_trial_for_process and not frappe.db.get_value('Completed Process Log', {'parent':self.name, 'completed_process': self.finish_trial_for_process}, 'completed_process'):
			response = self.make_process_completed_log()
			if response:
				frappe.db.sql("""update `tabProcess Allotment` set process_trials = (select name from `tabCustomer` where 1=2),
					emp_status='', start_date=(select name from `tabSupplier` where 1=2), qc=0 where pdd = '%s' 
					and process='%s'"""%(self.pdd, self.finish_trial_for_process))
				frappe.db.sql(""" update `tabWork Order` set trial_no = (select true from dual where 1=2) where work_order_name ='%s'"""%(self.work_order))
				self.prepare_ste_for_finished_process()

	def make_process_completed_log(self):
		obj = self.append('completed_process_log', {})
		obj.completed_process = self.finish_trial_for_process
		idx = frappe.db.sql("select ifnull(max(idx),0) from `tabCompleted Process Log` where parent='%s'"%(self.name), as_list=1)
		obj.idx = cint(idx[0][0]) + 1
		return "Done"

	def prepare_ste_for_finished_process(self):
		for d in self.get('completed_process_log'):
			if d.completed_process and not d.ste_no:
				self.update_process_staus(d)
				branch = self.get_target_branch(d.completed_process)
				if branch != get_user_branch() and not frappe.db.get_value('Stock Entry Detail', {'work_order': self.work_order, 'target_branch':branch, 'docstatus':0, 's_warehouse': get_branch_warehouse(get_user_branch())}, 'name'):
					s= {'work_order': self.work_order, 'status': 'Release', 'item': self.item_code}
					d.ste_no = stock_entry_for_out(s, branch, self.trials_serial_no_status, 1)
				

	def update_process_staus(self, args):
		qc_status = 0<commit_msg>trial date null in WO on cancellation of trials<commit_after># Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe.utils import cint, cstr, flt, nowdate, nowtime
from frappe import _
from erpnext.accounts.accounts_custom_methods import stock_entry_for_out
import datetime
from tools.custom_data_methods import get_user_branch, get_branch_cost_center, get_branch_warehouse, update_serial_no

class Trials(Document):
	def validate(self):
		self.finished_all_trials_for_SelectedProcess()
		self.make_event_for_trials()
		self.autoOperation()
		self.update_trials_status()
		# self.update_branch_of_warehouse()

	def finished_all_trials_for_SelectedProcess(self):
		if self.finish_trial_for_process and not frappe.db.get_value('Completed Process Log', {'parent':self.name, 'completed_process': self.finish_trial_for_process}, 'completed_process'):
			response = self.make_process_completed_log()
			if response:
				frappe.db.sql("""update `tabProcess Allotment` set process_trials = (select name from `tabCustomer` where 1=2),
					emp_status='', start_date=(select name from `tabSupplier` where 1=2), qc=0 where pdd = '%s' 
					and process='%s'"""%(self.pdd, self.finish_trial_for_process))
				frappe.db.sql(""" update `tabWork Order` set trial_no = (select true from dual where 1=2), trial_date = (select true from dual where 1=2) where work_order_name ='%s'"""%(self.work_order))
				self.prepare_ste_for_finished_process()

	def make_process_completed_log(self):
		obj = self.append('completed_process_log', {})
		obj.completed_process = self.finish_trial_for_process
		idx = frappe.db.sql("select ifnull(max(idx),0) from `tabCompleted Process Log` where parent='%s'"%(self.name), as_list=1)
		obj.idx = cint(idx[0][0]) + 1
		return "Done"

	def prepare_ste_for_finished_process(self):
		for d in self.get('completed_process_log'):
			if d.completed_process and not d.ste_no:
				self.update_process_staus(d)
				branch = self.get_target_branch(d.completed_process)
				if branch != get_user_branch() and not frappe.db.get_value('Stock Entry Detail', {'work_order': self.work_order, 'target_branch':branch, 'docstatus':0, 's_warehouse': get_branch_warehouse(get_user_branch())}, 'name'):
					s= {'work_order': self.work_order, 'status': 'Release', 'item': self.item_code}
					d.ste_no = stock_entry_for_out(s, branch, self.trials_serial_no_status, 1)
				

	def update_process_staus(self, args):
		qc_status = 0
{'fraction_non_alphanumeric': 0.11303501945525292, 'fraction_numerical': 0.007782101167315175, 'mean_word_length': 6.2306610407876235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5383348', 'n_tokens_mistral': 1868, 'n_tokens_neox': 1700, 'n_words': 388}