コード例 #1
0
	def on_update(self):
		NestedSet.on_update(self)
		if not dataent.db.sql("""select name from tabAccount
				where company=%s and docstatus<2 limit 1""", self.name):
			if not dataent.local.flags.ignore_chart_of_accounts:
				dataent.flags.country_change = True
				self.create_default_accounts()
				self.create_default_warehouses()

		if dataent.flags.country_change:
			install_country_fixtures(self.name)
			self.create_default_tax_template()



		if not dataent.db.get_value("Department", {"company": self.name}):
			from epaas.setup.setup_wizard.operations.install_fixtures import install_post_company_fixtures
			install_post_company_fixtures(dataent._dict({'company_name': self.name}))

		if not dataent.db.get_value("Cost Center", {"is_group": 0, "company": self.name}):
			self.create_default_cost_center()

		if not dataent.local.flags.ignore_chart_of_accounts:
			self.set_default_accounts()
			if self.default_cash_account:
				self.set_mode_of_payment_account()

		if self.default_currency:
			dataent.db.set_value("Currency", self.default_currency, "enabled", 1)

		if hasattr(dataent.local, 'enable_perpetual_inventory') and \
			self.name in dataent.local.enable_perpetual_inventory:
			dataent.local.enable_perpetual_inventory[self.name] = self.enable_perpetual_inventory

		dataent.clear_cache()
コード例 #2
0
    def create_custom_field_for_workflow_state(self):
        dataent.clear_cache(doctype=self.document_type)
        meta = dataent.get_meta(self.document_type)
        if not meta.get_field(self.workflow_state_field):
            # create custom field
            dataent.get_doc({
                "doctype":
                "Custom Field",
                "dt":
                self.document_type,
                "__islocal":
                1,
                "fieldname":
                self.workflow_state_field,
                "label":
                self.workflow_state_field.replace("_", " ").title(),
                "hidden":
                1,
                "allow_on_submit":
                1,
                "no_copy":
                1,
                "fieldtype":
                "Link",
                "options":
                "Workflow State",
                "owner":
                "Administrator"
            }).save()

            dataent.msgprint(
                _("Created Custom Field {0} in {1}").format(
                    self.workflow_state_field, self.document_type))
コード例 #3
0
def _reinstall(site,
               admin_password=None,
               mariadb_root_username=None,
               mariadb_root_password=None,
               yes=False,
               verbose=False):
    if not yes:
        click.confirm(
            'This will wipe your database. Are you sure you want to reinstall?',
            abort=True)
    try:
        dataent.init(site=site)
        dataent.connect()
        dataent.clear_cache()
        installed = dataent.get_installed_apps()
        dataent.clear_cache()
    except Exception:
        installed = []
    finally:
        if dataent.db:
            dataent.db.close()
        dataent.destroy()

    dataent.init(site=site)
    _new_site(dataent.conf.db_name,
              site,
              verbose=verbose,
              force=True,
              reinstall=True,
              install_apps=installed,
              mariadb_root_username=mariadb_root_username,
              mariadb_root_password=mariadb_root_password,
              admin_password=admin_password)
コード例 #4
0
ファイル: setup_data.py プロジェクト: dataent/epaas
def setup(domain):
	complete_setup(domain)
	setup_demo_page()
	setup_fiscal_year()
	setup_holiday_list()
	setup_user()
	setup_employee()
	setup_user_roles()
	setup_role_permissions()
	setup_custom_field_for_domain()

	employees = dataent.get_all('Employee',  fields=['name', 'date_of_joining'])

	# monthly salary
	setup_salary_structure(employees[:5], 0)

	# based on timesheet
	setup_salary_structure(employees[5:], 1)

	setup_leave_allocation()
	setup_customer()
	setup_supplier()
	setup_warehouse()
	import_json('Address')
	import_json('Contact')
	import_json('Lead')
	setup_currency_exchange()
	#setup_mode_of_payment()
	setup_account_to_expense_type()
	setup_budget()
	setup_pos_profile()

	dataent.db.commit()
	dataent.clear_cache()
