def bifurcate_based_on_type(self, doctype_name, total, av_dis, based_on, doc_obj, val, company): add_cond = '' auth_value = av_dis if val == 1: add_cond += " and system_user = '******'user'] + "'" elif val == 2: add_cond += " and system_role IN %s" % ( "('" + "','".join(webnotes.user.get_roles()) + "')") else: add_cond += " and ifnull(system_user,'') = '' and ifnull(system_role,'') = ''" if based_on == 'Grand Total': auth_value = total elif based_on == 'Customerwise Discount': if doc_obj: if doc_obj.doc.doctype == 'Sales Invoice': customer = doc_obj.doc.customer else: customer = doc_obj.doc.customer_name add_cond = " and master_name = '" + make_esc("'")( cstr(customer)) + "'" if based_on == 'Itemwise Discount': if doc_obj: for t in getlist(doc_obj.doclist, doc_obj.fname): self.validate_auth_rule(doctype_name, t.adj_rate, based_on, add_cond, company, t.item_code) else: self.validate_auth_rule(doctype_name, auth_value, based_on, add_cond, company)
def restore_database(self,target,source,root_password): from webnotes.utils import make_esc esc = make_esc('$ ') try: ret = os.system("mysql -u root -p%s %s < %s" % \ (esc(root_password), esc(target), source)) except Exception,e: raise e
def restore_database(self, target, source, root_password): from webnotes.utils import make_esc esc = make_esc('$ ') try: ret = os.system("mysql -u root -p%s %s < %s" % \ (esc(root_password), esc(target), source)) except Exception, e: raise e
def restore_database(self,target,source,root_password): import webnotes.defs mysql_path = getattr(webnotes.defs, 'mysql_path', None) mysql = mysql_path and os.path.join(mysql_path, 'mysql') or 'mysql' from webnotes.utils import make_esc esc = make_esc('$ ') try: ret = os.system("%s -u root -p%s %s < %s"%(mysql, esc(root_password), esc(target), source)) except Exception,e: raise e
def rename_mapper_files(ren_mapper): for d in ren_mapper: # module mod = '_'.join(webnotes.conn.sql("select module from `tabDocType Mapper` where name = %s", ren_mapper[d])[0][0].lower().split()) path = 'erpnext/' + mod + '/DocType Mapper/' # rename old dir esc = make_esc('$ ') os.system('git mv ' + esc(path + d) + ' ' + esc(path + ren_mapper[d])) print 'git mv ' + esc(path + d) + ' ' + esc(path + ren_mapper[d]) os.system('git mv ' + esc(path + ren_mapper[d] + '/'+ d + '.txt') + ' ' + esc(path + ren_mapper[d] + '/' + ren_mapper[d] + '.txt')) print 'git mv ' + esc(path + ren_mapper[d] + '/'+ d + '.txt') + ' ' + esc(path + ren_mapper[d] + '/' + ren_mapper[d] + '.txt')
def bifurcate_based_on_type(self, doctype_name, total, av_dis, based_on, doc_obj, val, company): add_cond = '' auth_value = av_dis if val == 1: add_cond += " and system_user = '******'user']+"'" elif val == 2: add_cond += " and system_role IN %s" % ("('"+"','".join(webnotes.user.get_roles())+"')") else: add_cond += " and ifnull(system_user,'') = '' and ifnull(system_role,'') = ''" if based_on == 'Grand Total': auth_value = total elif based_on == 'Customerwise Discount': if doc_obj: if doc_obj.doc.doctype == 'Sales Invoice': customer = doc_obj.doc.customer else: customer = doc_obj.doc.customer_name add_cond = " and master_name = '"+make_esc("'")(cstr(customer))+"'" if based_on == 'Itemwise Discount': if doc_obj: for t in getlist(doc_obj.doclist, doc_obj.fname): self.validate_auth_rule(doctype_name, t.adj_rate, based_on, add_cond, company,t.item_code ) else: self.validate_auth_rule(doctype_name, auth_value, based_on, add_cond, company)