Beispiel #1
0
    def validate(self):
        from erpnext.controllers.status_updater import validate_status
        validate_status(self.status, ["Active", "Left"])

        self.employee = self.name
        self.validate_date()
        self.validate_email()
        self.validate_position()
        self.validate_status()
        self.validate_employee_leave_approver()
        self.validate_reports_to()
        self.validate_prefered_email()
        self.validate_stop_working_date()
        self.validate_medical_data()
        #self.validate_resident_data()
        self.validate_attendance_data()

        if self.user_id:
            self.validate_user_details()
        else:
            existing_user_id = frappe.db.get_value("Employee", self.name,
                                                   "user_id")
            if existing_user_id:
                frappe.permissions.remove_user_permission(
                    "Employee", self.name, existing_user_id)

        if self.finger_print_number:
            self.validate_duplicate_finger_print_number()
Beispiel #2
0
	def validate(self):
		super(MaterialRequest, self).validate()

		self.validate_schedule_date()
		self.validate_uom_is_integer("uom", "qty")

		if not self.status:
			self.status = "Draft"

		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Draft", "Submitted", "Stopped", "Cancelled"])

		pc_obj = frappe.get_doc('Purchase Common')
		pc_obj.validate_for_items(self)

		# self.validate_qty_against_so()
		# NOTE: Since Item BOM and FG quantities are combined, using current data, it cannot be validated
		# Though the creation of Material Request from a Production Plan can be rethought to fix this

		#Start of Insert By Poorvi on 10-09-2016 for IBM value calculation
		selco_ibm_value = 0
		#if self.workflow_state =="Approval Pending by SM - IBM":
		for idx,selco_item in enumerate(self.items):
			selco_rate = frappe.db.sql("""select price_list_rate
				from `tabItem Price`
				where item_code = %s and price_list = "Branch Sales" """,(selco_item.item_code))
			if selco_rate:
				var1=selco_rate[0][0]
			else:
				var1=0
			self.items[idx].selco_rate =var1
			selco_ibm_value = selco_ibm_value + (var1 * selco_item.qty)
		self.selco_ibm_value = selco_ibm_value
		#self.items.sort(key = lambda x: x.item_code)
		self.items.sort(key=operator.attrgetter("item_code"), reverse=False)
Beispiel #3
0
	def validate(self):
		super(SalesOrder, self).validate()

		self.validate_order_type()
		self.validate_delivery_date()
		self.validate_mandatory()
		self.validate_proj_cust()
		self.validate_po()
		self.validate_uom_is_integer("stock_uom", "qty")
		self.validate_for_items()
		self.validate_warehouse()

		from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
		make_packing_list(self,'items')

		self.validate_with_previous_doc()

		if not self.status:
			self.status = "Draft"

		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Draft", "Submitted", "Stopped",
			"Cancelled"])

		if not self.billing_status: self.billing_status = 'Not Billed'
		if not self.delivery_status: self.delivery_status = 'Not Delivered'
Beispiel #4
0
 def validate(self):
     from erpnext.controllers.status_updater import validate_status
     validate_status(self.status,
                     ["Present", "Absent", "On Leave", "Half Day"])
     self.validate_attendance_date()
     self.validate_duplicate_record()
     self.check_leave_record()
Beispiel #5
0
	def validate(self):
		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Active", "Temporary Leave", "Left"])

		self.employee = self.name
		self.set_employee_name()
		self.validate_date()
		self.validate_email()
		self.validate_status()
		self.validate_reports_to()
		self.validate_preferred_email()
		self.update_batch()
		if self.job_applicant:
			self.validate_onboarding_process()

		if self.user_id:
			self.validate_user_details()
		else:
			existing_user_id = frappe.db.get_value("Employee", self.name, "user_id")
			if existing_user_id:
				remove_user_permission(
					"Employee", self.name, existing_user_id)

		if self.referred_employee:
			referred=self.get_employee_referral()
			if not referred:
				refer=frappe.new_doc("Employee Referral")
				refer.employee=self.referred_employee
				refer.employee_name = self.referred_employee_name
				refer.employee_referral=self.name
				refer.employee_referral_name= self.employee_name
				refer.confirmation_date=self.final_confirmation_date
				refer.date_of_joining=self.date_of_joining
				refer.department= self.department
				refer.save()
Beispiel #6
0
    def validate(self):
        from erpnext.controllers.status_updater import validate_status
        validate_status(self.status, ["Active", "Temporary Leave", "Left"])

        self.employee = self.name
        self.set_employee_name()
        self.set_employee_name_arabic()
        self.validate_date()
        self.validate_email()
        self.validate_status()
        self.validate_reports_to()
        self.validate_preferred_email()
        if self.job_applicant:
            self.validate_onboarding_process()

        if self.user_id:
            self.validate_for_enabled_user_id()
            self.validate_duplicate_user_id()
        else:
            existing_user_id = frappe.db.get_value("Employee", self.name, "user_id")
            if existing_user_id:
                remove_user_permission(
                    "Employee", self.name, existing_user_id)

        if self.advances_account_check:
            self.add_advances_account()
        if self.salary_expenses_account_check:
            self.add_salary_expebses_account()
        if self.accrued_vacation_account_check:
            self.add_accrued_vacation_account()
        if self.end_of_service_account_check:
            self.Add_end_of_service_account()
Beispiel #7
0
	def validate(self):
		from erpnext.controllers.status_updater import validate_status
		from erpnext.accounts.utils import validate_fiscal_year
		validate_status(self.status, ["Present", "Absent", "Half Day"])
		validate_fiscal_year(self.att_date, self.fiscal_year, _("Attendance Date"), self)
		self.validate_att_date()
		self.validate_duplicate_record()
		self.check_leave_record()
Beispiel #8
0
	def validate(self):
		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Active", "Left"])
		self.validate_date()
		self.validate_email()
		self.validate_status()
		#self.validate_employee_leave_approver()
		#self.validate_reports_to()
		#self.validate_prefered_email()
                #self.validate_phone_cell()
		self.clearance_leave_balances()
		#self.validate_duplicate_personal_email()
		#self.validate_duplicate_cell_number()

		if self.email and self.is_new():
			#pass
			#self.validate_for_enabled_user_id()
			self.validate_duplicate_user_id()
			self.create_user()
		else:
			existing_user_id = frappe.db.get_value("Employee", self.name, "email")
			if existing_user_id:
				frappe.permissions.remove_user_permission(
					"Employee", self.name, existing_user_id)


		try:
			if self.supervisor:
				self.add_manager_staff()

			self.deactivate_employee()
			self.update_emp_work_shift()
			self.update_emp_work_history()
		except:
			pass	

		#if self.basic_salary and  self.validate_salary_structure():
		#	pass#frappe.msgprint(_("Press Make Salary Structure Button"))

		if not self.get(self.employee_dependent):# not [] or self.employee_dependent not None: 
			child_num =0
			for d in self.get("employee_dependent"): #('Employee Dependent')
				if d.relation =='Son' or d.relation =='Daughter':
					child_num += 1
			add_depenents_bonus(self.name, 'Bonus Children', child_num)

		if not self.name:
			frappe.msgprint(__("Data Required!"))
		if self.type and not self.relieving_date:
			frappe.throw(_("Please enter relieving date."))
		elif self.type and self.relieving_date:
			self.service_years = self.get_service_years()
			self.amount = flt(self.calculate_end_service_amount())
			#self.update_emp_status('Left')

		# clear new password
		self.__new_password = self.new_password
		self.new_password = ""
Beispiel #9
0
	def validate(self):
		from erpnext.controllers.status_updater import validate_status

		validate_status(self.status, ["Present", "Absent", "On Leave", "Half Day", "Work From Home"])
		validate_active_employee(self.employee)
		self.validate_attendance_date()
		self.validate_duplicate_record()
		self.validate_employee_status()
		self.check_leave_record()
Beispiel #10
0
	def validate(self):
		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Present", "Absent", "Half Day"])
		self.validate_att_date()
		self.validate_duplicate_record()
		self.check_leave_record()
		self.calculate_total_hours()
		if self.normal_time < 0:
			frappe.throw(_("Working Time cannot be less than 0, date {0}").format(self.att_date))
 def validate(self):
     from erpnext.controllers.status_updater import validate_status
     validate_status(self.status,
                     ["Present", "Absent", "On Leave", "Half Day"])
     self.validate_attendance_date()
     self.validate_employee()
     self.validate_duplicate_record()
     self.check_leave_record()
     self.validate_in_out()
     self.validate_total_hours()
     self.validate_total_in_week_month()
    def validate(self):
        super(SupplierQuotation, self).validate()

        if not self.status:
            self.status = "Draft"

        from erpnext.controllers.status_updater import validate_status
        validate_status(self.status,
                        ["Draft", "Submitted", "Stopped", "Cancelled"])

        validate_for_items(self)
        self.validate_with_previous_doc()
        self.validate_uom_is_integer("uom", "qty")
	def validate(self):
		super(SupplierQuotation, self).validate()

		if not self.status:
			self.status = "Draft"

		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Draft", "Submitted", "Stopped",
			"Cancelled"])

		validate_for_items(self)
		self.validate_with_previous_doc()
		self.validate_uom_is_integer("uom", "qty")
