예제 #1
0
 def autoname(self):
   #self.doc.name = make_autoname(self.doc.naming_series+'.#####')
   # custom autoname
   if self.doc.sub_category == 'INR':
     self.doc.name = make_autoname(cstr(self.doc.supplier_name)+'/'+self.doc.naming_series+'/I/.####')
   elif self.doc.sub_category == 'DI':
     self.doc.name = make_autoname(cstr(self.doc.supplier_name)+'/'+self.doc.naming_series+'/D/.####')
예제 #2
0
 def autoname(self):
   ret = sql("select value from `tabSingles` where doctype = 'Global Defaults' and field = 'emp_created_by'")
   if not ret:
     msgprint("To Save Employee, please go to Setup -->Global Defaults. Click on HR and select 'Employee Records to be created by'.")
     raise Exception 
   else:
     if ret[0][0]=='Naming Series':
       self.doc.name = make_autoname(self.doc.naming_series + '.####')
     elif ret[0][0]=='Employee Number':
       self.doc.name = make_autoname(self.doc.employee_number)
예제 #3
0
	def autoname(self):
		ret = sql("select value from `tabSingles` where doctype = 'Global Defaults' and field = 'emp_created_by'")
		if not ret:
			msgprint("Please setup Employee Naming System in Setup > Global Defaults > HR", raise_exception=True)
		else:
			if ret[0][0]=='Naming Series':
				self.doc.name = make_autoname(self.doc.naming_series + '.####')
			elif ret[0][0]=='Employee Number':
				self.doc.name = make_autoname(self.doc.employee_number)

		self.doc.employee = self.doc.name
예제 #4
0
 def autoname(self):
     key = webnotes.conn.get_value("LocGlobKey", None, "key")
     curr = webnotes.conn.get_value('Series','A'+str(date.today().year)[-2:]+key,'current')
     if cint(curr)==99:
         key1 = key[0]
         key2 = key[1]
         key2 = key2.replace(key2,chr(ord(key2)+1))
         key = key1 + key2
         webnotes.conn.set_value("LocGlobKey", "LocGlobKey", "key", key)
     self.doc.patient_local_id = make_autoname('A'+str(date.today().year)[-2:]+key+'.##')
     # self.doc.name = self.doc.patient_local_id
 
     dt=today()
     ss="C"+cstr(dt[2:4]+cstr(dt[5:7]))+self.doc.lab_branch[1:]+"-"+key+"-"+''
     key="GID.##"
     n = ''
     l = key.split('.')
     series_set = False
     doctype=''
     for e in l:
         en = ''
         if e.startswith('#'):
             if not series_set:
                 digits = len(e)
                 en = self.getseries(n, digits, doctype)
                 series_set = True
         else: en = e
         n+=en
     self.doc.patient_online_id=ss+n[3:]
     self.doc.name = self.doc.patient_online_id
예제 #5
0
	def test_5_make_autoname(self):
		new_name = doc.make_autoname(self.test_doc.name,self.test_doc.parenttype)
		last_name = testlib.test_conn.sql("select name from `tab%s` order by name desc limit 1"%testlib.test_doctype)		
		if not last_name:
			last_name = '0'
		webnotes.conn.commit()
		assert (cint(new_name[get_num_start_pos(new_name):])) - cint(last_name[get_num_start_pos(last_name):])
예제 #6
0
	def convert_into_recurring(self):
		if self.doc.convert_into_recurring_invoice:
			self.set_next_date()
			if not self.doc.recurring_id:
				webnotes.conn.set(self.doc, 'recurring_id', make_autoname('RECINV/.#####'))
		elif self.doc.recurring_id:
			webnotes.conn.sql("""update `tabReceivable Voucher` set convert_into_recurring_invoice = 0 where recurring_id = %s""", self.doc.recurring_id)
