Beispiel #1
0
	def update_serial_record(self, obj, fname, is_submit = 1, is_incoming = 0):
		for d in getlist(obj.doclist, fname):
			if d.serial_no:
				serial_nos = get_valid_serial_nos(d.serial_no)
				for a in serial_nos:
					serial_no = a.strip()
					if is_incoming:
						self.update_serial_purchase_details(obj, d, serial_no, is_submit)
					else:
						self.update_serial_delivery_details(obj, d, serial_no, is_submit)

			if fname == 'purchase_receipt_details' and d.rejected_qty and d.rejected_serial_no:
				serial_nos = get_valid_serial_nos(d.rejected_serial_no)
				for a in serial_nos:
					self.update_serial_purchase_details(obj, d, a, is_submit, rejected=True)
Beispiel #2
0
	def update_stock(self, values, is_amended = 'No'):
		for v in values:
			sle_id, valid_serial_nos = '', ''
			# get serial nos
			if v.get("serial_no", "").strip():
				valid_serial_nos = get_valid_serial_nos(v["serial_no"], 
					v['actual_qty'], v['item_code'])
				v["serial_no"] = valid_serial_nos and "\n".join(valid_serial_nos) or ""
			
			# reverse quantities for cancel
			if v.get('is_cancelled') == 'Yes':
				v['actual_qty'] = -flt(v['actual_qty'])
				# cancel matching entry
				webnotes.conn.sql("""update `tabStock Ledger Entry` set is_cancelled='Yes',
					modified=%s, modified_by=%s
					where voucher_no=%s and voucher_type=%s""", 
					(now(), webnotes.session.user, v['voucher_no'], v['voucher_type']))

			if v.get("actual_qty"):
				sle_id = self.make_entry(v)
				
			args = v.copy()
			args.update({
				"sle_id": sle_id,
				"is_amended": is_amended
			})
			
			get_obj('Warehouse', v["warehouse"]).update_bin(args)
Beispiel #3
0
    def on_cancel(self):
        for d in getlist(self.doclist, 'item_maintenance_detail'):
            if d.serial_no:
                serial_nos = get_valid_serial_nos(d.serial_no)
                self.update_amc_date(serial_nos)

        webnotes.conn.set(self.doc, 'status', 'Cancelled')
        delete_events(self.doc.doctype, self.doc.name)
Beispiel #4
0
	def on_cancel(self):
		for d in getlist(self.doclist, 'item_maintenance_detail'):
			if d.serial_no:
				serial_nos = get_valid_serial_nos(d.serial_no)
				self.update_amc_date(serial_nos)
				
		webnotes.conn.set(self.doc, 'status', 'Cancelled')
		delete_events(self.doc.doctype, self.doc.name)
Beispiel #5
0
	def validate_serial_no(self):
		cur_s_no, prevdoc_s_no, sr_list = [], [], []
		for d in getlist(self.doclist, 'installed_item_details'):
			self.is_serial_no_added(d.item_code, d.serial_no)
			if d.serial_no:
				sr_list = get_valid_serial_nos(d.serial_no, d.qty, d.item_code)
				self.is_serial_no_exist(d.item_code, sr_list)
				
				prevdoc_s_no = self.get_prevdoc_serial_no(d.prevdoc_detail_docname)
				if prevdoc_s_no:
					self.is_serial_no_match(sr_list, prevdoc_s_no, d.prevdoc_docname)
				
				self.is_serial_no_installed(sr_list, d.item_code)
Beispiel #6
0
	def validate_serial_no_warehouse(self, obj, fname):
		for d in getlist(obj.doclist, fname):
			wh = d.warehouse or d.s_warehouse
			if d.serial_no and wh:
				serial_nos = get_valid_serial_nos(d.serial_no)
				for s in serial_nos:
					s = s.strip()
					sr_war = sql("select warehouse,name from `tabSerial No` where name = '%s'" % (s))
					if not sr_war:
						msgprint("Serial No %s does not exists"%s, raise_exception = 1)
					elif not sr_war[0][0]:
						msgprint("Warehouse not mentioned in the Serial No <b>%s</b>" % s, raise_exception = 1)
					elif sr_war[0][0] != wh:
						msgprint("Serial No : %s for Item : %s doesn't exists in Warehouse : %s" % (s, d.item_code, wh), raise_exception = 1)