コード例 #5
0
    def on_update(self):
        """update defaults"""
        for key in keydict:
            dataent.db.set_default(key, self.get(keydict[key], ''))

        # update year start date and year end date from fiscal_year
        year_start_end_date = dataent.db.sql(
            """select year_start_date, year_end_date
			from `tabFiscal Year` where name=%s""", self.current_fiscal_year)
        if year_start_end_date:
            ysd = year_start_end_date[0][0] or ''
            yed = year_start_end_date[0][1] or ''

            if ysd and yed:
                dataent.db.set_default('year_start_date',
                                       ysd.strftime('%Y-%m-%d'))
                dataent.db.set_default('year_end_date',
                                       yed.strftime('%Y-%m-%d'))

        # enable default currency
        if self.default_currency:
            dataent.db.set_value("Currency", self.default_currency, "enabled",
                                 1)

        self.toggle_rounded_total()
        self.toggle_in_words()

        # clear cache
        dataent.clear_cache()
コード例 #6
0
ファイル: module_def.py プロジェクト: dataent/dataent
	def on_update(self):
		"""If in `developer_mode`, create folder for module and
			add in `modules.txt` of app if missing."""
		dataent.clear_cache()
		if dataent.conf.get("developer_mode"):
			self.create_modules_folder()
			self.add_to_modules_txt()
コード例 #7
0
ファイル: install.py プロジェクト: dataent/dataent
def before_tests():
    if len(dataent.get_installed_apps()) > 1:
        # don't run before tests if any other app is installed
        return

    dataent.db.sql("delete from `tabCustom Field`")
    dataent.db.sql("delete from `tabEvent`")
    dataent.db.commit()
    dataent.clear_cache()

    # complete setup if missing
    from dataent.desk.page.setup_wizard.setup_wizard import setup_complete
    if not int(
            dataent.db.get_single_value('System Settings', 'setup_complete')
            or 0):
        setup_complete({
            "language": "english",
            "email": "*****@*****.**",
            "full_name": "Test User",
            "password": "******",
            "country": "United States",
            "timezone": "America/New_York",
            "currency": "USD"
        })

    dataent.db.commit()
    dataent.clear_cache()
コード例 #8
0
    def save_customization(self):
        if not self.doc_type:
            return

        self.flags.update_db = False
        self.flags.rebuild_doctype_for_global_search = False

        self.set_property_setters()
        self.update_custom_fields()
        self.set_name_translation()
        validate_fields_for_doctype(self.doc_type)

        if self.flags.update_db:
            from dataent.model.db_schema import updatedb
            updatedb(self.doc_type)

        if not hasattr(self, 'hide_success') or not self.hide_success:
            dataent.msgprint(_("{0} updated").format(_(self.doc_type)))
        dataent.clear_cache(doctype=self.doc_type)
        self.fetch_to_customize()

        if self.flags.rebuild_doctype_for_global_search:
            dataent.enqueue('dataent.utils.global_search.rebuild_for_doctype',
                            now=True,
                            doctype=self.doc_type)
コード例 #9
0
ファイル: installer.py プロジェクト: dataent/dataent
def post_install(rebuild_website=False):
    if rebuild_website:
        render.clear_cache()

    init_singles()
    dataent.db.commit()
    dataent.clear_cache()
コード例 #10
0
def test_fetch_if_empty(self):
    dataent.db.sql('delete from tabToDo')

    # Allow user changes
    todo_meta = dataent.get_doc('DocType', 'ToDo')
    field = todo_meta.get('fields', dict(fieldname='assigned_by_full_name'))[0]
    field.fetch_from = 'assigned_by.full_name'
    field.fetch_if_empty = 1
    todo_meta.save()

    dataent.clear_cache(doctype='ToDo')

    todo = dataent.get_doc(
        dict(doctype='ToDo',
             description='test todo',
             assigned_by='Administrator',
             assigned_by_full_name='Admin')).insert()

    self.assertEqual(todo.assigned_by_full_name, 'Admin')

    # Overwrite user changes
    todo_meta = dataent.get_doc('DocType', 'ToDo')
    todo_meta.get(
        'fields',
        dict(fieldname='assigned_by_full_name'))[0].fetch_if_empty = 0
    todo_meta.save()

    todo.reload()
    todo.save()

    self.assertEqual(
        todo.assigned_by_full_name,
        dataent.db.get_value('User', todo.assigned_by, 'full_name'))