예제 #7
0
	def validate_serial_no(self, item_det):
		if item_det.has_serial_no=="No":
			if self.doc.serial_no:
				webnotes.throw(_("Serial Number should be blank for Non Serialized Item" + ": " + self.doc.item), 
					SerialNoNotRequiredError)
		else:
			if self.doc.serial_no:
				serial_nos = get_serial_nos(self.doc.serial_no)
				if cint(self.doc.actual_qty) != flt(self.doc.actual_qty):
					webnotes.throw(_("Serial No qty cannot be a fraction") + \
						(": %s (%s)" % (self.doc.item_code, self.doc.actual_qty)))
				if len(serial_nos) and len(serial_nos) != abs(cint(self.doc.actual_qty)):
					webnotes.throw(_("Serial Nos do not match with qty") + \
						(": %s (%s)" % (self.doc.item_code, self.doc.actual_qty)), SerialNoQtyError)

				# check serial no exists, if yes then source
				for serial_no in serial_nos:
					if webnotes.conn.exists("Serial No", serial_no):
						sr = webnotes.bean("Serial No", serial_no)

						if sr.doc.item_code!=self.doc.item_code:
							webnotes.throw(_("Serial No does not belong to Item") + \
								(": %s (%s)" % (self.doc.item_code, serial_no)), SerialNoItemError)

						sr.make_controller().via_stock_ledger = True

						if self.doc.actual_qty < 0:
							if sr.doc.warehouse!=self.doc.warehouse:
								webnotes.throw(_("Warehouse does not belong to Item") + \
									(": %s (%s)" % (self.doc.item_code, serial_no)), SerialNoWarehouseError)
								
							if self.doc.voucher_type in ("Delivery Note", "Sales Invoice") \
								and sr.doc.status != "Available":
								webnotes.throw(_("Serial No status must be 'Available' to Deliver") + \
									": " + serial_no, SerialNoStatusError)
								
									
							sr.doc.warehouse = None
							sr.save()
						else:
							sr.doc.warehouse = self.doc.warehouse
							sr.save()
					else:
						if self.doc.actual_qty < 0:
							# transfer out
							webnotes.throw(_("Serial No must exist to transfer out.") + \
								": " + serial_no, SerialNoNotExistsError)
						else:
							# transfer in
							self.make_serial_no(serial_no)
			else:
				if item_det.serial_no_series:
					from webnotes.model.doc import make_autoname
					serial_nos = []
					for i in xrange(cint(self.doc.actual_qty)):
						serial_nos.append(self.make_serial_no(make_autoname(item_det.serial_no_series)))
					self.doc.serial_no = "\n".join(serial_nos)
				else:
					webnotes.throw(_("Serial Number Required for Serialized Item" + ": " + self.doc.item),
						SerialNoRequiredError)
예제 #8
0
파일: customer.py 프로젝트: abordin/erpnext
	def autoname(self):
		cust_master_name = webnotes.defaults.get_global_default('cust_master_name')
		if cust_master_name == 'Customer Name':
			if webnotes.conn.exists("Supplier", self.doc.customer_name):
				msgprint(_("A Supplier exists with same name"), raise_exception=1)
			self.doc.name = self.doc.customer_name
		else:
			self.doc.name = make_autoname(self.doc.naming_series+'.#####')
예제 #9
0
파일: item.py 프로젝트: rajatkapoor/erpnext
	def autoname(self):
		if webnotes.conn.get_default("item_naming_by")=="Naming Series":
			from webnotes.model.doc import make_autoname
			self.doc.item_code = make_autoname(self.doc.naming_series+'.#####')
		elif not self.doc.item_code:
			msgprint(_("Item Code (item_code) is mandatory because Item naming is not sequential."), raise_exception=1)
			
		self.doc.name = self.doc.item_code
예제 #10
0
	def convert_into_recurring(self):
		if self.doc.convert_into_recurring_invoice:
			if not self.doc.invoice_period_from_date or not self.doc.invoice_period_to_date:
				msgprint("Invoice period from date and to date is mandatory for recurring invoice", raise_exception=1)
			self.set_next_date()
			if not self.doc.recurring_id:
				webnotes.conn.set(self.doc, 'recurring_id', make_autoname('RECINV/.#####'))
		elif self.doc.recurring_id:
			webnotes.conn.sql("""update `tabSales Invoice` set convert_into_recurring_invoice = 0 where recurring_id = %s""", self.doc.recurring_id)
예제 #11
0
파일: supplier.py 프로젝트: hfeeki/erpnext
	def autoname(self):
		supp_master_name = get_defaults()['supp_master_name']
		
		if supp_master_name == 'Supplier Name':
			if webnotes.conn.exists("Customer", self.doc.supplier_name):
				webnotes.msgprint(_("A Customer exists with same name"), raise_exception=1)
			self.doc.name = self.doc.supplier_name
		else:
			self.doc.name = make_autoname(self.doc.naming_series + '.#####')
예제 #12
0
파일: employee.py 프로젝트: Jdfkat/erpnext
	def autoname(self):
		naming_method = webnotes.conn.get_value("HR Settings", None, "emp_created_by")
		if not naming_method:
			webnotes.throw(_("Please setup Employee Naming System in Human Resource > HR Settings"))
		else:
			if naming_method=='Naming Series':
				self.doc.name = make_autoname(self.doc.naming_series + '.####')
			elif naming_method=='Employee Number':
				self.doc.name = self.doc.employee_number

		self.doc.employee = self.doc.name
