Skip to content

Commit

Permalink
Merge pull request #211 from Khtah2/develop
Browse files Browse the repository at this point in the history
feat(transactions) changed the old and new employee fields from link …
  • Loading branch information
its4nas authored Jan 25, 2025
2 parents ff93711 + 0075f82 commit 2bcc194
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"actions": [],
"allow_rename": 1,
"creation": "2025-01-17 17:30:47.199845",
"default_view": "List",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"section_break_assx",
"old_employee",
"old_employee_name",
"new_employee",
"new_employee_name",
"amended_from",
"details"
],
Expand All @@ -19,17 +22,15 @@
{
"fieldname": "old_employee",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Old Employee",
"options": "User",
"options": "Employee",
"reqd": 1
},
{
"fieldname": "new_employee",
"fieldtype": "Link",
"in_list_view": 1,
"label": "New Employee",
"options": "User",
"options": "Employee",
"reqd": 1
},
{
Expand All @@ -46,12 +47,28 @@
"fieldname": "details",
"fieldtype": "Text",
"label": "Details"
},
{
"fetch_from": "old_employee.employee_name",
"fieldname": "old_employee_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Old Employee Name",
"read_only": 1
},
{
"fetch_from": "new_employee.employee_name",
"fieldname": "new_employee_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "New Employee Name",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2025-01-20 16:41:23.452407",
"modified": "2025-01-23 15:35:27.728939",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Permission Update Tool",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,26 @@ class PermissionUpdateTool(Document):
amended_from: DF.Link | None
details: DF.Text | None
new_employee: DF.Link
new_employee_name: DF.Data | None
old_employee: DF.Link
old_employee_name: DF.Data | None
# end: auto-generated types

def on_submit(self):
# Fetch the complete record for old_employee
old_employee_record = frappe.get_doc("Employee", self.old_employee)
old_employee_user_id = old_employee_record.user_id # Access the user_id field
# frappe.msgprint(f"Old Employee User ID: {old_employee_user_id}")
# Fetch the complete record for new_employee
new_employee_record = frappe.get_doc("Employee", self.new_employee)
new_employee_user_id = new_employee_record.user_id # Access the user_id field
# frappe.msgprint(f"New Employee User ID: {new_employee_user_id}")
# frappe.msgprint("on_submit triggered!")
update_user_values(
doctype_name="DocShare",
field_a="user",
condition_a_value=self.old_employee,
new_value_for_field_a=self.new_employee,
condition_a_value=old_employee_user_id,
new_value_for_field_a=new_employee_user_id,
field_b="share_doctype",
condition_b_values=[
"Transaction",
Expand All @@ -41,38 +51,38 @@ def on_submit(self):
# update_user_values(
# doctype_name="Transaction New",
# field_a="current_action_maker",
# condition_a_value=self.old_employee,
# new_value_for_field_a=self.new_employee
# condition_a_value=old_employee_user_id,
# new_value_for_field_a=new_employee_user_id
# )
# update_user_values(
# doctype_name="Transaction",
# field_a="current_action_maker",
# condition_a_value=self.old_employee,
# new_value_for_field_a=self.new_employee
# condition_a_value=old_employee_user_id,
# new_value_for_field_a=new_employee_user_id
# )
update_user_values(
doctype_name="Inbox Memo",
field_a="current_action_maker",
condition_a_value=self.old_employee,
new_value_for_field_a=self.new_employee
condition_a_value=old_employee_user_id,
new_value_for_field_a=new_employee_user_id
)
update_user_values(
doctype_name="Outbox Memo",
field_a="current_action_maker",
condition_a_value=self.old_employee,
new_value_for_field_a=self.new_employee
condition_a_value=old_employee_user_id,
new_value_for_field_a=new_employee_user_id
)
update_user_values(
doctype_name="Specific Transaction Document",
field_a="current_action_maker",
condition_a_value=self.old_employee,
new_value_for_field_a=self.new_employee
condition_a_value=old_employee_user_id,
new_value_for_field_a=new_employee_user_id
)
update_user_values(
doctype_name="Request",
field_a="current_action_maker",
condition_a_value=self.old_employee,
new_value_for_field_a=self.new_employee
condition_a_value=old_employee_user_id,
new_value_for_field_a=new_employee_user_id
)


Expand Down

0 comments on commit 2bcc194

Please sign in to comment.