コード例 #11
0
    def on_update(self):
        """update defaults"""
        for key in education_keydict:
            dataent.db.set_default(key, self.get(education_keydict[key], ''))

        # clear cache
        dataent.clear_cache()
コード例 #12
0
    def test_fetch_setup(self):
        dataent.db.sql('delete from tabToDo')

        todo_meta = dataent.get_doc('DocType', 'ToDo')
        todo_meta.get(
            'fields',
            dict(fieldname='assigned_by_full_name'))[0].fetch_from = ''
        todo_meta.save()

        dataent.clear_cache(doctype='ToDo')

        todo = dataent.get_doc(
            dict(doctype='ToDo',
                 description='test todo',
                 assigned_by='Administrator')).insert()
        self.assertFalse(todo.assigned_by_full_name)

        todo_meta = dataent.get_doc('DocType', 'ToDo')
        todo_meta.get('fields', dict(fieldname='assigned_by_full_name')
                      )[0].fetch_from = 'assigned_by.full_name'
        todo_meta.save()

        todo.reload()

        self.assertEqual(
            todo.assigned_by_full_name,
            dataent.db.get_value('User', todo.assigned_by, 'full_name'))
コード例 #13
0
ファイル: print_format.py プロジェクト: dataent/dataent
    def on_update(self):
        if hasattr(self, 'old_doc_type') and self.old_doc_type:
            dataent.clear_cache(doctype=self.old_doc_type)
        if self.doc_type:
            dataent.clear_cache(doctype=self.doc_type)

        self.export_doc()
コード例 #14
0
def before_tests():
    dataent.clear_cache()
    # complete setup if missing
    from dataent.desk.page.setup_wizard.setup_wizard import setup_complete
    if not dataent.get_list("Company"):
        setup_complete({
            "currency": "USD",
            "full_name": "Test User",
            "company_name": "Wind Power LLC",
            "timezone": "America/New_York",
            "company_abbr": "WP",
            "industry": "Manufacturing",
            "country": "United States",
            "fy_start_date": "2011-01-01",
            "fy_end_date": "2011-12-31",
            "language": "english",
            "company_tagline": "Testing",
            "email": "*****@*****.**",
            "password": "******",
            "chart_of_accounts": "Standard",
            "domains": ["Manufacturing"],
        })

    dataent.db.sql("delete from `tabLeave Allocation`")
    dataent.db.sql("delete from `tabLeave Application`")
    dataent.db.sql("delete from `tabSalary Slip`")
    dataent.db.sql("delete from `tabItem Price`")

    dataent.db.set_value("Stock Settings", None,
                         "auto_insert_price_list_rate_if_missing", 0)
    enable_all_roles_and_domains()

    dataent.db.commit()
コード例 #15
0
    def if_owner_setup(self):
        update('Blog Post', 'Blogger', 0, 'if_owner', 1)

        add_user_permission("Blog Category", "_Test Blog Category 1",
                            "*****@*****.**")
        add_user_permission("Blogger", "_Test Blogger 1", "*****@*****.**")

        dataent.clear_cache(doctype="Blog Post")
コード例 #16
0
    def test_set_only_once_child_table_okay(self):
        doctype_meta = dataent.get_meta("DocType")
        doctype_meta.get_field("fields").set_only_once = 1
        doc = dataent.get_doc("DocType", "Blog Post")

        doc.load_doc_before_save()
        self.assertFalse(doc.validate_set_only_once())
        dataent.clear_cache(doctype='DocType')
コード例 #17
0
ファイル: setup_wizard.py プロジェクト: dataent/dataent
def update_global_settings(args):
	if args.language and args.language != "English":
		set_default_language(get_language_code(args.lang))
		dataent.db.commit()
	dataent.clear_cache()

	update_system_settings(args)
	update_user_name(args)
コード例 #18
0
def execute():
    dataent.db.sql(
        "update `tabDefaultValue` set parenttype='__default' where parenttype='Control Panel'"
    )
    dataent.db.sql(
        "update `tabDefaultValue` set parent='__default' where parent='Control Panel'"
    )
    dataent.clear_cache()
