mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
fix: Role to override maintain same rate check in transactions
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
"pr_required",
|
"pr_required",
|
||||||
"maintain_same_rate",
|
"maintain_same_rate",
|
||||||
"maintain_same_rate_action",
|
"maintain_same_rate_action",
|
||||||
|
"role_to_override_stop_action",
|
||||||
"allow_multiple_items",
|
"allow_multiple_items",
|
||||||
"subcontract",
|
"subcontract",
|
||||||
"backflush_raw_materials_of_subcontract_based_on",
|
"backflush_raw_materials_of_subcontract_based_on",
|
||||||
@@ -100,6 +101,13 @@
|
|||||||
"label": "Action If Same Rate is Not Maintained",
|
"label": "Action If Same Rate is Not Maintained",
|
||||||
"mandatory_depends_on": "maintain_same_rate",
|
"mandatory_depends_on": "maintain_same_rate",
|
||||||
"options": "Stop\nWarn"
|
"options": "Stop\nWarn"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.maintain_same_rate_action == 'Stop'",
|
||||||
|
"fieldname": "role_to_override_stop_action",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Role Allowed to Override Stop Action",
|
||||||
|
"options": "Role"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-cog",
|
"icon": "fa fa-cog",
|
||||||
@@ -107,7 +115,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-03-11 17:31:21.293142",
|
"modified": "2021-04-04 20:01:44.087066",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Buying Settings",
|
"name": "Buying Settings",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"sales_update_frequency",
|
"sales_update_frequency",
|
||||||
"maintain_same_sales_rate",
|
"maintain_same_sales_rate",
|
||||||
"maintain_same_rate_action",
|
"maintain_same_rate_action",
|
||||||
|
"role_to_override_stop_action",
|
||||||
"editable_price_list_rate",
|
"editable_price_list_rate",
|
||||||
"allow_multiple_items",
|
"allow_multiple_items",
|
||||||
"allow_against_multiple_purchase_orders",
|
"allow_against_multiple_purchase_orders",
|
||||||
@@ -144,6 +145,13 @@
|
|||||||
"label": "Action If Same Rate is Not Maintained",
|
"label": "Action If Same Rate is Not Maintained",
|
||||||
"mandatory_depends_on": "maintain_same_sales_rate",
|
"mandatory_depends_on": "maintain_same_sales_rate",
|
||||||
"options": "Stop\nWarn"
|
"options": "Stop\nWarn"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval: doc.maintain_same_rate_action == 'Stop'",
|
||||||
|
"fieldname": "role_to_override_stop_action",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Role Allowed to Override Stop Action",
|
||||||
|
"options": "Role"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-cog",
|
"icon": "fa fa-cog",
|
||||||
@@ -151,7 +159,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-03-11 17:43:55.584040",
|
"modified": "2021-04-04 20:18:12.814624",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Selling Settings",
|
"name": "Selling Settings",
|
||||||
|
|||||||
@@ -121,8 +121,10 @@ class TransactionBase(StatusUpdater):
|
|||||||
|
|
||||||
if self.doctype in buying_doctypes:
|
if self.doctype in buying_doctypes:
|
||||||
action = frappe.db.get_single_value("Buying Settings", "maintain_same_rate_action")
|
action = frappe.db.get_single_value("Buying Settings", "maintain_same_rate_action")
|
||||||
|
settings_doc = "Buying Settings"
|
||||||
else:
|
else:
|
||||||
action = frappe.db.get_single_value("Selling Settings", "maintain_same_rate_action")
|
action = frappe.db.get_single_value("Selling Settings", "maintain_same_rate_action")
|
||||||
|
settings_doc = "Selling Settings"
|
||||||
|
|
||||||
for ref_dt, ref_dn_field, ref_link_field in ref_details:
|
for ref_dt, ref_dn_field, ref_link_field in ref_details:
|
||||||
for d in self.get("items"):
|
for d in self.get("items"):
|
||||||
@@ -131,8 +133,11 @@ class TransactionBase(StatusUpdater):
|
|||||||
|
|
||||||
if abs(flt(d.rate - ref_rate, d.precision("rate"))) >= .01:
|
if abs(flt(d.rate - ref_rate, d.precision("rate"))) >= .01:
|
||||||
if action == "Stop":
|
if action == "Stop":
|
||||||
frappe.throw(_("Row #{0}: Rate must be same as {1}: {2} ({3} / {4})").format(
|
role_allowed_to_override = frappe.db.get_single_value(settings_doc, 'role_to_override_stop_action')
|
||||||
d.idx, ref_dt, d.get(ref_dn_field), d.rate, ref_rate))
|
|
||||||
|
if role_allowed_to_override not in frappe.get_roles():
|
||||||
|
frappe.throw(_("Row #{0}: Rate must be same as {1}: {2} ({3} / {4})").format(
|
||||||
|
d.idx, ref_dt, d.get(ref_dn_field), d.rate, ref_rate))
|
||||||
else:
|
else:
|
||||||
frappe.msgprint(_("Row #{0}: Rate must be same as {1}: {2} ({3} / {4})").format(
|
frappe.msgprint(_("Row #{0}: Rate must be same as {1}: {2} ({3} / {4})").format(
|
||||||
d.idx, ref_dt, d.get(ref_dn_field), d.rate, ref_rate), title=_("Warning"), indicator="orange")
|
d.idx, ref_dt, d.get(ref_dn_field), d.rate, ref_rate), title=_("Warning"), indicator="orange")
|
||||||
|
|||||||
Reference in New Issue
Block a user