Merge pull request #14171 from rohitwaghchaure/fixed_patch_v11_salary_structure_assignment
[Fix] Patch
This commit is contained in:
commit
b1036e5582
@ -8,6 +8,8 @@ from frappe import _
|
|||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class DuplicateAssignment(frappe.ValidationError): pass
|
||||||
|
|
||||||
class SalaryStructureAssignment(Document):
|
class SalaryStructureAssignment(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_dates()
|
self.validate_dates()
|
||||||
@ -56,7 +58,8 @@ class SalaryStructureAssignment(Document):
|
|||||||
})
|
})
|
||||||
|
|
||||||
if assignment:
|
if assignment:
|
||||||
frappe.throw(_("Active Salary Structure Assignment {0} found for employee {1} for the given dates").format(assignment[0][0], self.employee))
|
frappe.throw(_("Active Salary Structure Assignment {0} found for employee {1} for the given dates").
|
||||||
|
format(assignment[0][0], self.employee), DuplicateAssignment)
|
||||||
|
|
||||||
def get_assigned_salary_structure(employee, on_date):
|
def get_assigned_salary_structure(employee, on_date):
|
||||||
if not employee or not on_date:
|
if not employee or not on_date:
|
||||||
|
@ -4,12 +4,14 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from erpnext.hr.doctype.salary_structure_assignment.salary_structure_assignment import DuplicateAssignment
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.reload_doc("hr", "doctype", "salary_structure_assignment")
|
frappe.reload_doc("hr", "doctype", "salary_structure_assignment")
|
||||||
for d in frappe.db.sql("""
|
for d in frappe.db.sql("""
|
||||||
select sse.*, ss.company from `tabSalary Structure Employee` sse, `tabSalary Structure` ss
|
select sse.*, ss.company from `tabSalary Structure Employee` sse, `tabSalary Structure` ss
|
||||||
where ss.name = sse.parent AND sse.employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')""", as_dict=1):
|
where ss.name = sse.parent AND sse.employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')""", as_dict=1):
|
||||||
|
try:
|
||||||
s = frappe.new_doc("Salary Structure Assignment")
|
s = frappe.new_doc("Salary Structure Assignment")
|
||||||
s.employee = d.employee
|
s.employee = d.employee
|
||||||
s.employee_name = d.employee_name
|
s.employee_name = d.employee_name
|
||||||
@ -23,5 +25,7 @@ def execute():
|
|||||||
# to migrate the data of the old employees
|
# to migrate the data of the old employees
|
||||||
s.flags.old_employee = True
|
s.flags.old_employee = True
|
||||||
s.save()
|
s.save()
|
||||||
|
except DuplicateAssignment:
|
||||||
|
pass
|
||||||
|
|
||||||
frappe.db.sql("update `tabSalary Structure` set docstatus=1")
|
frappe.db.sql("update `tabSalary Structure` set docstatus=1")
|
Loading…
x
Reference in New Issue
Block a user