Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Head of Smith role #188

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions aumms/aumms/doctype/design_analysis/design_analysis.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"item_group",
"customer_expected_weight",
"purity",
"phone_no",
"mobile_no",
"section_break_rgobr",
"column_break_y3jbr",
"section_break_qqgnh",
Expand Down Expand Up @@ -217,14 +217,15 @@
},
{
"fetch_from": "design_request.mobile_no",
"fieldname": "phone_no",
"fetch_if_empty": 1,
"fieldname": "mobile_no",
"fieldtype": "Data",
"label": "Phone No"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-09 14:49:22.769235",
"modified": "2023-11-13 12:34:20.281981",
"modified_by": "Administrator",
"module": "AuMMS",
"name": "Design Analysis",
Expand Down
12 changes: 11 additions & 1 deletion aumms/aumms/doctype/smith/smith.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"is_head_of_smith",
"head_of_smith",
"hourly_rate",
"email",
"section_break_9mmii",
"category"
],
Expand Down Expand Up @@ -109,11 +110,20 @@
"fieldname": "is_head_of_smith",
"fieldtype": "Check",
"label": "Is Head of smith"
},
{
"fetch_from": "employee.company_email",
"fieldname": "email",
"fieldtype": "Data",
"label": "Email",
"mandatory_depends_on": "eval:doc.is_head_of_smith",
"read_only": 1,
"reqd": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-10 13:12:57.067492",
"modified": "2023-11-14 11:49:07.892640",
"modified_by": "Administrator",
"module": "AuMMS",
"name": "Smith",
Expand Down
13 changes: 13 additions & 0 deletions aumms/aumms/doctype/smith/smith.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
class Smith(Document):
def before_insert(self):
self.create_smith_warehouse()

def validate(self):
create_user_for_smith(self)

def create_smith_warehouse(self):
"""
Expand Down Expand Up @@ -85,3 +88,13 @@ def smith_reference_filter_query(doctype, txt, searchfield, start, page_len, fil
tabSmith
)
'''.format(tab_of_doctype = f'tab{doctype}', doctype = doctype.lower()))

def create_user_for_smith(doc):
if doc.email:
user = frappe.new_doc('User')
user.email = doc.email
user.first_name = doc.smith_name
user.append('roles', {'role': 'Head of Smith'})
user.save(ignore_permissions = True)
frappe.msgprint('User created for this smith', alert=True, indicator='green')

Loading