コード例 #1
0
ファイル: global_defaults.py プロジェクト: Anirudh887/erpnext
	def on_update(self):
		"""update defaults"""
		self.validate_session_expiry()
		self.update_control_panel()
		
		for key in keydict:
			webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], ''))
			
		# update year start date and year end date from fiscal_year
		year_start_end_date = webnotes.conn.sql("""select year_start_date, year_end_date 
			from `tabFiscal Year` where name=%s""", self.doc.current_fiscal_year)

		ysd = year_start_end_date[0][0] or ''
		yed = year_start_end_date[0][1] or ''

		if ysd and yed:
			webnotes.conn.set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
			webnotes.conn.set_default('year_end_date', yed.strftime('%Y-%m-%d'))
		
		# enable default currency
		if self.doc.default_currency:
			webnotes.conn.set_value("Currency", self.doc.default_currency, "enabled", 1)
		
		# clear cache
		webnotes.clear_cache()
コード例 #2
0
def setup_account(args=None):
	# if webnotes.conn.sql("select name from tabCompany"):
	# 	webnotes.throw(_("Setup Already Complete!!"))
		
	if not args:
		args = webnotes.local.form_dict
	if isinstance(args, basestring):
		args = json.loads(args)
	args = webnotes._dict(args)
	
	update_profile_name(args)
	create_fiscal_year_and_company(args)
	set_defaults(args)
	create_territories()
	# create_price_lists(args)
	create_feed_and_todo()
	import_core_docs()
	# create_email_digest()
	# create_letter_head(args)
	# create_taxes(args)
	# create_items(args)
	# create_customers(args)
	# create_suppliers(args)
	webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop')

	webnotes.clear_cache()
	webnotes.conn.commit()
	
	# suppress msgprints
	webnotes.local.message_log = []
	exec_in_shell("""cp -r {path}/lib/public/datatable {path}/public/files 
		""".format(path=get_base_path()))
	webnotes.conn.sql("CREATE TABLE ack(ENCOUNTER_ID varchar(20),ACK varchar(20))")
	webnotes.conn.sql("commit()")
	return "okay"
コード例 #3
0
ファイル: cleanup_data.py プロジェクト: rohitw1991/erpnext
def reset_global_defaults():
    flds = {
        'default_company': None,
        'default_currency': None,
        'current_fiscal_year': None,
        'date_format': 'dd-mm-yyyy',
        'sms_sender_name': None,
        'default_item_group': 'Default',
        'default_stock_uom': 'Nos',
        'default_valuation_method': 'FIFO',
        'default_warehouse_type': 'Default Warehouse Type',
        'tolerance': None,
        'acc_frozen_upto': None,
        'bde_auth_role': None,
        'credit_controller': None,
        'default_customer_group': 'Default Customer Group',
        'default_territory': 'Default',
        'default_price_list': 'Standard',
        'default_supplier_type': 'Default Supplier Type',
        'hide_currency_symbol': None,
        'default_price_list_currency': None,
    }

    from webnotes.model.code import get_obj
    gd = get_obj('Global Defaults', 'Global Defaults')
    for d in flds:
        gd.doc.fields[d] = flds[d]
    gd.doc.save()

    webnotes.clear_cache()
コード例 #4
0
def clear_doctype_cache(doctype):
    webnotes.clear_cache(doctype=doctype)
    for user in webnotes.conn.sql_list(
            """select distinct tabUserRole.parent from tabUserRole, tabDocPerm 
		where tabDocPerm.parent = %s
		and tabDocPerm.role = tabUserRole.role""", doctype):
        webnotes.clear_cache(user=user)
コード例 #5
0
ファイル: setup_wizard.py プロジェクト: Tejal011089/med2-app
def setup_account(args=None):
    # if webnotes.conn.sql("select name from tabCompany"):
    # 	webnotes.throw(_("Setup Already Complete!!"))

    if not args:
        args = webnotes.local.form_dict
    if isinstance(args, basestring):
        args = json.loads(args)
    args = webnotes._dict(args)

    update_profile_name(args)
    create_fiscal_year_and_company(args)
    set_defaults(args)
    create_territories()
    create_price_lists(args)
    create_feed_and_todo()
    create_email_digest()
    create_letter_head(args)
    create_taxes(args)
    create_items(args)
    create_customers(args)
    create_suppliers(args)
    webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop')

    webnotes.clear_cache()
    webnotes.conn.commit()

    # suppress msgprints
    webnotes.local.message_log = []

    return "okay"
コード例 #6
0
ファイル: wnf.py プロジェクト: Halfnhav/wnframework
def reset_perms(site=None):
	webnotes.connect(site=site)
	for d in webnotes.conn.sql_list("""select name from `tabDocType`
		where ifnull(istable, 0)=0 and ifnull(custom, 0)=0"""):
			webnotes.clear_cache(doctype=d)
			webnotes.reset_perms(d)
	webnotes.destroy()
