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/.####')
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)
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
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
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):])
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)
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)
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+'.#####')
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
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)
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 + '.#####')
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
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()
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,))
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+'.#####')
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)
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+'.#####')
def autoname(self): self.doc.name = make_autoname('Form 16A' + '/.#####')
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+'.#####')
def autoname(self): self.doc.name = make_autoname(self.doc.employee + '/.SST' + '/.#####')
def autoname(self): self.doc.name = make_autoname('Sal Slip/' + self.doc.employee + '/.#####')
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)
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
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] + '/.######')
def autoname(self): self.doc.name = make_autoname(self.doc.naming_series + '.####')
def autoname(self): """ Create Lease Id using naming_series pattern """ self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
def autoname(self): self.doc.name = make_autoname(self.doc.from_doctype + '-' + self.doc.to_doctype)
def autoname(self): self.doc.name = make_autoname('IT Check/' +self.doc.employee + '/.#####')
def autoname(self): self.doc.name = make_autoname(self.doc.fiscal_year + "/" + self.doc.holiday_list_name + "/.###")
def autoname(self): self.doc.name = make_autoname(self.doc.fiscal_year +"/"+ self.doc.holiday_list_name+"/.###")
def autoname(self): self.doc.name = make_autoname('Sal Slip/' +self.doc.employee + '/.#####')
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 + '/' + '.###')
def autoname(self): self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
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 + ".###")
def autoname(self): self.doc.name = make_autoname('EMP-'+self.doc.employee)