def get_serial_no(doctype, txt, searchfield, start, page_len, filters):
    if filters.get('trial_no'):
        return frappe.db.sql(
            """ select name from `tabSerial No` where name in (select
			trials_serial_no_status from `tabTrials` where work_order='%s') and warehouse='%s'
			and (select status from `tabWork Order` where name='%s') = 'Release'""" %
            (filters.get('work_order'), get_branch_warehouse(
                get_user_branch()), filters.get('work_order')))
    else:
        return frappe.db.sql(
            """ select name from `tabSerial No` where warehouse = '%s' and work_order='%s' 
			and (select status from `tabWork Order` where name='%s') = 'Release'""" %
            (get_branch_warehouse(get_user_branch()),
             filters.get('work_order'), filters.get('work_order')))
Example #2
0
 	def stock_entry_of_child(self, obj, args, target_branch):
		ste = obj.append('mtn_details', {})
		ste.s_warehouse = get_branch_warehouse(get_user_branch())
		ste.target_branch = target_branch
		ste.t_warehouse = get_branch_warehouse(target_branch)
		ste.qty = args.get('qty')
		ste.serial_no = args.get('serial_data')
		ste.incoming_rate = 1.0
		ste.conversion_factor = 1.0
		ste.has_trials = 'Yes'
		ste.work_order = args.get('work_order')
		ste.item_code = args.get('item')
		ste.item_name = frappe.db.get_value('Item', ste.item_code, 'item_name')
		ste.stock_uom = frappe.db.get_value('Item', ste.item_code, 'stock_uom')
		company = frappe.db.get_value('GLobal Default', None, 'company')
		ste.expense_account = frappe.db.get_value('Company', company, 'default_expense_account')
		return "Done"
def stock_entry_for_out(args, target_branch, sn_list, qty):
    if target_branch != get_user_branch():
        parent = frappe.db.get_value(
            'Stock Entry Detail', {
                'target_branch': target_branch,
                'docstatus': 0,
                's_warehouse': get_branch_warehouse(get_user_branch())
            }, 'parent')
        if parent:
            obj = frappe.get_doc('Stock Entry', parent)
            stock_entry_of_child(obj, args, target_branch, sn_list, qty)
            obj.save(ignore_permissions=True)
        else:
            parent = make_StockEntry(args, target_branch, sn_list, qty)
        return parent
    else:
        return "Completed"
Example #4
0
	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)
Example #5
0
	def prepare_for_ste(self, trial_data, branch, data, msg):
		parent = frappe.db.get_value('Stock Entry Detail', {'target_branch':data.branch, 'docstatus':0, 's_warehouse': get_branch_warehouse(trial_data.trial_branch)}, 'parent')
		args = {'qty': 1, 'serial_data': self.trials_serial_no_status, 'work_order': self.work_order, 'item': self.item_code, 'trials': trial_data.next_trial_no}	
		if parent:
			st = frappe.get_doc('Stock Entry', parent)
			self.stock_entry_of_child(st, args, branch)
			st.save(ignore_permissions=True)
		else:
			parent = self.make_stock_entry(branch, args)
		if parent:
			update_serial_no(self.pdd, self.trials_serial_no_status, msg)
			frappe.db.sql(""" update `tabProcess Log` set reverse_entry = 'Done' where name ='%s'"""%(data.name))