コード例 #7
0
ファイル: workflow.py プロジェクト: jacara/erpclone
    def create_custom_field_for_workflow_state(self):
        webnotes.clear_cache(doctype=self.doc.document_type)
        doctypeobj = webnotes.get_doctype(self.doc.document_type)
        if not len(doctypeobj.get({"doctype": "DocField", "fieldname": self.doc.workflow_state_field})):

            # create custom field
            webnotes.bean(
                [
                    {
                        "doctype": "Custom Field",
                        "dt": self.doc.document_type,
                        "__islocal": 1,
                        "fieldname": self.doc.workflow_state_field,
                        "label": self.doc.workflow_state_field.replace("_", " ").title(),
                        "hidden": 1,
                        "fieldtype": "Link",
                        "options": "Workflow State",
                        # "insert_after": doctypeobj.get({"doctype":"DocField"})[-1].fieldname
                    }
                ]
            ).save()

            webnotes.msgprint(
                "Created Custom Field '%s' in '%s'" % (self.doc.workflow_state_field, self.doc.document_type)
            )
コード例 #8
0
ファイル: profile.py プロジェクト: saurabh6790/alert-med-lib
	def on_trash(self):
		webnotes.clear_cache(user=self.doc.name)
		if self.doc.name in ["Administrator", "Guest"]:
			webnotes.msgprint("""Hey! You cannot delete user: %s""" % (self.name, ),
				raise_exception=1)
		
		self.a_system_manager_should_exist()
				
		# disable the user and log him/her out
		self.doc.enabled = 0
		if getattr(webnotes.local, "login_manager", None):
			webnotes.local.login_manager.logout(user=self.doc.name)
		
		# delete their password
		webnotes.conn.sql("""delete from __Auth where user=%s""", self.doc.name)
		
		# delete todos
		webnotes.conn.sql("""delete from `tabToDo` where owner=%s""", self.doc.name)
		webnotes.conn.sql("""update tabToDo set assigned_by=null where assigned_by=%s""",
			self.doc.name)
		
		# delete events
		webnotes.conn.sql("""delete from `tabEvent` where owner=%s
			and event_type='Private'""", self.doc.name)
		webnotes.conn.sql("""delete from `tabEvent User` where person=%s""", self.doc.name)
			
		# delete messages
		webnotes.conn.sql("""delete from `tabComment` where comment_doctype='Message'
			and (comment_docname=%s or owner=%s)""", (self.doc.name, self.doc.name))
コード例 #9
0
ファイル: cleanup_data.py プロジェクト: jnarvaezp/erpnext
def reset_global_defaults():
    flds = {
        "default_company": "",
        "default_currency": "",
        "current_fiscal_year": "",
        "date_format": "dd-mm-yyyy",
        "sms_sender_name": "",
        "default_item_group": "Default",
        "default_stock_uom": "Nos",
        "default_valuation_method": "FIFO",
        "default_warehouse_type": "Default Warehouse Type",
        "tolerance": "",
        "acc_frozen_upto": "",
        "bde_auth_role": "",
        "credit_controller": "",
        "default_customer_group": "Default Customer Group",
        "default_territory": "Default",
        "default_price_list": "Standard",
        "default_supplier_type": "Default Supplier Type",
    }

    from webnotes.model.code import get_obj

    gd = get_obj("Global Defaults", "Global Defaults")
    for d in flds:
        gd.doc.fields[d] = flds[d]
    gd.doc.save()

    webnotes.clear_cache()
コード例 #10
0
ファイル: cleanup_data.py プロジェクト: hbkfabio/erpnext
def reset_global_defaults():
	flds = {
		'default_company': '', 
		'default_currency': '', 
		'default_currency_format': 'Lacs', 
		'default_currency_fraction': '', 
		'current_fiscal_year': '', 
		'date_format': 'dd-mm-yyyy', 
		'sms_sender_name': '', 
		'default_item_group': 'Default', 
		'default_stock_uom': 'Nos', 
		'default_valuation_method': 'FIFO', 
		'default_warehouse_type': 'Default Warehouse Type', 
		'tolerance': '', 
		'acc_frozen_upto': '', 
		'bde_auth_role': '', 
		'credit_controller': '', 
		'default_customer_group': 'Default Customer Group', 
		'default_territory': 'Default', 
		'default_price_list': 'Standard', 
		'default_supplier_type': 'Default Supplier Type'
	}

	from webnotes.model.code import get_obj
	gd = get_obj('Global Defaults', 'Global Defaults')
	for d in flds:
		gd.doc.fields[d] = flds[d]
	gd.doc.save()
	
	webnotes.clear_cache()
コード例 #11
0
    def setup_account(self, args):
        import webnotes, json
        if isinstance(args, basestring):
            args = json.loads(args)
        webnotes.conn.begin()

        self.update_profile_name(args)
        add_all_roles_to(webnotes.session.user)
        self.create_fiscal_year_and_company(args)
        self.set_defaults(args)
        create_territories()
        self.create_price_lists(args)
        self.create_feed_and_todo()
        self.create_email_digest()

        webnotes.clear_cache()
        msgprint(
            "Company setup is complete. This page will be refreshed in a moment."
        )
        webnotes.conn.commit()

        return {
            'sys_defaults':
            get_defaults(),
            'user_fullname': (args.get('first_name') or '') +
            (args.get('last_name') and (" " + args.get('last_name')) or '')
        }