예제 #13
0
    def convert_into_recurring(self):
        if self.doc.convert_into_recurring_invoice:
            self.set_next_date()
            if not self.doc.recurring_id:
                webnotes.conn.set(self.doc, "recurring_id", make_autoname("RECINV/.#####"))
        elif self.doc.recurring_id:
            webnotes.conn.sql(
                """update `tabReceivable Voucher` set convert_into_recurring_invoice = 0 where recurring_id = %s""",
                self.doc.recurring_id,
            )

        self.manage_scheduler()
예제 #14
0
	def convert_to_recurring(self):
		if self.doc.convert_into_recurring_invoice:
			if not self.doc.recurring_id:
				webnotes.conn.set(self.doc, "recurring_id",
					make_autoname("RECINV/.#####"))
			
			self.set_next_date()

		elif self.doc.recurring_id:
			webnotes.conn.sql("""update `tabSales Invoice`
				set convert_into_recurring_invoice = 0
				where recurring_id = %s""", (self.doc.recurring_id,))
예제 #15
0
파일: customer.py 프로젝트: antoxin/erpnext
	def autoname(self):
		cust_master_name = get_defaults().get('cust_master_name')
		if cust_master_name == 'Customer Name':
			# filter out bad characters in name
			#cust = self.doc.customer_name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','')
			cust = self.doc.customer_name

			supp = sql("select name from `tabSupplier` where name = %s", (cust))
			supp = supp and supp[0][0] or ''
			if supp:
				msgprint("You already have a Supplier with same name")
				raise Exception("You already have a Supplier with same name")
			else:
				self.doc.name = cust
		else:
			self.doc.name = make_autoname(self.doc.naming_series+'.#####')
예제 #16
0
def update_serial_nos(sle, item_det):
	if sle.serial_no:
		serial_nos = get_serial_nos(sle.serial_no)
		for serial_no in serial_nos:
			if webnotes.conn.exists("Serial No", serial_no):
				sr = webnotes.bean("Serial No", serial_no)
				sr.make_controller().via_stock_ledger = True
				sr.doc.warehouse = sle.warehouse if sle.actual_qty > 0 else None
				sr.save()
			elif sle.actual_qty > 0:
				make_serial_no(serial_no, sle)
	elif sle.actual_qty > 0 and item_det.serial_no_series:
		from webnotes.model.doc import make_autoname
		serial_nos = []
		for i in xrange(cint(sle.actual_qty)):
			serial_nos.append(make_serial_no(make_autoname(item_det.serial_no_series), sle))
		sle.serial_no = "\n".join(serial_nos)
예제 #17
0
	def autoname(self):
		#get default naming conventional from control panel
		supp_master_name = get_defaults()['supp_master_name']

		if supp_master_name == 'Supplier Name':
		
			# filter out bad characters in name
			#supp = self.doc.supplier_name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','')
			supp = self.doc.supplier_name
			
			cust = sql("select name from `tabCustomer` where name = '%s'" % (supp))
			cust = cust and cust[0][0] or ''
		
			if cust:
				msgprint("You already have a Customer with same name")
				raise Exception
			self.doc.name = supp
			
		else:
			self.doc.name = make_autoname(self.doc.naming_series+'.#####')
예제 #18
0
	def autoname(self):
		self.doc.name = make_autoname('Form 16A' + '/.#####') 
예제 #19
0
	def autoname(self):
		if not self.doc.naming_series:
			webnotes.msgprint("""Naming Series is mandatory""", raise_exception=1)
			
		self.doc.name = make_autoname(self.doc.naming_series+'.#####')
예제 #20
0
 def autoname(self):
   self.doc.name = make_autoname(self.doc.employee + '/.SST' + '/.#####')
예제 #21
0
 def autoname(self):
     self.doc.name = make_autoname('Sal Slip/' + self.doc.employee +
                                   '/.#####')
