Skip to content

Instantly share code, notes, and snippets.

View rmehta's full-sized avatar

Rushabh Mehta rmehta

View GitHub Profile
@rmehta
rmehta / extract_system_managers.py
Created January 25, 2013 06:35
Extract System Managers from Frappe
from webnotes.utils import cstr, validate_email_add, extract_email_id
from email.utils import parseaddr
el = []
for s in webnotes.conn.sql("""select system_managers from `tabSerial No`
where status in ("Active", "Trial", "Delivered")"""):
if s and s[0]:
emails = cstr(s[0]).split("\n")
for e in emails:
name, addr = parseaddr(e)
if addr:
from webclient import *
server = "http://myaccount.erpnext.com/server.py"
user = "your user name"
password = "your password"
login()
customer = get_doc("Customer", customer_name)
cur_frm.cscript.item_prefix = function() {
// will be called on change of item_prefix
// note: it is important to specifiy tablename.fieldname
// in query as permissions are evaluated on this basis
// and sql keywords must be in CAPS
wn.call({
method: "webnotes.widgets.query_builder.runquery",
args: {
"query":"SELECT `tabItem`.name \
import webnotes, json
webnotes.connect()
source = "Quotation"
target = "Sales Order"
doclist = webnotes.bean("DocType Mapper", "Quotation-Sales Order").doclist
map_id = {}
with open("para1.txt", "r") as pfile:
ptxt = pfile.read()
with open("para1-1.txt", "r") as ufile:
utxt = ufile.read()
pwords = ptxt.split()
uwords = utxt.split()
my_map = {
# -*- coding: utf-8 -*-
my_map = {
"B": u"\u0901",
"Q": u"\u0948\u0902",
"R": u"\u0940\u0902",
"W": u"\u0902",
"b": u"\u0902",
"D": u"\u0905",
"F": u"\u0907",
शहर काr अाेर जा रही हैं। बजट काr केहनी जाता हैं, वह बंद केरकेे, सभी दजx केे याित्रयों सो केइ& जयाद हैं
त्र+<भ मोहता
इस हफ्तो हमारे िवò मंत्री श्री िचदंबरम नो 2013-14 का केंõीय बजट पोश िकेया। बजट केे बारे मैं बहुत लाेगों नो अपनी रय रखी। िवरोधी दल नो िवरोध िकेया, शासके दल नो पसंद िकेया। पर अाम जनता पर इसका क्या असर होता हैं? भारत जwसो िवशाल देश काr अL&वयवसLा एके मशीन काr तरह बहुत ही जाfटल मामला हैं। मानाे यह एके रेल गा[ी हैं, जाे तो]जी सो चल रही हैं। ऐसी रेल गा[ी मw अाप जाे बदलाव केर सकेतो हैं बस Gतना ही देश काr अL&वयवसLा मं बदलाव हो सकेता हैं।
इस अL&वयवसLा काr रेल गा[ी काे लगता हैं काr हमारे िवò मंत्री चला रहे हैं। पर यह सच नहीं हैं। इसकाे चला रहे हैं पलािनंग केमीशन केे Gपाअधय# श्री मोंटेके िसंह अहलुवािलया। िवò मंत्री ताे केेवल यह तय केरतो हैं िके काेयलो केे िलए पwसो केहB सो अायंगो? पर यह गा[ी अा केहB सो रही हैं अाwर जा केहB रही हैं?
यह गा[ी 1947 नाम केे एके गाBव सो अा रही हैं, अाwर भाfव<य केे
यह गा[ी जहB सो शु¤ हुइ&, वहं बहुत Úोटे Úोटे गाBव Lो, अाwर शहर केम Lो। जयाद लाेग गरीब Lो अाwर लाेगों केे पास सामन भी के
@rmehta
rmehta / custom_communication.py
Created September 10, 2013 17:17
Custom Script for "Communication" model
def custom_on_update(self):
parent = self.get_parent_bean()
if not parent:
return
parent.ignore_permissions = True
if parent.doc.doctype=="Lead" and parent.doc.status != "Trial Approved":
if "via demo.erpnext.com" in self.doc.content:
parent.doc.source="Demo"
def custom_validate(self):
webnotes.msgprint('I got called')
company_count = 1
if company_count >=0 :
webnotes.msgprint('Error: Test')
raise Exception
cur_frm.cscript.custom_validate = function(doc) {
var items = wn.model.get("Delivery Note Item", {parent: doc.name})
var items_against_sales_order = $.map(items, function(d) { return d.against_sales_order ? d : null })
if(items.length > items_against_sales_order.length && user_roles.indexOf(["Allowed Role"])===-1) {
wn.msgprint("Please make against sales order");
throw "Not allowed";
}
}