Beispiel #7
0
	def validate_serial_no_warehouse(self, obj, fname):
		for d in getlist(obj.doclist, fname):
			wh = d.warehouse or d.s_warehouse
			if cstr(d.serial_no).strip() and wh:
				serial_nos = get_valid_serial_nos(d.serial_no)
				for s in serial_nos:
					s = s.strip()
					sr_war = webnotes.conn.sql("select warehouse,name from `tabSerial No` where name = '%s'" % (s))
					if not sr_war:
						msgprint("Serial No %s does not exists"%s, raise_exception = 1)
					elif not sr_war[0][0]:
						msgprint("Warehouse not mentioned in the Serial No <b>%s</b>" % s, raise_exception = 1)
					elif sr_war[0][0] != wh:
						msgprint("Serial No : %s for Item : %s doesn't exists in Warehouse : %s" % (s, d.item_code, wh), raise_exception = 1)
Beispiel #8
0
	def validate_serial_no(self):
		cur_s_no, prevdoc_s_no, sr_list = [], [], []
		for d in getlist(self.doclist, 'installed_item_details'):
			self.is_serial_no_added(d.item_code, d.serial_no)
			if d.serial_no:
				sr_list = get_valid_serial_nos(d.serial_no, d.qty, d.item_code)
				self.is_serial_no_exist(d.item_code, sr_list)
				
				prevdoc_s_no = self.get_prevdoc_serial_no(d.prevdoc_detail_docname)
				if prevdoc_s_no:
					self.is_serial_no_match(sr_list, prevdoc_s_no, d.prevdoc_docname)
				
				self.is_serial_no_installed(sr_list, d.item_code)
		return sr_list
Beispiel #9
0
    def on_submit(self):
        if not getlist(self.doclist, 'maintenance_schedule_detail'):
            msgprint("Please click on 'Generate Schedule' to get schedule")
            raise Exception
        self.check_serial_no_added()
        self.validate_schedule()

        email_map = {}
        for d in getlist(self.doclist, 'item_maintenance_detail'):
            if d.serial_no:
                serial_nos = get_valid_serial_nos(d.serial_no)
                self.validate_serial_no(serial_nos, d.start_date)
                self.update_amc_date(serial_nos, d.end_date)

            if d.incharge_name not in email_map:
                email_map[d.incharge_name] = webnotes.bean(
                    "Sales Person", d.incharge_name).run_method("get_email_id")

            scheduled_date =webnotes.conn.sql("select scheduled_date from `tabMaintenance Schedule Detail` \
				where incharge_name='%s' and item_code='%s' and parent='%s' "                                                                           %(d.incharge_name, \
             d.item_code, self.doc.name), as_dict=1)

            for key in scheduled_date:
                if email_map[d.incharge_name]:
                    description = "Reference: %s, Item Code: %s and Customer: %s" % \
                     (self.doc.name, d.item_code, self.doc.customer)
                    webnotes.bean({
                        "doctype":
                        "Event",
                        "owner":
                        email_map[d.incharge_name] or self.doc.owner,
                        "subject":
                        description,
                        "description":
                        description,
                        "starts_on":
                        key["scheduled_date"] + " 10:00:00",
                        "event_type":
                        "Private",
                        "ref_type":
                        self.doc.doctype,
                        "ref_name":
                        self.doc.name
                    }).insert()

        webnotes.conn.set(self.doc, 'status', 'Submitted')
Beispiel #10
0
    def update_serial_no(self, is_submit):
        """Create / Update Serial No"""
        from stock.utils import get_valid_serial_nos

        sl_obj = get_obj("Stock Ledger")
        if is_submit:
            sl_obj.validate_serial_no_warehouse(self, "mtn_details")

        for d in getlist(self.doclist, "mtn_details"):
            if cstr(d.serial_no).strip():
                for x in get_valid_serial_nos(d.serial_no):
                    serial_no = x.strip()
                    if d.s_warehouse:
                        sl_obj.update_serial_delivery_details(self, d, serial_no, is_submit)
                    if d.t_warehouse:
                        sl_obj.update_serial_purchase_details(self, d, serial_no, is_submit, self.doc.purpose)

                    if self.doc.purpose == "Purchase Return":
                        serial_doc = Document("Serial No", serial_no)
                        serial_doc.status = is_submit and "Purchase Returned" or "In Store"
                        serial_doc.docstatus = is_submit and 2 or 0
                        serial_doc.save()
