Skip to content
Open
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
16 changes: 3 additions & 13 deletions erpnext/buying/doctype/purchase_order/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import json

import frappe
from frappe import _, msgprint
from frappe import _
from frappe.desk.notifications import clear_doctype_notifications
from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
from frappe.utils import cint, cstr, flt, get_link_to_form
from frappe.utils import cint, flt, get_link_to_form

from erpnext.accounts.doctype.sales_invoice.sales_invoice import (
unlink_inter_company_doc,
Expand Down Expand Up @@ -426,18 +426,8 @@ def update_ordered_qty(self, po_item_rows=None):
for item_code, warehouse in item_wh_list:
update_bin_qty(item_code, warehouse, {"ordered_qty": get_ordered_qty(item_code, warehouse)})

def check_modified_date(self):
mod_db = frappe.db.sql("select modified from `tabPurchase Order` where name = %s", self.name)
date_diff = frappe.db.sql(f"select '{mod_db[0][0]}' - '{cstr(self.modified)}' ")

if date_diff and date_diff[0][0]:
msgprint(
_("{0} {1} has been modified. Please refresh.").format(self.doctype, self.name),
raise_exception=True,
)

def update_status(self, status):
self.check_modified_date()
self.check_if_latest()
self.set_status(update=True, status=status)
self.update_requested_qty()
self.update_ordered_qty()
Expand Down
8 changes: 1 addition & 7 deletions erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,8 @@ def check_nextdoc_docstatus(self):
)
)

def check_modified_date(self):
mod_db = frappe.db.get_value("Sales Order", self.name, "modified")
date_diff = frappe.db.sql(f"select TIMEDIFF('{mod_db}', '{cstr(self.modified)}')")
if date_diff and date_diff[0][0]:
frappe.throw(_("{0} {1} has been modified. Please refresh.").format(self.doctype, self.name))

def update_status(self, status):
self.check_modified_date()
self.check_if_latest()
self.set_status(update=True, status=status)
# Upon Sales Order Re-open, check for credit limit.
# Limit should be checked after the 'Hold/Closed' status is reset.
Expand Down
11 changes: 2 additions & 9 deletions erpnext/stock/doctype/material_request/material_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from frappe.model.mapper import get_mapped_doc
from frappe.query_builder import Order
from frappe.query_builder.functions import Sum
from frappe.utils import cint, cstr, flt, get_link_to_form, getdate, new_line_sep, nowdate
from frappe.utils import cint, flt, get_link_to_form, getdate, new_line_sep, nowdate

from erpnext.buying.utils import check_on_hold_or_closed_status, validate_for_items
from erpnext.controllers.buying_controller import BuyingController
Expand Down Expand Up @@ -249,15 +249,8 @@ def before_cancel(self):

self.set_status(update=True, status="Cancelled")

def check_modified_date(self):
mod_db = frappe.db.sql("""select modified from `tabMaterial Request` where name = %s""", self.name)
date_diff = frappe.db.sql(f"""select TIMEDIFF('{mod_db[0][0]}', '{cstr(self.modified)}')""")

if date_diff and date_diff[0][0]:
frappe.throw(_("{0} {1} has been modified. Please refresh.").format(_(self.doctype), self.name))

def update_status(self, status):
self.check_modified_date()
self.check_if_latest()
self.status_can_change(status)
self.set_status(update=True, status=status)
self.update_requested_qty()
Expand Down
Loading