Exemple #1
0
 def on_rename(self, newdn, olddn):
     sql("update `tabCompany` set company_name = '%s' where name = '%s'" % (newdn, olddn))
     sql(
         "update `tabSingles` set value = %s where doctype='Global Defaults' and field = 'default_company' and value = %s",
         (newdn, olddn),
     )
     if get_defaults("company") == olddn:
         set_default("company", newdn)
Exemple #2
0
 def on_rename(self, newdn, olddn):
     sql("update `tabCompany` set company_name = '%s' where name = '%s'" %
         (newdn, olddn))
     sql(
         "update `tabSingles` set value = %s where doctype='Global Defaults' and field = 'default_company' and value = %s",
         (newdn, olddn))
     if get_defaults('company') == olddn:
         set_default('company', newdn)
Exemple #3
0
	def set_as_default(self):
		from webnotes.utils import set_default
		if self.doc.is_default:
			sql("update `tabLetter Head` set is_default=0 where name != %s", self.doc.name)
			set_default('letter_head', self.doc.name)

			# update control panel - so it loads new letter directly
			webnotes.conn.set_value('Control Panel', None, 'letter_head', self.doc.content)
Exemple #4
0
	def validate(self):
		"""
			update settings in defaults
		"""
		from webnotes.model import default_fields 
		from webnotes.utils import set_default
		for key in self.doc.fields:
			if key not in default_fields:
				set_default(key, self.doc.fields[key])
Exemple #5
0
    def validate(self):
        """
			update settings in defaults
		"""
        from webnotes.model import default_fields
        from webnotes.utils import set_default
        for key in self.doc.fields:
            if key not in default_fields:
                set_default(key, self.doc.fields[key])
Exemple #6
0
    def set_as_default(self):
        from webnotes.utils import set_default
        if self.doc.is_default:
            sql("update `tabLetter Head` set is_default=0 where name != %s",
                self.doc.name)
            set_default('letter_head', self.doc.name)

            # update control panel - so it loads new letter directly
            webnotes.conn.set_value('Control Panel', None, 'letter_head',
                                    self.doc.content)
	def set_as_default(self):
		from webnotes.utils import set_default
		if not self.doc.is_default:
			if not webnotes.conn.sql("""select count(*) from `tabLetter Head` where ifnull(is_default,0)=1"""):
				self.doc.is_default = 1
		if self.doc.is_default:
			webnotes.conn.sql("update `tabLetter Head` set is_default=0 where name != %s",
				self.doc.name)
			set_default('letter_head', self.doc.name)

			# update control panel - so it loads new letter directly
			webnotes.conn.set_value('Control Panel', None, 'letter_head', self.doc.content)
Exemple #8
0
    def set_as_default(self):
        from webnotes.utils import set_default
        if not self.doc.is_default:
            if not webnotes.conn.sql(
                    """select count(*) from `tabLetter Head` where ifnull(is_default,0)=1"""
            ):
                self.doc.is_default = 1
        if self.doc.is_default:
            webnotes.conn.sql(
                "update `tabLetter Head` set is_default=0 where name != %s",
                self.doc.name)
            set_default('letter_head', self.doc.name)

            # update control panel - so it loads new letter directly
            webnotes.conn.set_value('Control Panel', None, 'letter_head',
                                    self.doc.content)
Exemple #9
0
def update_account_details():
	# additional details (if from gateway)
	if webnotes.form_dict.get('is_trial'):
		webnotes.conn.set_global('is_trial', cint(webnotes.form_dict.get('is_trial')))

	if webnotes.form_dict.get('days_to_expiry'):
		webnotes.conn.set_global('days_to_expiry', webnotes.form_dict.get('days_to_expiry'))

	if webnotes.form_dict.get('first_name'):
		from server_tools.gateway_utils import update_user_details
		update_user_details()

	if webnotes.form_dict.get('xpassword') and webnotes.form_dict.get('login_as')!='Administrator':
		webnotes.conn.sql("""update tabProfile set password=password(%(xpassword)s) where name=%(login_as)s""", (webnotes.form_dict))

	if webnotes.form_dict.get('url_name'):
		from webnotes.utils import set_default
		set_default('account_url', 'http://'+webnotes.form_dict.get('url_name'))
