mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-01 12:38:27 +00:00
Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
@@ -61,7 +61,7 @@ def dropbox_callback(oauth_token=None, not_approved=False):
|
||||
webnotes.response['page_name'] = 'message.html'
|
||||
|
||||
def backup_to_dropbox():
|
||||
from dropbox import client, session, rest
|
||||
from dropbox import client, session
|
||||
from conf import dropbox_access_key, dropbox_secret_key
|
||||
from webnotes.utils.backups import new_backup
|
||||
if not webnotes.conn:
|
||||
@@ -97,13 +97,14 @@ def get_dropbox_session():
|
||||
from dropbox import session
|
||||
try:
|
||||
from conf import dropbox_access_key, dropbox_secret_key
|
||||
except ImportError, e:
|
||||
except ImportError:
|
||||
webnotes.msgprint(_("Please set Dropbox access keys in") + " conf.py",
|
||||
raise_exception=True)
|
||||
sess = session.DropboxSession(dropbox_access_key, dropbox_secret_key, "app_folder")
|
||||
return sess
|
||||
|
||||
def upload_file_to_dropbox(filename, folder, dropbox_client):
|
||||
from dropbox import rest
|
||||
size = os.stat(filename).st_size
|
||||
f = open(filename,'r')
|
||||
if size > 4194304:
|
||||
@@ -111,11 +112,11 @@ def upload_file_to_dropbox(filename, folder, dropbox_client):
|
||||
while uploader.offset < size:
|
||||
try:
|
||||
uploader.upload_chunked()
|
||||
uploader.finish(os.path.join(folder, os.path.basename(filename)), overwrite='True')
|
||||
except rest.ErrorResponse, e:
|
||||
uploader.finish(os.path.join(folder, os.path.basename(filename)), overwrite=True)
|
||||
except rest.ErrorResponse:
|
||||
pass
|
||||
else:
|
||||
response = dropbox_client.put_file(os.path.join(folder, os.path.basename(filename)), f, overwrite=True)
|
||||
dropbox_client.put_file(os.path.join(folder, os.path.basename(filename)), f, overwrite=True)
|
||||
|
||||
if __name__=="__main__":
|
||||
backup_to_dropbox()
|
||||
@@ -11,12 +11,11 @@
|
||||
# gdrive_client_secret
|
||||
|
||||
import httplib2
|
||||
import sys
|
||||
import os
|
||||
import mimetypes
|
||||
import webnotes
|
||||
import oauth2client.client
|
||||
from webnotes.utils import get_request_site_address, get_base_path
|
||||
from webnotes.utils import get_base_path
|
||||
from webnotes import _, msgprint
|
||||
from apiclient.discovery import build
|
||||
from apiclient.http import MediaFileUpload
|
||||
@@ -53,7 +52,7 @@ def backup_to_gdrive():
|
||||
from webnotes.utils.backups import new_backup
|
||||
if not webnotes.conn:
|
||||
webnotes.connect()
|
||||
flow = get_gdrive_flow()
|
||||
get_gdrive_flow()
|
||||
credentials_json = webnotes.conn.get_value("Backup Manager", None, "gdrive_credentials")
|
||||
credentials = oauth2client.client.Credentials.new_from_json(credentials_json)
|
||||
http = httplib2.Http()
|
||||
@@ -101,11 +100,6 @@ def get_gdrive_flow():
|
||||
webnotes.msgprint(_("Please set Google Drive access keys in") + " conf.py",
|
||||
raise_exception=True)
|
||||
|
||||
#callback_url = get_request_site_address(True) \
|
||||
# + "?cmd=setup.doctype.backup_manager.backup_googledrive.googledrive_callback"
|
||||
|
||||
# for installed apps since google does not support subdomains
|
||||
|
||||
flow = OAuth2WebServerFlow(conf.gdrive_client_id, conf.gdrive_client_secret,
|
||||
"https://www.googleapis.com/auth/drive", 'urn:ietf:wg:oauth:2.0:oob')
|
||||
return flow
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
from backup_dropbox import dropbox_callback, get_dropbox_session, get_dropbox_authorize_url
|
||||
from backup_googledrive import gdrive_callback, get_gdrive_flow, get_gdrive_authorize_url
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -1,99 +1,7 @@
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import set_default
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.bean import copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def enable_login(self,arg):
|
||||
arg = eval(arg)
|
||||
sql("update tabContact set disable_login = 'No' where name=%s",arg['contact'])
|
||||
sql("update tabProfile set enabled=1 where name=%s",arg['email'])
|
||||
|
||||
def disable_login(self,arg):
|
||||
arg = eval(arg)
|
||||
sql("update tabContact set disable_login = 'Yes' where name=%s",arg['contact'])
|
||||
sql("update tabProfile set enabled=0 where name=%s",arg['email'])
|
||||
|
||||
def create_login(self,arg):
|
||||
arg = eval(arg)
|
||||
cont_det = sql("select * from tabContact where name=%s",(arg['contact']),as_dict=1)
|
||||
if cont_det[0]['docstatus'] !=0:
|
||||
msgprint('Please save the corresponding contact first')
|
||||
raise Exception
|
||||
|
||||
if sql("select name from tabProfile where name=%s",cont_det[0]['email_id']):
|
||||
msgprint('Profile with same name already exist.')
|
||||
raise Exception
|
||||
else:
|
||||
p = Document('Profile')
|
||||
p.name = cont_det[0]['email_id']
|
||||
p.first_name = cont_det[0]['first_name']
|
||||
p.last_name = cont_det[0]['last_name']
|
||||
p.email = cont_det[0]['email_id']
|
||||
p.cell_no = cont_det[0]['contact_no']
|
||||
p.password = 'password'
|
||||
p.enabled = 1
|
||||
p.user_type = 'Partner';
|
||||
p.save(1)
|
||||
|
||||
get_obj(doc=p).on_update()
|
||||
|
||||
role = []
|
||||
if cont_det[0]['contact_type'] == 'Individual':
|
||||
role = ['Customer']
|
||||
else:
|
||||
if cont_det[0]['is_customer']:
|
||||
role.append('Customer')
|
||||
if cont_det[0]['is_supplier']:
|
||||
role.append('Supplier')
|
||||
if cont_det[0]['is_sales_partner']:
|
||||
role.append('Partner')
|
||||
|
||||
if role:
|
||||
prof_nm = p.name
|
||||
for i in role:
|
||||
r = Document('UserRole')
|
||||
r.parent = p.name
|
||||
r.role = i
|
||||
r.parenttype = 'Profile'
|
||||
r.parentfield = 'userroles'
|
||||
r.save(1)
|
||||
|
||||
if i == 'Customer':
|
||||
def_keys = ['from_company','customer_name','customer']
|
||||
def_val = cont_det[0]['customer_name']
|
||||
self.set_default_val(def_keys,def_val,prof_nm)
|
||||
|
||||
if i == 'Supplier':
|
||||
def_keys = ['supplier_name','supplier']
|
||||
def_val = cont_det[0]['supplier_name']
|
||||
self.set_default_val(def_keys,def_val,prof_nm)
|
||||
|
||||
sql("update tabContact set has_login = 'Yes' where name=%s",cont_det[0]['name'])
|
||||
sql("update tabContact set disable_login = 'No' where name=%s",cont_det[0]['name'])
|
||||
msgprint('User login is created.')
|
||||
|
||||
#------set default values---------
|
||||
def set_default_val(self,def_keys,def_val,prof_nm):
|
||||
for d in def_keys:
|
||||
kv = Document('DefaultValue')
|
||||
kv.defkey = d
|
||||
kv.defvalue = def_val
|
||||
kv.parent = prof_nm
|
||||
kv.parenttype = 'Profile'
|
||||
kv.parentfield = 'defaults'
|
||||
kv.save(1)
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
@@ -21,6 +21,7 @@ import webnotes.defaults
|
||||
from webnotes.utils import cint
|
||||
|
||||
keydict = {
|
||||
"print_style": "print_style",
|
||||
"fiscal_year": "current_fiscal_year",
|
||||
'company': 'default_company',
|
||||
'currency': 'default_currency',
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-02-21 14:54:43",
|
||||
"creation": "2013-02-21 12:28:24",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-03-19 14:46:49",
|
||||
"modified": "2013-03-21 15:42:59",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -27,8 +27,6 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
@@ -59,6 +57,19 @@
|
||||
"fieldtype": "Data",
|
||||
"label": "Session Expiry"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_3",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"description": "For Server Side Print Formats",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "print_style",
|
||||
"fieldtype": "Select",
|
||||
"label": "Print Format Style",
|
||||
"options": "Standard\nClassic\nModern\nSpartan"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "company",
|
||||
@@ -424,6 +435,11 @@
|
||||
"fieldtype": "Data",
|
||||
"label": "SMS Sender Name"
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"doctype": "DocPerm"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-01-10 16:34:23",
|
||||
"creation": "2013-01-23 20:00:16",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-01-22 14:56:03",
|
||||
"modified": "2013-03-20 15:09:28",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -123,6 +123,13 @@
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Description"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_website_specifications",
|
||||
"fieldtype": "Table",
|
||||
"label": "Item Website Specifications",
|
||||
"options": "Item Website Specification"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "lft",
|
||||
@@ -174,6 +181,20 @@
|
||||
"no_copy": 1,
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "System Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Material Master Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
@@ -189,19 +210,5 @@
|
||||
"doctype": "DocPerm",
|
||||
"role": "Material User",
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "System Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Material Master Manager",
|
||||
"write": 1
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user