-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
81 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import frappe | ||
from frappe.utils import has_common, get_fullname | ||
|
||
|
||
def create_smith_warehouse(doc, method = None): | ||
""" | ||
method to create personal warehouse for a smith user | ||
args: | ||
doc (class object): object of User | ||
""" | ||
# checking if the user has Smith roles or if the user is administrator | ||
user_roles = frappe.get_roles(doc.name) | ||
required_roles = ["Smith", "Head of Smith"] | ||
if not has_common(user_roles, required_roles) or doc.name == 'Administrator': | ||
return | ||
|
||
# generating the warehouse name | ||
user_fullname = get_fullname(doc.name) | ||
new_warehouse = frappe.new_doc("Warehouse") | ||
req_warehouse_name = f"{user_fullname} - Smith" | ||
|
||
# checking if the warehouse already exist | ||
warehouse = frappe.db.exists("Warehouse", {"email_id": doc.name, 'parent_warehouse':'All smith Warehouse - EG'}) | ||
if warehouse: | ||
warehouse_doc = frappe.get_doc("Warehouse", warehouse) | ||
# renaming the warehouse if the user's full name was changed | ||
if not warehouse_doc.warehouse_name == req_warehouse_name: | ||
warehouse_doc.warehouse_name = req_warehouse_name | ||
warehouse_doc.save() | ||
else: | ||
# creating a new warehouse | ||
new_warehouse.warehouse_name = req_warehouse_name | ||
new_warehouse.email_id = doc.name | ||
new_warehouse.parent_warehouse = 'All smith Warehouse - EG' | ||
new_warehouse.save() |
File renamed without changes.
4 changes: 3 additions & 1 deletion
4
...ms/doctype/smith_details/smith_details.js → aumms/aumms/doctype/smith/smith.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
// Copyright (c) 2023, efeone and contributors | ||
// For license information, please see license.txt | ||
|
||
frappe.ui.form.on('Smith Details', { | ||
frappe.ui.form.on('Smith', { | ||
// refresh: function(frm) { | ||
|
||
// } | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ms/doctype/smith_details/smith_details.py → aumms/aumms/doctype/smith/smith.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# Copyright (c) 2023, efeone and contributors | ||
# For license information, please see license.txt | ||
|
||
# import frappe | ||
from frappe.model.document import Document | ||
|
||
|
||
class SmithDetails(Document): | ||
pass | ||
class Smith(Document): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters