Skip to content

Commit

Permalink
Merge pull request #188 from efeone/role
Browse files Browse the repository at this point in the history
feat:Head of Smith role
  • Loading branch information
muhammadmp authored Nov 15, 2023
2 parents 34d6781 + ed9921e commit 34b4648
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
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')

0 comments on commit 34b4648

Please sign in to comment.