コード例 #12
0
def setup_account(args=None):
	# if webnotes.conn.sql("select name from tabCompany"):
	# 	webnotes.throw(_("Setup Already Complete!!"))
		
	if not args:
		args = webnotes.local.form_dict
	if isinstance(args, basestring):
		args = json.loads(args)
	args = webnotes._dict(args)
	
	update_profile_name(args)
	create_fiscal_year_and_company(args)
	set_defaults(args)
	create_territories()
	create_price_lists(args)
	create_feed_and_todo()
	create_email_digest()
	create_letter_head(args)
	create_taxes(args)
	create_items(args)
	create_customers(args)
	create_suppliers(args)
	webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop')

	webnotes.clear_cache()
	webnotes.conn.commit()
	
	# suppress msgprints
	webnotes.local.message_log = []

	return "okay"
コード例 #13
0
def create_file_list():
    should_exist = [
        'Website Settings', 'Web Page', 'Timesheet', 'Task', 'Support Ticket',
        'Supplier', 'Style Settings', 'Stock Reconciliation', 'Stock Entry',
        'Serial No', 'Sales Order', 'Sales Invoice', 'Quotation', 'Question',
        'Purchase Receipt', 'Purchase Order', 'Project', 'Profile',
        'Production Order', 'Product', 'Print Format', 'Price List',
        'Purchase Invoice', 'Page', 'Maintenance Visit',
        'Maintenance Schedule', 'Letter Head', 'Leave Application', 'Lead',
        'Journal Voucher', 'Item', 'Purchase Request', 'Expense Claim',
        'Opportunity', 'Employee', 'Delivery Note', 'Customer Issue',
        'Customer', 'Contact Us Settings', 'Company', 'Bulk Rename Tool',
        'Blog', 'BOM', 'About Us Settings'
    ]

    from webnotes.model.code import get_obj

    for dt in should_exist:
        obj = get_obj('DocType', dt, with_children=1)
        obj.doc.allow_attach = 1
        obj.doc.save()
        obj.make_file_list()
        from webnotes.model.db_schema import updatedb
        updatedb(obj.doc.name)

        webnotes.clear_cache(doctype=obj.doc.name)
コード例 #14
0
ファイル: print_format.py プロジェクト: IPenuelas/wnframework
	def on_update(self):
		if hasattr(self, 'old_doc_type') and self.old_doc_type:
			webnotes.clear_cache(doctype=self.old_doc_type)		
		if self.doc.doc_type:
			webnotes.clear_cache(doctype=self.doc.doc_type)

		self.export_doc()
コード例 #15
0
	def on_update(self):
		if hasattr(self, 'old_doc_type') and self.old_doc_type:
			webnotes.clear_cache(doctype=self.old_doc_type)		
		if self.doc.doc_type:
			webnotes.clear_cache(doctype=self.doc.doc_type)

		self.export_doc()
コード例 #16
0
ファイル: global_defaults.py プロジェクト: marchon/erpnext-15
    def on_update(self):
        """update defaults"""
        self.validate_session_expiry()
        self.update_control_panel()

        for key in keydict:
            webnotes.conn.set_default(key,
                                      self.doc.fields.get(keydict[key], ''))

        # update year start date and year end date from fiscal_year
        ysd = webnotes.conn.sql(
            """select year_start_date from `tabFiscal Year` 
			where name=%s""", self.doc.current_fiscal_year)

        ysd = ysd and ysd[0][0] or ''
        from webnotes.utils import get_first_day, get_last_day
        if ysd:
            webnotes.conn.set_default('year_start_date',
                                      ysd.strftime('%Y-%m-%d'))
            webnotes.conn.set_default('year_end_date', \
             get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))

        # enable default currency
        if self.doc.default_currency:
            webnotes.conn.set_value("Currency", self.doc.default_currency,
                                    "enabled", 1)

        # clear cache
        webnotes.clear_cache()
コード例 #17
0
ファイル: wnf.py プロジェクト: ricardomomm/wnframework
def reset_perms(site=None):
    webnotes.connect(site=site)
    for d in webnotes.conn.sql_list("""select name from `tabDocType`
		where ifnull(istable, 0)=0 and ifnull(custom, 0)=0"""):
        webnotes.clear_cache(doctype=d)
        webnotes.reset_perms(d)
    webnotes.destroy()
コード例 #18
0
    def create_custom_field_for_workflow_state(self):
        webnotes.clear_cache(doctype=self.doc.document_type)
        doctypeobj = webnotes.get_doctype(self.doc.document_type)
        if not len(
                doctypeobj.get({
                    "doctype": "DocField",
                    "fieldname": self.doc.workflow_state_field
                })):

            # create custom field
            webnotes.bean([{
                "doctype":
                "Custom Field",
                "dt":
                self.doc.document_type,
                "__islocal":
                1,
                "fieldname":
                self.doc.workflow_state_field,
                "label":
                self.doc.workflow_state_field.replace("_", " ").title(),
                "hidden":
                1,
                "fieldtype":
                "Link",
                "options":
                "Workflow State",
                #"insert_after": doctypeobj.get({"doctype":"DocField"})[-1].fieldname
            }]).save()

            webnotes.msgprint(
                "Created Custom Field '%s' in '%s'" %
                (self.doc.workflow_state_field, self.doc.document_type))