Beispiel #11
0
	def on_submit(self):
		if not getlist(self.doclist, 'maintenance_schedule_detail'):
			msgprint("Please click on 'Generate Schedule' to get schedule")
			raise Exception
		self.check_serial_no_added()
		self.validate_schedule()

		email_map ={}
		for d in getlist(self.doclist, 'item_maintenance_detail'):
			if d.serial_no:
				serial_nos = get_valid_serial_nos(d.serial_no)
				self.validate_serial_no(serial_nos, d.start_date)
				self.update_amc_date(serial_nos, d.end_date)

			if d.incharge_name not in email_map:
				email_map[d.incharge_name] = webnotes.bean("Sales Person", 
					d.incharge_name).run_method("get_email_id")

			scheduled_date =webnotes.conn.sql("select scheduled_date from `tabMaintenance Schedule Detail` \
				where incharge_name='%s' and item_code='%s' and parent='%s' " %(d.incharge_name, \
				d.item_code, self.doc.name), as_dict=1)

			for key in scheduled_date:
				if email_map[d.incharge_name]:
					description = "Reference: %s, Item Code: %s and Customer: %s" % \
						(self.doc.name, d.item_code, self.doc.customer)
					webnotes.bean({
						"doctype": "Event",
						"owner": email_map[d.incharge_name] or self.doc.owner,
						"subject": description,
						"description": description,
						"starts_on": key["scheduled_date"] + " 10:00:00",
						"event_type": "Private",
						"ref_type": self.doc.doctype,
						"ref_name": self.doc.name
					}).insert()

		webnotes.conn.set(self.doc, 'status', 'Submitted')		
Beispiel #12
0
	def update_stock(self, values, is_amended = 'No'):
		for v in values:
			sle_id, serial_nos = '', ''
			# get serial nos
			if v.get("serial_no"):
				serial_nos = get_valid_serial_nos(v["serial_no"], v['actual_qty'], v['item_code'])
			
			# reverse quantities for cancel
			if v.get('is_cancelled') == 'Yes':
				v['actual_qty'] = -flt(v['actual_qty'])
				# cancel matching entry
				sql("update `tabStock Ledger Entry` set is_cancelled='Yes' where voucher_no=%s \
					and voucher_type=%s", (v['voucher_no'], v['voucher_type']))

			if v.get("actual_qty"):
				sle_id = self.make_entry(v)

			args = v.copy()
			args.update({
				"sle_id": sle_id,
				"is_amended": is_amended
			})
			get_obj('Warehouse', v["warehouse"]).update_bin(args)
	def update_serial_no(self, is_submit):
		"""Create / Update Serial No"""
		from stock.utils import get_valid_serial_nos
		
		sl_obj = get_obj('Stock Ledger')
		if is_submit:
			sl_obj.validate_serial_no_warehouse(self, 'mtn_details')
		
		for d in getlist(self.doclist, 'mtn_details'):
			if cstr(d.serial_no).strip():
				for x in get_valid_serial_nos(d.serial_no):
					serial_no = x.strip()
					if d.s_warehouse:
						sl_obj.update_serial_delivery_details(self, d, serial_no, is_submit)
					if d.t_warehouse:
						sl_obj.update_serial_purchase_details(self, d, serial_no, is_submit,
							self.doc.purpose)
					
					if self.doc.purpose == 'Purchase Return':
						serial_doc = Document("Serial No", serial_no)
						serial_doc.status = is_submit and 'Purchase Returned' or 'In Store'
						serial_doc.docstatus = is_submit and 2 or 0
						serial_doc.save()
 def get_prevdoc_serial_no(self, prevdoc_detail_docname):
     serial_nos = webnotes.conn.get_value("Delivery Note Item",
                                          prevdoc_detail_docname,
                                          "serial_no")
     return get_valid_serial_nos(serial_nos)
Beispiel #15
0
	def get_prevdoc_serial_no(self, prevdoc_detail_docname):
		serial_nos = webnotes.conn.get_value("Delivery Note Item", 
			prevdoc_detail_docname, "serial_no")
		return get_valid_serial_nos(serial_nos)
	def get_prevdoc_serial_no(self, prevdoc_detail_docname, prevdoc_docname):
		res = sql("select serial_no from `tabDelivery Note Item` where name = '%s' and parent ='%s'" % (prevdoc_detail_docname, prevdoc_docname))
		return get_valid_serial_nos(res[0][0])
Beispiel #17
0
 def get_prevdoc_serial_no(self, prevdoc_detail_docname, prevdoc_docname):
     res = sql(
         "select serial_no from `tabDelivery Note Item` where name = '%s' and parent ='%s'"
         % (prevdoc_detail_docname, prevdoc_docname))
     return get_valid_serial_nos(res[0][0])