Example #1
0
	def validate_abbr(self):
		if not self.salary_component_abbr:
			self.salary_component_abbr = ''.join([c[0] for c in
				self.salary_component.split()]).upper()

		self.salary_component_abbr = self.salary_component_abbr.strip()
		self.salary_component_abbr = append_number_if_name_exists('Salary Component', self.salary_component_abbr,
			'salary_component_abbr', separator='_', filters={"name": ["!=", self.name]})
Example #2
0
	def test_append_number_if_name_exists(self):
		'''
		Append number to name based on existing values
		if Bottle exists
			Bottle -> Bottle-1
		if Bottle-1 exists
			Bottle -> Bottle-2
		'''

		note = frappe.new_doc('Note')
		note.title = 'Test'
		note.insert()

		title2 = append_number_if_name_exists('Note', 'Test')
		self.assertEqual(title2, 'Test-1')

		title2 = append_number_if_name_exists('Note', 'Test', 'title', '_')
		self.assertEqual(title2, 'Test_1')
Example #3
0
	def autoname(self):
		# concat first and last name
		self.name = " ".join(filter(None,
			[cstr(self.get(f)).strip() for f in ["first_name", "last_name"]]))

		if frappe.db.exists("Contact", self.name):
			self.name = append_number_if_name_exists('Contact', self.name)

		# concat party name if reqd
		for link in self.links:
			self.name = self.name + '-' + link.link_name.strip()
			break
Example #4
0
def create_dashboard_chart(args):
    args = frappe.parse_json(args)
    doc = frappe.new_doc('Dashboard Chart')

    doc.update(args)

    if args.get('custom_options'):
        doc.custom_options = json.dumps(args.get('custom_options'))

    if frappe.db.exists('Dashboard Chart', args.chart_name):
        args.chart_name = append_number_if_name_exists('Dashboard Chart',
                                                       args.chart_name)
        doc.chart_name = args.chart_name
    doc.insert(ignore_permissions=True)
    return doc
Example #5
0
def make_variant_based_on_manufacturer(template, manufacturer, manufacturer_part_no):
	'''Make and return a new variant based on manufacturer and
		manufacturer part no'''
	from frappe.model.naming import append_number_if_name_exists

	variant = frappe.new_doc('Item')

	copy_attributes_to_variant(template, variant)

	variant.manufacturer = manufacturer
	variant.manufacturer_part_no = manufacturer_part_no

	variant.item_code = append_number_if_name_exists('Item', template.name)

	return variant
Example #6
0
def make_variant_based_on_manufacturer(template, manufacturer, manufacturer_part_no):
	'''Make and return a new variant based on manufacturer and
		manufacturer part no'''
	from frappe.model.naming import append_number_if_name_exists

	variant = frappe.new_doc('Item')

	copy_attributes_to_variant(template, variant)

	variant.manufacturer = manufacturer
	variant.manufacturer_part_no = manufacturer_part_no

	variant.item_code = append_number_if_name_exists('Item', template.name)

	return variant
def create_company(company_name, country, default_currency, chart_of_accounts, forked_from=None):
	frappe.local.flags.allow_unverified_charts = True
	
	company = frappe.new_doc("Company")
	company.country = country
	company.default_currency = default_currency
	company.chart_of_accounts = chart_of_accounts
	company.name = company_name
	company.abbr = random_string(3)
	company.forked = 1
	company.forked_from = forked_from
	company = append_number_if_name_exists(company)
	company.company_name = company.name
	
	company.flags.ignore_permissions = True
	
	company.insert(ignore_permissions=True)
	
	if frappe.local.message_log:
		frappe.local.message_log = []
		
	frappe.local.flags.allow_unverified_charts = False
	
	return company.name
Example #8
0
    def autoname(self):
        # concat first and last name
        self.name = self.practitioner_name

        if frappe.db.exists('kis Practitioner', self.name):
            self.name = append_number_if_name_exists('Contact', self.name)
Example #9
0
	def autoname(self):
		if not self.name:
			self.name = self.label

		if frappe.db.exists("Number Card", self.name):
			self.name = append_number_if_name_exists('Number Card', self.name)
	def autoname(self):
		if self.meta.autoname != "hash":
			self.name = self.get_page_name()
			append_number_if_name_exists(self)
Example #11
0
 def autoname(self):
     self.name = _(self.report)
     if frappe.db.exists("Auto Email Report", self.name):
         self.name = append_number_if_name_exists("Auto Email Report",
                                                  self.name)
Example #12
0
 def autoname(self):
     if self.meta.autoname != "hash":
         self.name = self.get_page_name()
         append_number_if_name_exists(self)
Example #13
0
	def autoname(self):
		self.name = self.get_page_name()
		append_number_if_name_exists(self)
Example #14
0
    def autoname(self):
        self.setup_generator()
        if not self.website_template: return

        self.name = self.get_page_name()
        append_number_if_name_exists(self)
Example #15
0
	def autoname(self):
		self.name = self.email_id

		# applicant can apply more than once for a different job title or reapply
		if frappe.db.exists("Job Applicant", self.name):
			self.name = append_number_if_name_exists("Job Applicant", self.name)
Example #16
0
 def autoname(self):
     self.name = self.get_page_name()
     append_number_if_name_exists(self)
    def autoname(self):
        # concat first and last name
        self.name = self.practitioner_name

        if frappe.db.exists("Healthcare Practitioner", self.name):
            self.name = append_number_if_name_exists("Contact", self.name)
Example #18
0
	def autoname(self):
		self.setup_generator()
		if not self.website_template: return

		self.name = self.get_page_name()
		append_number_if_name_exists(self)