mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-15 07:28:39 +00:00
fix: permissions in workstation file
(cherry picked from commit cf127e8900)
# Conflicts:
# erpnext/manufacturing/doctype/workstation/workstation.py
This commit is contained in:
committed by
Mergify
parent
a7dfc55d02
commit
0fea93388d
@@ -83,7 +83,7 @@ class Workstation(Document):
|
|||||||
|
|
||||||
def before_save(self):
|
def before_save(self):
|
||||||
if self.has_value_changed("workstation_type"):
|
if self.has_value_changed("workstation_type"):
|
||||||
self.set_data_based_on_workstation_type()
|
self._set_data_based_on_workstation_type()
|
||||||
|
|
||||||
self.set_hour_rate()
|
self.set_hour_rate()
|
||||||
self.set_total_working_hours()
|
self.set_total_working_hours()
|
||||||
@@ -114,6 +114,10 @@ class Workstation(Document):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def set_data_based_on_workstation_type(self):
|
def set_data_based_on_workstation_type(self):
|
||||||
|
self.check_permission("write")
|
||||||
|
self._set_data_based_on_workstation_type()
|
||||||
|
|
||||||
|
def _set_data_based_on_workstation_type(self):
|
||||||
if self.workstation_type:
|
if self.workstation_type:
|
||||||
data = frappe.get_all(
|
data = frappe.get_all(
|
||||||
"Workstation Cost",
|
"Workstation Cost",
|
||||||
@@ -211,6 +215,8 @@ class Workstation(Document):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def start_job(self, job_card, from_time, employee):
|
def start_job(self, job_card, from_time, employee):
|
||||||
doc = frappe.get_doc("Job Card", job_card)
|
doc = frappe.get_doc("Job Card", job_card)
|
||||||
|
doc.check_permission("write")
|
||||||
|
|
||||||
doc.append("time_logs", {"from_time": from_time, "employee": employee})
|
doc.append("time_logs", {"from_time": from_time, "employee": employee})
|
||||||
doc.save(ignore_permissions=True)
|
doc.save(ignore_permissions=True)
|
||||||
|
|
||||||
@@ -219,6 +225,8 @@ class Workstation(Document):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def complete_job(self, job_card, qty, to_time):
|
def complete_job(self, job_card, qty, to_time):
|
||||||
doc = frappe.get_doc("Job Card", job_card)
|
doc = frappe.get_doc("Job Card", job_card)
|
||||||
|
doc.check_permission("submit")
|
||||||
|
|
||||||
for row in doc.time_logs:
|
for row in doc.time_logs:
|
||||||
if not row.to_time:
|
if not row.to_time:
|
||||||
row.to_time = to_time
|
row.to_time = to_time
|
||||||
@@ -316,7 +324,13 @@ def get_status_color(status):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
<<<<<<< HEAD
|
||||||
def get_raw_materials(job_card):
|
def get_raw_materials(job_card):
|
||||||
|
=======
|
||||||
|
def get_raw_materials(job_card: str):
|
||||||
|
frappe.has_permission("Job Card", "read", doc=job_card, throw=True)
|
||||||
|
|
||||||
|
>>>>>>> cf127e8900 (fix: permissions in workstation file)
|
||||||
raw_materials = frappe.get_all(
|
raw_materials = frappe.get_all(
|
||||||
"Job Card",
|
"Job Card",
|
||||||
fields=[
|
fields=[
|
||||||
@@ -460,6 +474,8 @@ def check_workstation_for_holiday(workstation, from_datetime, to_datetime):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_workstations(**kwargs):
|
def get_workstations(**kwargs):
|
||||||
|
frappe.has_permission("Workstation", "read", throw=True)
|
||||||
|
|
||||||
kwargs = frappe._dict(kwargs)
|
kwargs = frappe._dict(kwargs)
|
||||||
_workstation = frappe.qb.DocType("Workstation")
|
_workstation = frappe.qb.DocType("Workstation")
|
||||||
|
|
||||||
@@ -535,13 +551,8 @@ def update_job_card(job_card: str, method: str, **kwargs):
|
|||||||
title=_("Not Allowed"),
|
title=_("Not Allowed"),
|
||||||
)
|
)
|
||||||
|
|
||||||
frappe.has_permission("Job Card", "read", throw=True)
|
|
||||||
|
|
||||||
doc = frappe.get_doc("Job Card", job_card)
|
doc = frappe.get_doc("Job Card", job_card)
|
||||||
|
doc.check_permission("write")
|
||||||
# These methods mutate the Job Card, but frappe.get_doc does not enforce permissions —
|
|
||||||
# require write access before running anything.
|
|
||||||
frappe.has_permission("Job Card", "write", doc=doc, throw=True)
|
|
||||||
|
|
||||||
if isinstance(kwargs, dict):
|
if isinstance(kwargs, dict):
|
||||||
kwargs = frappe._dict(kwargs)
|
kwargs = frappe._dict(kwargs)
|
||||||
@@ -556,7 +567,13 @@ def update_job_card(job_card: str, method: str, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
<<<<<<< HEAD
|
||||||
def validate_job_card(job_card, status):
|
def validate_job_card(job_card, status):
|
||||||
|
=======
|
||||||
|
def validate_job_card(job_card: str, status: str):
|
||||||
|
frappe.has_permission("Job Card", "read", doc=job_card, throw=True)
|
||||||
|
|
||||||
|
>>>>>>> cf127e8900 (fix: permissions in workstation file)
|
||||||
job_card_details = frappe.db.get_value("Job Card", job_card, ["status", "for_quantity"], as_dict=1)
|
job_card_details = frappe.db.get_value("Job Card", job_card, ["status", "for_quantity"], as_dict=1)
|
||||||
|
|
||||||
current_status = job_card_details.status
|
current_status = job_card_details.status
|
||||||
|
|||||||
Reference in New Issue
Block a user