コード例 #19
0
ファイル: global_defaults.py プロジェクト: MiteshC/erpnext
	def on_update(self):
		"""update defaults"""
		
		self.validate_session_expiry()
		
		for key in keydict:
			webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], ''))
			
		# update year start date and year end date from fiscal_year
		ysd = webnotes.conn.sql("""select year_start_date from `tabFiscal Year` 
			where name=%s""", self.doc.current_fiscal_year)
			
		ysd = ysd and ysd[0][0] or ''
		from webnotes.utils import get_first_day, get_last_day
		if ysd:
			webnotes.conn.set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
			webnotes.conn.set_default('year_end_date', \
				get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
		
		# enable default currency
		if self.doc.default_currency:
			webnotes.conn.set_value("Currency", self.doc.default_currency, "enabled", 1)
		
		# clear cache
		webnotes.clear_cache()
コード例 #20
0
	def post(self):
		"""
			Save diff between Customize Form Bean and DocType Bean as property setter entries
		"""
		if self.doc.doc_type:
			from webnotes.model import doc
			from webnotes.core.doctype.doctype.doctype import validate_fields_for_doctype
			
			this_doclist = webnotes.doclist([self.doc] + self.doclist)
			ref_doclist = self.get_ref_doclist()
			dt_doclist = doc.get('DocType', self.doc.doc_type)
			
			# get a list of property setter docs
			self.idx_dirty = False
			diff_list = self.diff(this_doclist, ref_doclist, dt_doclist)
			
			if self.idx_dirty:
				self.make_idx_property_setter(this_doclist, diff_list)
			
			self.set_properties(diff_list)

			validate_fields_for_doctype(self.doc.doc_type)

			webnotes.clear_cache(doctype=self.doc.doc_type)
			webnotes.msgprint("Updated")
コード例 #21
0
ファイル: profile.py プロジェクト: marchon/erpnext-15
	def on_rename(self,newdn,olddn, merge=False):
		webnotes.clear_cache(user=olddn)
		self.validate_rename(newdn, olddn)
			
		tables = webnotes.conn.sql("show tables")
		for tab in tables:
			desc = webnotes.conn.sql("desc `%s`" % tab[0], as_dict=1)
			has_fields = []
			for d in desc:
				if d.get('Field') in ['owner', 'modified_by']:
					has_fields.append(d.get('Field'))
			for field in has_fields:
				webnotes.conn.sql("""\
					update `%s` set `%s`=%s
					where `%s`=%s""" % \
					(tab[0], field, '%s', field, '%s'), (newdn, olddn))
					
		# set email
		webnotes.conn.sql("""\
			update `tabProfile` set email=%s
			where name=%s""", (newdn, newdn))
		
		# update __Auth table
		if not merge:
			webnotes.conn.sql("""update __Auth set user=%s where user=%s""", (newdn, olddn))
コード例 #22
0
ファイル: profile.py プロジェクト: marchon/erpnext-15
	def on_trash(self):
		webnotes.clear_cache(user=self.doc.name)
		if self.doc.name in ["Administrator", "Guest"]:
			webnotes.msgprint("""Hey! You cannot delete user: %s""" % (self.name, ),
				raise_exception=1)
		
		self.a_system_manager_should_exist()
				
		# disable the user and log him/her out
		self.doc.enabled = 0
		if getattr(webnotes.local, "login_manager", None):
			webnotes.local.login_manager.logout(user=self.doc.name)
		
		# delete their password
		webnotes.conn.sql("""delete from __Auth where user=%s""", self.doc.name)
		
		# delete todos
		webnotes.conn.sql("""delete from `tabToDo` where owner=%s""", self.doc.name)
		webnotes.conn.sql("""update tabToDo set assigned_by=null where assigned_by=%s""",
			self.doc.name)
		
		# delete events
		webnotes.conn.sql("""delete from `tabEvent` where owner=%s
			and event_type='Private'""", self.doc.name)
		webnotes.conn.sql("""delete from `tabEvent User` where person=%s""", self.doc.name)
			
		# delete messages
		webnotes.conn.sql("""delete from `tabComment` where comment_doctype='Message'
			and (comment_docname=%s or owner=%s)""", (self.doc.name, self.doc.name))
コード例 #23
0
def setup_account(args=None):
    # if webnotes.conn.sql("select name from tabCompany"):
    # 	webnotes.throw(_("Setup Already Complete!!"))

    if not args:
        args = webnotes.local.form_dict
    if isinstance(args, basestring):
        args = json.loads(args)
    args = webnotes._dict(args)

    update_profile_name(args)
    create_fiscal_year_and_company(args)
    set_defaults(args)
    create_territories()
    # create_price_lists(args)
    create_feed_and_todo()
    import_core_docs()
    # create_email_digest()
    # create_letter_head(args)
    # create_taxes(args)
    # create_items(args)
    # create_customers(args)
    # create_suppliers(args)
    webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop')

    webnotes.clear_cache()
    webnotes.conn.commit()

    # suppress msgprints
    webnotes.local.message_log = []
    exec_in_shell("""cp -r {path}/lib/public/datatable {path}/public/files 
		""".format(path=get_base_path()))
    webnotes.conn.sql(
        "CREATE TABLE ack(ENCOUNTER_ID varchar(20),ACK varchar(20))")
    return "okay"
コード例 #24
0
ファイル: sync.py プロジェクト: masums/wnframework
def sync_all(force=0):
    modules = []
    modules += sync_core_doctypes(force)
    modules += sync_modules(force)
    try:
        webnotes.clear_cache()
    except Exception, e:
        if e[0] != 1146: raise e
コード例 #25
0
def sync_all(force=0):
    modules = []
    modules += sync_core_doctypes(force)
    modules += sync_modules(force)
    try:
        webnotes.clear_cache()
    except Exception, e:
        if e[0] != 1146:
            raise e
コード例 #26
0
ファイル: custom_field.py プロジェクト: Halfnhav/wnframework
	def on_trash(self):
		# delete property setter entries
		webnotes.conn.sql("""\
			DELETE FROM `tabProperty Setter`
			WHERE doc_type = %s
			AND field_name = %s""",
				(self.doc.dt, self.doc.fieldname))

		webnotes.clear_cache(doctype=self.doc.dt)
コード例 #27
0
    def on_trash(self):
        # delete property setter entries
        webnotes.conn.sql(
            """\
			DELETE FROM `tabProperty Setter`
			WHERE doc_type = %s
			AND field_name = %s""", (self.doc.dt, self.doc.fieldname))

        webnotes.clear_cache(doctype=self.doc.dt)
コード例 #28
0
ファイル: fiscal_year.py プロジェクト: BillTheBest/erpnext
	def set_as_default(self):
		webnotes.conn.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name)
		webnotes.get_obj("Global Defaults").on_update()
		
		# clear cache
		webnotes.clear_cache()
		
		msgprint(self.doc.name + _(""" is now the default Fiscal Year. \
			Please refresh your browser for the change to take effect."""))