Beispiel #14
0
 def validate(self):
     self.validate_employee()
     from erpnext.controllers.status_updater import validate_status
     validate_status(self.status,
                     ["Present", "Absent", "On Leave", "Half Day"])
     self.validate_attendance_date()
     self.validate_duplicate_record()
     self.check_leave_record()
     self.calculate_total_hours()
     if self.normal_time < 0:
         frappe.throw(
             _("Working Time cannot be less than 0, date {0}").format(
                 self.attendance_date))
Beispiel #15
0
    def validate(self):
        from erpnext.controllers.status_updater import validate_status
        from erpnext.accounts.utils import validate_fiscal_year
        validate_status(self.status, ["Present", "Absent", "Half Day"])
        validate_fiscal_year(self.att_date, self.fiscal_year,
                             _("Attendance Date"), self)
        self.validate_att_date()
        self.validate_duplicate_record()
        self.check_leave_record()
        self.validate_task_details()

        self.working_hours = self.calculate_total_work_hours()
        self.break_time = self.calculate_total_break_hours()
Beispiel #16
0
    def validate(self):
        from erpnext.controllers.status_updater import validate_status
        validate_status(self.status, ["Active", "Left"])

        self.employee = self.name
        self.validate_date()
        self.validate_email()
        self.validate_status()
        self.validate_employee_leave_approver()
        self.validate_reports_to()

        if self.user_id:
            self.validate_for_enabled_user_id()
            self.validate_duplicate_user_id()
	def validate(self):
		super(MaterialRequest, self).validate()

		self.validate_schedule_date()
		self.validate_uom_is_integer("uom", "qty")

		if not self.status:
			self.status = "Draft"

		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Draft", "Submitted", "Stopped", "Cancelled"])

		pc_obj = frappe.get_doc('Purchase Common')
		pc_obj.validate_for_items(self)
Beispiel #18
0
	def validate(self):
		super(MaterialRequest, self).validate()

		self.validate_schedule_date()
		self.validate_uom_is_integer("uom", "qty")

		if not self.status:
			self.status = "Draft"

		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Draft", "Submitted", "Stopped", "Cancelled"])

		pc_obj = frappe.get_doc('Purchase Common')
		pc_obj.validate_for_items(self)
Beispiel #19
0
	def validate(self):
		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Active", "Left"])

		self.employee = self.name
		self.validate_date()
		self.validate_email()
		self.validate_status()
		self.validate_employee_leave_approver()
		self.validate_reports_to()

		if self.user_id:
			self.validate_for_enabled_user_id()
			self.validate_duplicate_user_id()
Beispiel #20
0
    def validate(self):
        from erpnext.controllers.status_updater import validate_status
        validate_status(self.status, [
            "Active", "Temporary Leave", "Left", 'Resign',
            'With In Article 81', 'With Out Article 81',
            'Marriage Within 6 Months Or 3 Months Of Childbirth',
            'Force Majeure', 'With In Article 80', 'With Out Article 80',
            'End By Employer',
            'Expiration Of The Contract Or Agreement Of The Parties'
        ])

        self.employee = self.name
        self.set_employee_name()
        self.validate_date()
        self.set_total()
Beispiel #21
0
	def validate(self):
		super(MaterialRequest, self).validate()

		self.validate_schedule_date()
		self.validate_uom_is_integer("uom", "qty")

		if not self.status:
			self.status = "Draft"

		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, 
			["Draft", "Submitted", "Stopped", "Cancelled", "Pending",
			"Partially Ordered", "Ordered", "Issued", "Transferred"])

		validate_for_items(self)
Beispiel #22
0
	def validate(self):
		super(MaterialRequest, self).validate()

		self.validate_schedule_date()
		self.validate_uom_is_integer("uom", "qty")

		if not self.status:
			self.status = "Draft"

		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status,
			["Draft", "Submitted", "Stopped", "Cancelled", "Pending",
			"Partially Ordered", "Ordered", "Issued", "Transferred"])

		validate_for_items(self)
	def validate(self):
		super(MaterialRequest, self).validate()

		self.validate_schedule_date()
		self.check_for_on_hold_or_closed_status('Sales Order', 'sales_order')
		self.validate_uom_is_integer("uom", "qty")

		if not self.status:
			self.status = "Draft"

		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status,
			["Draft", "Submitted", "Stopped", "Cancelled", "Pending",
			"Partially Ordered", "Ordered", "Issued", "Transferred", "Received"])

		validate_for_items(self)

		self.set_title()
Beispiel #24
0
	def validate(self):
		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Active", "Left"])

		self.employee = self.name
		self.validate_date()
		self.validate_email()
		self.validate_status()
		self.validate_employee_leave_approver()
		self.validate_reports_to()

		if self.user_id:
			self.validate_for_enabled_user_id()
			self.validate_duplicate_user_id()
		else:
			existing_user_id = frappe.db.get_value("Employee", self.name, "user_id")
			if existing_user_id:
				frappe.permissions.remove_user_permission("Employee", self.name, existing_user_id)
	def validate(self):
		if self.docstatus == 0:
			self.status = "Draft"

		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Draft", "Submitted", "Stopped",
			"In Process", "Completed", "Cancelled"])

		if self.bom_no:
			validate_bom_no(self.production_item, self.bom_no)

		self.validate_sales_order()
		self.validate_warehouse()
		self.calculate_operating_cost()
		self.validate_delivery_date()

		from erpnext.utilities.transaction_base import validate_uom_is_integer
		validate_uom_is_integer(self, "stock_uom", ["qty", "produced_qty"])
Beispiel #26
0
	def validate(self):
		#rule_code = frappe.db.get_value("Wage Rule", {"rule_code": self.rule_code},"rule_code")
		#if self.is_new() and self.amended_from:
			#self.revision_number = self.revision_number + 1

		self.validate_prevdoc_dates()
		#if self.is_new() and self.amended_from != None and self.revision_number==1:
			#frappe.throw(_("Rule Code '{0}' Already Exist with Revision Number '{1}'").format(self.rule_code, self.revision_number))

		if self.party_name and self.rule_code and self.revision_number:
			wr = frappe.db.sql("select rule_code from `tabWage Rule` \
						where  party_name = %s and revision_number = %s and docstatus = 1\
						and rule_code = %s", (self.party_name, self.revision_number, self.rule_code))
			if wr and wr[0][0]:
				frappe.throw(_("Rule Code <b> ' {0} '</b> And Revision : <b> {1} </b> already exist for Party : <b>{2}</b> ").format(self.rule_code,self.revision_number,self.party_name))

		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Active", "Closed", "Cancelled"])
Beispiel #27
0
	def validate(self):
		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Active", "Left"])

		self.employee = self.name
		self.validate_date()
		self.validate_email()
		self.validate_status()
		self.validate_employee_leave_approver()
		self.validate_reports_to()

		if self.user_id:
			self.validate_for_enabled_user_id()
			self.validate_duplicate_user_id()
		else:
			existing_user_id = frappe.db.get_value("Employee", self.name, "user_id")
			if existing_user_id:
				frappe.permissions.remove_user_permission("Employee", self.name, existing_user_id)
Beispiel #28
0
    def validate(self):
        if self.docstatus == 0:
            self.status = "Draft"

        from erpnext.controllers.status_updater import validate_status
        validate_status(self.status, [
            "Draft", "Submitted", "Stopped", "In Process", "Completed",
            "Cancelled"
        ])

        if self.bom_no:
            validate_bom_no(self.production_item, self.bom_no)

        self.validate_sales_order()
        self.validate_warehouse()
        self.calculate_operating_cost()
        self.validate_delivery_date()

        from erpnext.utilities.transaction_base import validate_uom_is_integer
        validate_uom_is_integer(self, "stock_uom", ["qty", "produced_qty"])
Beispiel #29
0
    def validate(self):
        from erpnext.controllers.status_updater import validate_status
        validate_status(self.status, ["Active", "Temporary Leave", "Left"])

        self.employee = self.name
        self.set_employee_name()
        self.validate_date()
        self.validate_email()
        self.validate_status()
        self.validate_reports_to()
        self.validate_preferred_email()
        if self.job_applicant:
            self.validate_onboarding_process()

        if self.user_id:
            self.validate_user_details()
        else:
            existing_user_id = frappe.db.get_value("Employee", self.name,
                                                   "user_id")
            if existing_user_id:
                remove_user_permission("Employee", self.name, existing_user_id)
Beispiel #30
0
	def validate(self):
		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Active", "Temporary Leave", "Left"])

		self.employee = self.name
		self.set_employee_name()
		self.validate_date()
		self.validate_email()
		self.validate_status()
		self.validate_reports_to()
		self.validate_preferred_email()
		if self.job_applicant:
			self.validate_onboarding_process()

		if self.user_id:
			self.validate_user_details()
		else:
			existing_user_id = frappe.db.get_value("Employee", self.name, "user_id")
			if existing_user_id:
				remove_user_permission(
					"Employee", self.name, existing_user_id)
Beispiel #31
0
    def validate(self):
        super(PurchaseOrder, self).validate()

        if not self.status:
            self.status = "Draft"

        from erpnext.controllers.status_updater import validate_status

        validate_status(self.status, ["Draft", "Submitted", "Stopped", "Cancelled"])

        pc_obj = frappe.get_doc("Purchase Common")
        pc_obj.validate_for_items(self)
        self.check_for_stopped_status(pc_obj)

        self.validate_uom_is_integer("uom", "qty")
        self.validate_uom_is_integer("stock_uom", ["qty", "required_qty"])

        self.validate_with_previous_doc()
        self.validate_for_subcontracting()
        self.validate_minimum_order_qty()
        self.create_raw_materials_supplied("supplied_items")
Beispiel #32
0
	def validate(self):
		super(PurchaseOrder, self).validate()

		if not self.status:
			self.status = "Draft"

		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Draft", "Submitted", "Stopped",
			"Cancelled"])

		pc_obj = frappe.get_doc('Purchase Common')
		pc_obj.validate_for_items(self)
		self.check_for_stopped_status(pc_obj)

		self.validate_uom_is_integer("uom", "qty")
		self.validate_uom_is_integer("stock_uom", ["qty", "required_qty"])

		self.validate_with_previous_doc()
		self.validate_for_subcontracting()
		self.validate_minimum_order_qty()
		self.create_raw_materials_supplied("supplied_items")
Beispiel #33
0
    def validate(self):
        super(MaterialRequest, self).validate()

        self.validate_schedule_date()
        self.check_for_on_hold_or_closed_status("Sales Order", "sales_order")
        self.validate_uom_is_integer("uom", "qty")
        self.validate_material_request_type()

        if not self.status:
            self.status = "Draft"

        from erpnext.controllers.status_updater import validate_status

        validate_status(
            self.status,
            [
                "Draft",
                "Submitted",
                "Stopped",
                "Cancelled",
                "Pending",
                "Partially Ordered",
                "Ordered",
                "Issued",
                "Transferred",
                "Received",
            ],
        )

        validate_for_items(self)

        self.set_title()
        # self.validate_qty_against_so()
        # NOTE: Since Item BOM and FG quantities are combined, using current data, it cannot be validated
        # Though the creation of Material Request from a Production Plan can be rethought to fix this

        self.reset_default_field_value("set_warehouse", "items", "warehouse")
        self.reset_default_field_value("set_from_warehouse", "items",
                                       "from_warehouse")
    def validate(self):
        self.docstatus = 1
        footprint_clock_closing = frappe.db.get_value(
            "HR Settings", None, "footprint_clock_closing")

        #if footprint_clock_closing and get_time(self.attendance_time) >= get_time(footprint_clock_closing):
        #	frappe.throw(_("Not Allowed! Footprint Clock is closed"))
        #frappe.throw( frappe.get_request_header("X-Frappe-CSRF-Token"))
        #if self.attendance_type == 'Attendance':
        #	self.departure_time = '0'
        #	self.attendance_time = time.strftime("%X")

        #elif self.attendance_type =='Departure':
        #	self.attendance_time = get_time(self.attendance_time)
        #	self.departure_time = time.strftime("%X")
        #	att = frappe.db.sql("select name from `tabAttendance` where employee = %s and attendance_date=%s and docstatus !=2 order by name desc LIMIT 1",(self.employee,self.attendance_date))
        #	if att:
        #		frappe.db.sql("update `tabAttendance` set departure_time=%s,departure_date=%s where employee = %s and attendance_date=%s and docstatus !=2",(time.strftime("%X"),getdate(nowdate()),self.employee,self.attendance_date))

        from erpnext.controllers.status_updater import validate_status
        validate_status(self.status,
                        ["Present", "Absent", "On Leave", "Half Day"])
        self.validate_duplicate_record()
        self.validate_attendance_date()
Beispiel #35
0
	def validate(self):
		from erpnext.controllers.status_updater import validate_status
		validate_status(self.status, ["Present", "Absent", "On Leave", "Half Day"])
		self.validate_attendance_date()
		self.validate_duplicate_record()
		self.check_leave_record()