コード例 #19
0
def execute():
	hr = dataent.db.get_value("Module Def", "HR")
	if hr == "Hr":
		dataent.rename_doc("Module Def", "Hr", "HR")
		dataent.db.set_value("Module Def", "HR", "module_name", "HR")

	dataent.clear_cache()
	dataent.setup_module_map()
コード例 #20
0
def execute():
    dataent.reload_doc("core", "doctype", "docfield")
    dataent.reload_doc("hr", "doctype", "employee")

    set_print_email_permissions()
    migrate_user_properties_to_user_permissions()

    dataent.clear_cache()
コード例 #21
0
ファイル: test_global_search.py プロジェクト: dataent/dataent
 def tearDown(self):
     dataent.db.sql(
         'delete from `tabProperty Setter` where doc_type="Event"')
     dataent.clear_cache(doctype='Event')
     dataent.db.sql('delete from `tabEvent`')
     dataent.db.sql('delete from __global_search')
     make_test_objects('Event')
     dataent.db.commit()
コード例 #22
0
def execute():
	dataent.clear_cache()
	installed = dataent.get_installed_apps()
	if "webnotes" in installed:
		installed.remove("webnotes")
	if "dataent" not in installed:
		installed = ["dataent"] + installed
	dataent.db.set_global("installed_apps", json.dumps(installed))
	dataent.clear_cache()
コード例 #23
0
    def on_trash(self):
        # delete property setter entries
        dataent.db.sql(
            """\
			DELETE FROM `tabProperty Setter`
			WHERE doc_type = %s
			AND field_name = %s""", (self.dt, self.fieldname))

        dataent.clear_cache(doctype=self.dt)
コード例 #24
0
    def test_set_only_once_child_table_rows(self):
        doctype_meta = dataent.get_meta("DocType")
        doctype_meta.get_field("fields").set_only_once = 1
        doc = dataent.get_doc("DocType", "Blog Post")

        # remove last one
        doc.fields = doc.fields[:-1]
        self.assertRaises(dataent.CannotChangeConstantError, doc.save)
        dataent.clear_cache(doctype='DocType')
コード例 #25
0
    def test_set_only_once_child_table_row_value(self):
        doctype_meta = dataent.get_meta("DocType")
        doctype_meta.get_field("fields").set_only_once = 1
        doc = dataent.get_doc("DocType", "Blog Post")

        # change one property from the child table
        doc.fields[-1].fieldtype = 'HTML'
        self.assertRaises(dataent.CannotChangeConstantError, doc.save)
        dataent.clear_cache(doctype='DocType')
コード例 #26
0
def sync_all(force=0, verbose=False, reset_permissions=False):
	block_user(True)

	for app in dataent.get_installed_apps():
		sync_for(app, force, verbose=verbose, reset_permissions=reset_permissions)

	block_user(False)

	dataent.clear_cache()
コード例 #27
0
def execute():
    for d in dataent.get_all("Property Setter",
                             fields=["name", "doc_type"],
                             filters={
                                 "doctype_or_field": "DocField",
                                 "property": "allow_on_submit",
                                 "value": "1"
                             }):
        dataent.delete_doc("Property Setter", d.name)
        dataent.clear_cache(doctype=d.doc_type)
コード例 #28
0
 def login(self):
     # clear cache
     dataent.clear_cache(user=dataent.form_dict.get('usr'))
     user, pwd = get_cached_user_pass()
     self.authenticate(user=user, pwd=pwd)
     if should_run_2fa(self.user):
         authenticate_for_2factor(self.user)
         if not confirm_otp_token(self):
             return False
     self.post_login()
コード例 #29
0
ファイル: portal_settings.py プロジェクト: dataent/dataent
	def clear_cache(self):
		# make js and css
		# clear web cache (for menus!)
		dataent.clear_cache(user='******')

		from dataent.website.render import clear_cache
		clear_cache()

		# clears role based home pages
		dataent.clear_cache()
コード例 #30
0
    def reset_to_defaults(self):
        if not self.doc_type:
            return

        dataent.db.sql(
            """delete from `tabProperty Setter` where doc_type=%s
			and !(`field_name`='naming_series' and `property`='options')""",
            self.doc_type)
        dataent.clear_cache(doctype=self.doc_type)
        self.fetch_to_customize()