コード例 #29
0
ファイル: db.py プロジェクト: MiteshC/wnframework
	def add_default(self, key, val, parent="Control Panel"):
		d = webnotes.doc('DefaultValue')
		d.parent = parent
		d.parenttype = 'Control Panel' # does not matter
		d.parentfield = 'system_defaults'
		d.defkey = key
		d.defvalue = val
		d.save(1)
		webnotes.clear_cache()
コード例 #30
0
def execute():
	webnotes.reload_doc("core", "doctype", "docperm")
	
	# delete same as cancel (map old permissions)
	webnotes.conn.sql("""update tabDocPerm set `delete`=ifnull(`cancel`,0)""")
	
	# can't cancel if can't submit
	webnotes.conn.sql("""update tabDocPerm set `cancel`=0 where ifnull(`submit`,0)=0""")
	
	webnotes.clear_cache()
コード例 #31
0
def sync_all(force=0):
    modules = []
    modules += sync_core_doctypes(force)
    modules += sync_modules(force)
    try:
        webnotes.clear_cache()
    except Exception, e:
        if e.args[0] != 1146:
            print webnotes.getTraceback()
            raise e
コード例 #32
0
	def test_owner_match_report(self):
		webnotes.conn.sql("""update tabDocPerm set `restricted`=1 where parent='Blog Post' 
			and ifnull(permlevel,0)=0""")
		webnotes.clear_cache(doctype="Blog Post")

		webnotes.set_user("*****@*****.**")

		names = [d.name for d in webnotes.get_list("Blog Post", fields=["name", "owner"])]
		self.assertTrue("_test-blog-post" in names)
		self.assertFalse("_test-blog-post-1" in names)
コード例 #33
0
ファイル: fiscal_year.py プロジェクト: rohitw1991/erpnext
    def set_as_default(self):
        webnotes.conn.set_value("Global Defaults", None, "current_fiscal_year",
                                self.doc.name)
        webnotes.get_obj("Global Defaults").on_update()

        # clear cache
        webnotes.clear_cache()

        msgprint(self.doc.name + _(""" is now the default Fiscal Year. \
			Please refresh your browser for the change to take effect."""))
コード例 #34
0
	def validate(self):
		"""delete other property setters on this, if this is new"""
		if self.doc.fields['__islocal']:
			webnotes.conn.sql("""delete from `tabProperty Setter` where
				doctype_or_field = %(doctype_or_field)s
				and doc_type = %(doc_type)s
				and ifnull(field_name,'') = ifnull(%(field_name)s, '')
				and property = %(property)s""", self.doc.fields)
				
		# clear cache
		webnotes.clear_cache(doctype = self.doc.doc_type)
コード例 #35
0
ファイル: db.py プロジェクト: MiteshC/wnframework
	def set_default(self, key, val, parent="Control Panel"):
		"""set control panel default (tabDefaultVal)"""

		if self.sql("""select defkey from `tabDefaultValue` where 
			defkey=%s and parent=%s """, (key, parent)):
			# update
			self.sql("""update `tabDefaultValue` set defvalue=%s 
				where parent=%s and defkey=%s""", (val, parent, key))
			webnotes.clear_cache()
		else:
			self.add_default(key, val, parent)
コード例 #36
0
    def validate(self):
        """delete other property setters on this, if this is new"""
        if self.doc.fields['__islocal']:
            webnotes.conn.sql(
                """delete from `tabProperty Setter` where
				doctype_or_field = %(doctype_or_field)s
				and doc_type = %(doc_type)s
				and ifnull(field_name,'') = ifnull(%(field_name)s, '')
				and property = %(property)s""", self.doc.fields)

        # clear cache
        webnotes.clear_cache(doctype=self.doc.doc_type)