Exemple #10
0
	def setup_account(self, args):
		company_name, comp_abbr, fy_start, currency = eval(args)
		curr_fiscal_year,fy_start_date = self.get_fy_details(fy_start)
		self.currency = currency
		
		# Fiscal Year
		master_dict = {'Fiscal Year':{'year':curr_fiscal_year, 'year_start_date':fy_start_date}}
		self.create_records(master_dict)
		
		# Company
		master_dict = {'Company':{'company_name':company_name,
								  'abbr':comp_abbr,
								  'default_currency':currency
															}}
		self.create_records(master_dict)
		
		def_args = {'current_fiscal_year':curr_fiscal_year,
								'default_currency': currency,
								'default_company':company_name,
								'default_valuation_method':'FIFO',
								'date_format':'dd-mm-yyyy',
								'default_currency_format':'Lacs',
								'so_required':'No',
								'dn_required':'No',
								'po_required':'No',
								'pr_required':'No',
								'emp_created_by':'Naming Series',
								'cust_master_name':'Customer Name', 
								'supp_master_name':'Supplier Name',
								'default_currency_format': (currency=='INR') and 'Lacs' or 'Millions'
					}

		# Set 
		self.set_defaults(def_args)

		# Set Registration Complete
		set_default('registration_complete','1')

		webnotes.msgprint("Great! Your company has now been created")
		
		import webnotes.utils
		return webnotes.utils.get_defaults()
Exemple #11
0
    def setup_account(self, args):
        company_name, comp_abbr, fy_start, currency = eval(args)
        curr_fiscal_year, fy_start_date = self.get_fy_details(fy_start)
        self.currency = currency

        # Fiscal Year
        master_dict = {"Fiscal Year": {"year": curr_fiscal_year, "year_start_date": fy_start_date}}
        self.create_records(master_dict)

        # Company
        master_dict = {"Company": {"company_name": company_name, "abbr": comp_abbr}}
        self.create_records(master_dict)

        def_args = {
            "current_fiscal_year": curr_fiscal_year,
            "default_currency": currency,
            "default_company": company_name,
            "default_valuation_method": "FIFO",
            "date_format": "dd-mm-yyyy",
            "default_currency_format": "Lacs",
            "so_required": "No",
            "dn_required": "No",
            "po_required": "No",
            "pr_required": "No",
            "emp_created_by": "Naming Series",
            "cust_master_name": "Customer Name",
            "supp_master_name": "Supplier Name",
        }

        # Set
        self.set_defaults(def_args)

        # Set Registration Complete
        set_default("registration_complete", "1")

        import webnotes.utils

        return webnotes.utils.get_defaults()
  def set_system_default(self, defkey, defvalue):
    set_default(defkey, defvalue)

    if defkey == 'fiscal_year':
      ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", cstr(defvalue))
      ysd = ysd and ysd[0][0] or ''
      if ysd:
        set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
        set_default('year_end_date', get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
Exemple #13
0
def update_account_details():
    # additional details (if from gateway)
    if webnotes.form_dict.get('is_trial'):
        webnotes.conn.set_global('is_trial',
                                 cint(webnotes.form_dict.get('is_trial')))

    if webnotes.form_dict.get('days_to_expiry'):
        webnotes.conn.set_global('days_to_expiry',
                                 webnotes.form_dict.get('days_to_expiry'))

    if webnotes.form_dict.get('first_name'):
        from server_tools.gateway_utils import update_user_details
        update_user_details()

    if webnotes.form_dict.get('xpassword') and webnotes.form_dict.get(
            'login_as') != 'Administrator':
        webnotes.conn.sql(
            """update tabProfile set password=password(%(xpassword)s) where name=%(login_as)s""",
            (webnotes.form_dict))

    if webnotes.form_dict.get('url_name'):
        from webnotes.utils import set_default
        set_default('account_url',
                    'http://' + webnotes.form_dict.get('url_name'))
Exemple #14
0
	def on_rename(self,newdn,olddn):		
		sql("update `tabCompany` set company_name = '%s' where name = '%s'" %(newdn,olddn))	
		sql("update `tabSingles` set value = %s where doctype='Manage Account' and field = 'default_company' and value = %s", (newdn, olddn))	
		if get_defaults('company') == olddn:
			set_default('company', newdn)
Exemple #15
0
  def on_update(self):

    # fiscal year
    set_default('fiscal_year', self.doc.current_fiscal_year)
    ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", self.doc.current_fiscal_year, as_dict = 1)
    set_default('year_start_date', ysd[0]['year_start_date'].strftime('%Y-%m-%d'))
    set_default('year_end_date', get_last_day(get_first_day(ysd[0]['year_start_date'],0,11)).strftime('%Y-%m-%d'))

    # company
    set_default('company', self.doc.default_company)

    set_default('stock_valuation', self.doc.stock_valuation or 'Moving Average')
    set_default('default_currency', self.doc.default_currency or 'INR')

    # Purchase in transit
    if self.doc.purchase_in_transit_account:
      set_default('purchase_in_transit_account', self.doc.purchase_in_transit_account)
	def set_welcome_done(self):
		set_default('welcome_done', '1')
Exemple #17
0
 def on_update(self):
   set_default('fiscal_year', self.doc.current_fiscal_year)
   ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", self.doc.current_fiscal_year)[0][0]
   set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
   set_default('year_end_date', get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))