예제 #22
0
    def validate_serial_no(self, item_det):
        if item_det.has_serial_no == "No":
            if self.doc.serial_no:
                webnotes.throw(
                    _("Serial Number should be blank for Non Serialized Item" +
                      ": " + self.doc.item), SerialNoNotRequiredError)
        else:
            if self.doc.serial_no:
                serial_nos = get_serial_nos(self.doc.serial_no)
                if cint(self.doc.actual_qty) != flt(self.doc.actual_qty):
                    webnotes.throw(_("Serial No qty cannot be a fraction") + \
                     (": %s (%s)" % (self.doc.item_code, self.doc.actual_qty)))
                if len(serial_nos) and len(serial_nos) != abs(
                        cint(self.doc.actual_qty)):
                    webnotes.throw(_("Serial Nos do not match with qty") + \
                     (": %s (%s)" % (self.doc.item_code, self.doc.actual_qty)), SerialNoQtyError)

                # check serial no exists, if yes then source
                for serial_no in serial_nos:
                    if webnotes.conn.exists("Serial No", serial_no):
                        sr = webnotes.bean("Serial No", serial_no)

                        if sr.doc.item_code != self.doc.item_code:
                            webnotes.throw(_("Serial No does not belong to Item") + \
                             (": %s (%s)" % (self.doc.item_code, serial_no)), SerialNoItemError)

                        sr.make_controller().via_stock_ledger = True

                        if self.doc.actual_qty < 0:
                            if sr.doc.warehouse != self.doc.warehouse:
                                webnotes.throw(
                                    _("Serial No") + ": " + serial_no +
                                    _(" does not belong to Warehouse") + ": " +
                                    self.doc.warehouse, SerialNoWarehouseError)

                            if self.doc.voucher_type in ("Delivery Note", "Sales Invoice") \
                             and sr.doc.status != "Available":
                                webnotes.throw(
                                    _("Serial No status must be 'Available' to Deliver"
                                      ) + ": " + serial_no,
                                    SerialNoStatusError)

                            sr.doc.warehouse = None
                            sr.save()
                        else:
                            sr.doc.warehouse = self.doc.warehouse
                            sr.save()
                    else:
                        if self.doc.actual_qty < 0:
                            # transfer out
                            webnotes.throw(_("Serial No must exist to transfer out.") + \
                             ": " + serial_no, SerialNoNotExistsError)
                        else:
                            # transfer in
                            self.make_serial_no(serial_no)
            else:
                if item_det.serial_no_series:
                    from webnotes.model.doc import make_autoname
                    serial_nos = []
                    for i in xrange(cint(self.doc.actual_qty)):
                        serial_nos.append(
                            self.make_serial_no(
                                make_autoname(item_det.serial_no_series)))
                    self.doc.serial_no = "\n".join(serial_nos)
                else:
                    webnotes.throw(
                        _("Serial Number Required for Serialized Item" + ": " +
                          self.doc.item), SerialNoRequiredError)
예제 #23
0
	def autoname(self):
		self.doc.name = make_autoname('Form 16A' + '/.#####') 
예제 #24
0
	def autoname(self):
		gl_name = make_autoname(webnotes.conn.get_value('DocType', 'GL Entry', 'autoname'))
		company = webnotes.conn.sql(""" select name from tabCompany 
				where name = (select value from tabSingles 
					where doctype = 'Global Defaults' and field = 'default_company') """)[0][0]
		self.doc.name = company + ' ' + gl_name
예제 #25
0
	def autoname(self):
		p = self.doc.fiscal_year
		self.doc.name = make_autoname('PRO/' + self.doc.fiscal_year[2:5]+self.doc.fiscal_year[7:9] + '/.######')
예제 #26
0
 def autoname(self):
     self.doc.name = make_autoname(self.doc.naming_series + '.####')
예제 #27
0
	def autoname(self):
		"""
			Create Lease Id using naming_series pattern
		"""
		self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
예제 #28
0
 def autoname(self):
   self.doc.name = make_autoname(self.doc.from_doctype + '-' + self.doc.to_doctype)
예제 #29
0
 def autoname(self):
   self.doc.name = make_autoname('IT Check/' +self.doc.employee + '/.#####')
예제 #30
0
 def autoname(self):
     self.doc.name = make_autoname(self.doc.fiscal_year + "/" +
                                   self.doc.holiday_list_name + "/.###")
예제 #31
0
	def autoname(self):
		self.doc.name = make_autoname(self.doc.fiscal_year +"/"+ self.doc.holiday_list_name+"/.###")
예제 #32
0
 def autoname(self):
     self.doc.name = make_autoname(self.doc.employee + '/.SST' + '/.#####')
예제 #33
0
	def autoname(self):
		self.doc.name = make_autoname('Sal Slip/' +self.doc.employee + '/.#####') 
예제 #34
0
	def autoname(self):
		from webnotes.model.doc import make_autoname
		month=datetime.datetime.now().strftime("%B").upper()
		year=datetime.datetime.now().strftime("%y")
		self.doc.name = make_autoname('MS-PO/' + month + '/' + year + '/' + '.###')
예제 #35
0
	def autoname(self):
		self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
예제 #36
0
파일: sales_bom.py 프로젝트: nijil/erpnext
 def validate(self):
     # check for duplicate
     self.check_duplicate()
     item_code = self.get_main_item()
     if not self.doc.new_item_code:
         self.doc.new_item_code = make_autoname(item_code + ".###")
예제 #37
0
 def autoname(self):
   self.doc.name = make_autoname('EMP-'+self.doc.employee)