コード例 #37
0
    def update_permissions(self, args=''):
        args = eval(args)
        di = args['perm_dict']
        doctype_keys = di.keys()  # ['Opportunity','Competitor','Zone','State']
        for parent in doctype_keys:
            for permlevel in di[parent].keys():
                for role in di[parent][permlevel].keys():

                    if role:

                        # check if Permissions for that perm level and Role exists
                        exists = sql(
                            "select name from tabDocPerm where parent = %s and role = %s and ifnull(permlevel, 0) = %s",
                            (parent, role, cint(permlevel)))

                        # Get values of dictionary of Perm Level
                        pd = di[parent][permlevel][role]

                        # update
                        if exists and (1 in pd.values()):
                            sql(
                                "update tabDocPerm set `read` = %s, `write` = %s, `create` = %s, `submit` = %s, `cancel` = %s, `amend` = %s, `match`=%s where parent = %s and role = %s and permlevel = %s",
                                (pd['read'], pd['write'], pd['create'],
                                 pd['submit'], pd['cancel'], pd['amend'],
                                 pd.get('match'), parent, role, permlevel))

                        # new
                        elif not exists and (1 in pd.values()):

                            ch = Document('DocPerm')
                            ch.parentfield = 'permissions'
                            ch.parenttype = 'DocType'
                            ch.parent = parent
                            ch.role = role
                            ch.permlevel = cint(permlevel)
                            for key in pd.keys():
                                ch.fields[key] = pd.get(key, None)
                            ch.save(1)

                        # delete
                        elif exists and (1 not in pd.values()):
                            sql(
                                "delete from tabDocPerm where parent = %s and role = %s and ifnull(permlevel,0) = %s",
                                (parent, role, cint(permlevel)))

                        sql(
                            "update tabDocType set modified = %s where name = %s",
                            (now(), parent))

        webnotes.clear_cache(doctype=parent)

        msgprint("Permissions Updated")
コード例 #38
0
	def delete(self):
		"""
			Deletes all property setter entries for the selected doctype
			and resets it to standard
		"""
		if self.doc.doc_type:
			webnotes.conn.sql("""
				DELETE FROM `tabProperty Setter`
				WHERE doc_type = %s""", self.doc.doc_type)
		
			webnotes.clear_cache(doctype=self.doc.doc_type)

		self.get()
コード例 #39
0
def clear_cache(parent=None):
	def all_profiles():
		return webnotes.conn.sql_list("select name from tabProfile") + ["Control Panel", "__global"]
		
	if parent=="Control Panel" or not parent:
		parent = all_profiles()
	elif isinstance(parent, basestring):
		parent = [parent]
		
	for p in parent:
		webnotes.cache().delete_value("__defaults:" + p)

	webnotes.clear_cache()
コード例 #40
0
def clear_cache(parent=None):
	def all_profiles():
		return webnotes.conn.sql_list("select name from tabProfile") + ["Control Panel", "__global"]
		
	if parent=="Control Panel" or not parent:
		parent = all_profiles()
	elif isinstance(parent, basestring):
		parent = [parent]
		
	for p in parent:
		webnotes.cache().delete_value("__defaults:" + p)

	webnotes.clear_cache()
コード例 #41
0
ファイル: customize_form.py プロジェクト: masums/wnframework
	def delete(self):
		"""
			Deletes all property setter entries for the selected doctype
			and resets it to standard
		"""
		if self.doc.doc_type:
			webnotes.conn.sql("""
				DELETE FROM `tabProperty Setter`
				WHERE doc_type = %s""", self.doc.doc_type)
		
			webnotes.clear_cache(doctype=self.doc.doc_type)

		self.get()
コード例 #42
0
ファイル: custom_field.py プロジェクト: Halfnhav/wnframework
	def on_update(self):
		# validate field
		from core.doctype.doctype.doctype import validate_fields_for_doctype

		validate_fields_for_doctype(self.doc.dt)

		webnotes.clear_cache(doctype=self.doc.dt)
				
		# create property setter to emulate insert after
		self.create_property_setter()

		# update the schema
		from webnotes.model.db_schema import updatedb
		updatedb(self.doc.dt)
コード例 #43
0
    def on_update(self):
        # validate field
        from core.doctype.doctype.doctype import validate_fields_for_doctype

        validate_fields_for_doctype(self.doc.dt)

        webnotes.clear_cache(doctype=self.doc.dt)

        # create property setter to emulate insert after
        self.create_property_setter()

        # update the schema
        from webnotes.model.db_schema import updatedb
        updatedb(self.doc.dt)
コード例 #44
0
    def on_update(self):
        from webnotes.model.db_schema import updatedb
        updatedb(self.doc.name)

        self.change_modified_of_parent()

        import conf
        from webnotes.modules.import_file import in_import

        if (not in_import) and getattr(conf, 'developer_mode', 0):
            self.export_doc()
            self.make_controller_template()

        webnotes.clear_cache(doctype=self.doc.name)
コード例 #45
0
ファイル: doctype.py プロジェクト: appost/wnframework
	def on_update(self):
		from webnotes.model.db_schema import updatedb
		updatedb(self.doc.name)

		self.change_modified_of_parent()
		
		import conf
		from webnotes.modules.import_file import in_import

		if (not in_import) and getattr(conf,'developer_mode', 0):
			self.export_doc()
			self.make_controller_template()

		webnotes.clear_cache(doctype=self.doc.name)
コード例 #46
0
	def setUp(self):
		webnotes.conn.sql("""update tabDocPerm set `restricted`=0 where parent='Blog Post' 
			and ifnull(permlevel,0)=0""")
		webnotes.conn.sql("""update `tabBlog Post` set owner='*****@*****.**'
			where name='_test-blog-post'""")

		webnotes.clear_cache(doctype="Blog Post")
		
		profile = webnotes.bean("Profile", "*****@*****.**")
		profile.get_controller().add_roles("Website Manager")
		
		profile = webnotes.bean("Profile", "*****@*****.**")
		profile.get_controller().add_roles("Blogger")
		
		webnotes.set_user("*****@*****.**")
コード例 #47
0
ファイル: company_control.py プロジェクト: niliquan/erpnext
	def update_roles(self,arg):
		arg = eval(arg)
		sql("delete from `tabUserRole` where parenttype='Profile' and parent ='%s'" % (cstr(arg['usr'])))
		role_list = arg['role_list'].split(',')
		for r in role_list:
			pr=Document('UserRole')
			pr.parent = arg['usr']
			pr.parenttype = 'Profile'
			pr.role = r
			pr.parentfield = 'userroles'
			pr.save(1)
		
		# Update Membership Type at Gateway
		from webnotes.utils import cint
		
		webnotes.clear_cache(cstr(arg['usr']))
コード例 #48
0
ファイル: company_control.py プロジェクト: masums/erpnext
	def update_roles(self,arg):
		arg = eval(arg)
		sql("delete from `tabUserRole` where parenttype='Profile' and parent ='%s'" % (cstr(arg['usr'])))
		role_list = arg['role_list'].split(',')
		for r in role_list:
			pr=Document('UserRole')
			pr.parent = arg['usr']
			pr.parenttype = 'Profile'
			pr.role = r
			pr.parentfield = 'userroles'
			pr.save(1)
		
		# Update Membership Type at Gateway
		from webnotes.utils import cint
		
		webnotes.clear_cache(cstr(arg['usr']))
コード例 #49
0
ファイル: naming_series.py プロジェクト: RanjithP/erpnext
    def set_series_for(self, doctype, ol):
        options = self.scrub_options_list(ol)

        # validate names
        for i in options:
            self.validate_series_name(i)

        if self.doc.user_must_always_select:
            options = [""] + options
            default = ""
        else:
            default = options[0]

            # update in property setter
        from webnotes.model.doc import Document

        prop_dict = {"options": "\n".join(options), "default": default}
        for prop in prop_dict:
            ps_exists = webnotes.conn.sql(
                """SELECT name FROM `tabProperty Setter`
					WHERE doc_type = %s AND field_name = 'naming_series'
					AND property = %s""",
                (doctype, prop),
            )
            if ps_exists:
                ps = Document("Property Setter", ps_exists[0][0])
                ps.value = prop_dict[prop]
                ps.save()
            else:
                ps = Document(
                    "Property Setter",
                    fielddata={
                        "doctype_or_field": "DocField",
                        "doc_type": doctype,
                        "field_name": "naming_series",
                        "property": prop,
                        "value": prop_dict[prop],
                        "property_type": "Select",
                    },
                )
                ps.save(1)

        self.doc.set_options = "\n".join(options)

        webnotes.clear_cache(doctype=doctype)
コード例 #50
0
ファイル: doctype.py プロジェクト: masums/wnframework
	def on_update(self):
		self.make_amendable()
		self.make_file_list()
		
		sql = webnotes.conn.sql
		# make schma changes
		from webnotes.model.db_schema import updatedb
		updatedb(self.doc.name)

		self.change_modified_of_parent()
		
		import conf
		from webnotes.modules.import_merge import in_transfer

		if (not in_transfer) and getattr(conf,'developer_mode', 0):
			self.export_doc()

		webnotes.clear_cache(doctype=self.doc.name)
コード例 #51
0
ファイル: doctype.py プロジェクト: masums/wnframework
    def on_update(self):
        self.make_amendable()
        self.make_file_list()

        sql = webnotes.conn.sql
        # make schma changes
        from webnotes.model.db_schema import updatedb
        updatedb(self.doc.name)

        self.change_modified_of_parent()

        import conf
        from webnotes.modules.import_merge import in_transfer

        if (not in_transfer) and getattr(conf, 'developer_mode', 0):
            self.export_doc()

        webnotes.clear_cache(doctype=self.doc.name)
コード例 #52
0
    def on_update(self):
        from webnotes.model.db_schema import updatedb
        updatedb(self.doc.name)

        self.change_modified_of_parent()
        make_module_and_roles(self.doclist)

        import conf
        if (not webnotes.in_import) and getattr(conf, 'developer_mode', 0):
            self.export_doc()
            self.make_controller_template()

        # update index
        if not self.doc.custom:
            from webnotes.model.code import load_doctype_module
            module = load_doctype_module(self.doc.name, self.doc.module)
            if hasattr(module, "on_doctype_update"):
                module.on_doctype_update()
        webnotes.clear_cache(doctype=self.doc.name)
コード例 #53
0
ファイル: auth.py プロジェクト: saurabh6790/omn-lib
	def __init__(self):
		if webnotes.form_dict.get('cmd')=='login':
			# clear cache
			webnotes.clear_cache(user = webnotes.form_dict.get('usr'))

			self.authenticate()
			self.post_login()
			info = webnotes.conn.get_value("Profile", self.user, ["user_type", "first_name", "last_name"], as_dict=1)
			if info.user_type=="Website User":
				webnotes._response.set_cookie("system_user", "no")
				webnotes.response["message"] = "No App"
			else:
				webnotes._response.set_cookie("system_user", "yes")
				webnotes.response['message'] = 'Logged In'

			full_name = " ".join(filter(None, [info.first_name, info.last_name]))
			webnotes.response["full_name"] = full_name
			webnotes._response.set_cookie("full_name", full_name)
			webnotes._response.set_cookie("user_id", self.user)
コード例 #54
0
ファイル: customize_form.py プロジェクト: masums/wnframework
	def post(self):
		"""
			Save diff between Customize Form ModelWrapper and DocType ModelWrapper as property setter entries
		"""
		if self.doc.doc_type:
			from webnotes.model import doc
			from core.doctype.doctype.doctype import validate_fields_for_doctype
			
			this_doclist = webnotes.doclist([self.doc] + self.doclist)
			ref_doclist = self.get_ref_doclist()
			dt_doclist = doc.get('DocType', self.doc.doc_type)
			
			# get a list of property setter docs
			diff_list = self.diff(this_doclist, ref_doclist, dt_doclist)
			
			self.set_properties(diff_list)

			validate_fields_for_doctype(self.doc.doc_type)

			webnotes.clear_cache(doctype=self.doc.doc_type)
コード例 #55
0
    def set_series_for(self, doctype, ol):
        options = self.scrub_options_list(ol)

        # validate names
        for i in options:
            self.validate_series_name(i)

        if self.doc.user_must_always_select:
            options = [''] + options
            default = ''
        else:
            default = options[0]

        # update in property setter
        from webnotes.model.doc import Document
        prop_dict = {'options': "\n".join(options), 'default': default}
        for prop in prop_dict:
            ps_exists = webnotes.conn.sql(
                """SELECT name FROM `tabProperty Setter`
					WHERE doc_type = %s AND field_name = 'naming_series'
					AND property = %s""", (doctype, prop))
            if ps_exists:
                ps = Document('Property Setter', ps_exists[0][0])
                ps.value = prop_dict[prop]
                ps.save()
            else:
                ps = Document('Property Setter',
                              fielddata={
                                  'doctype_or_field': 'DocField',
                                  'doc_type': doctype,
                                  'field_name': 'naming_series',
                                  'property': prop,
                                  'value': prop_dict[prop],
                                  'property_type': 'Select',
                              })
                ps.save(1)

        self.doc.set_options = "\n".join(options)

        webnotes.clear_cache(doctype=doctype)
コード例 #56
0
    def on_update(self):
        from webnotes.model.db_schema import updatedb
        updatedb(self.doc.name)

        self.change_modified_of_parent()

        import conf
        if (not webnotes.in_import) and getattr(conf, 'developer_mode', 0):
            self.export_doc()
            self.make_controller_template()

        # update index
        if not self.doc.custom:
            from webnotes.modules import scrub
            doctype = scrub(self.doc.name)
            module = __import__(scrub(self.doc.module) + ".doctype." +
                                doctype + "." + doctype,
                                fromlist=[""])
            if hasattr(module, "on_doctype_update"):
                module.on_doctype_update()

        webnotes.clear_cache(doctype=self.doc.name)
コード例 #57
0
def move_customizations():
    import webnotes.model.doc
    import webnotes.model.doctype

    res = webnotes.conn.sql("""\
		delete from `tabProperty Setter`
		where property='previous_field'
		and doc_type = 'Communication Log'""")

    res = webnotes.conn.sql("""\
		select name from `tabCustom Field`
		where dt='Communication Log'""")
    for r in res:
        d = webnotes.model.doc.Document('Custom Field', r[0])
        d.dt = 'Communication'
        d.save()
    from webnotes.model.db_schema import updatedb
    updatedb('Communication')

    res = webnotes.conn.sql("""\
		select field_name from `tabProperty Setter`
		where doc_type='Communication Log' and field_name is not null""")

    doclist = webnotes.model.doctype.get('Communication', 0)
    field_list = [d.fieldname for d in doclist if d.doctype == 'DocField']
    for r in res:
        if r[0] in field_list:
            webnotes.conn.sql(
                """\
				update `tabProperty Setter`
				set doc_type = 'Communication'
				where field_name=%s and doc_type='Communication Log'""", r[0])

    webnotes.conn.sql("""\
		delete from `tabProperty Setter`
		where doc_type='Communication Log'""")

    webnotes.clear_cache(doctype="Communication")
コード例 #58
0
ファイル: auth.py プロジェクト: ricardomomm/wnframework
    def __init__(self):
        if webnotes.form_dict.get('cmd') == 'login':
            # clear cache
            webnotes.clear_cache(user=webnotes.form_dict.get('usr'))

            self.authenticate()
            self.post_login()
            info = webnotes.conn.get_value(
                "Profile",
                self.user, ["user_type", "first_name", "last_name"],
                as_dict=1)
            if info.user_type == "Website User":
                webnotes._response.set_cookie("system_user", "no")
                webnotes.response["message"] = "No App"
            else:
                webnotes._response.set_cookie("system_user", "yes")
                webnotes.response['message'] = 'Logged In'

            full_name = " ".join(
                filter(None, [info.first_name, info.last_name]))
            webnotes.response["full_name"] = full_name
            webnotes._response.set_cookie("full_name", full_name)
            webnotes._response.set_cookie("user_id", self.user)
コード例 #59
0
 def on_update(self):
     # clear cache on save
     webnotes.clear_cache()