Merge pull request #24991 from rohitwaghchaure/repost-not-completed-transactions-pre
fix: repost not completed backdated transactions
This commit is contained in:
commit
3c490088c4
@ -320,6 +320,7 @@ scheduler_events = {
|
|||||||
"erpnext.hr.doctype.shift_type.shift_type.process_auto_attendance_for_all_shifts",
|
"erpnext.hr.doctype.shift_type.shift_type.process_auto_attendance_for_all_shifts",
|
||||||
"erpnext.support.doctype.issue.issue.set_service_level_agreement_variance",
|
"erpnext.support.doctype.issue.issue.set_service_level_agreement_variance",
|
||||||
"erpnext.erpnext_integrations.connectors.shopify_connection.sync_old_orders",
|
"erpnext.erpnext_integrations.connectors.shopify_connection.sync_old_orders",
|
||||||
|
"erpnext.stock.doctype.repost_item_valuation.repost_item_valuation.repost_entries"
|
||||||
],
|
],
|
||||||
"daily": [
|
"daily": [
|
||||||
"erpnext.stock.reorder_item.reorder_item",
|
"erpnext.stock.reorder_item.reorder_item",
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe, erpnext
|
import frappe, erpnext
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import cint, get_link_to_form
|
from frappe.utils import cint, get_link_to_form, add_to_date, today
|
||||||
from erpnext.stock.stock_ledger import repost_future_sle
|
from erpnext.stock.stock_ledger import repost_future_sle
|
||||||
from erpnext.accounts.utils import update_gl_entries_after, check_if_stock_and_account_balance_synced
|
from erpnext.accounts.utils import update_gl_entries_after, check_if_stock_and_account_balance_synced
|
||||||
from frappe.utils.user import get_users_with_role
|
from frappe.utils.user import get_users_with_role
|
||||||
@ -29,7 +29,7 @@ class RepostItemValuation(Document):
|
|||||||
self.company = frappe.get_cached_value(self.voucher_type, self.voucher_no, "company")
|
self.company = frappe.get_cached_value(self.voucher_type, self.voucher_no, "company")
|
||||||
elif self.warehouse:
|
elif self.warehouse:
|
||||||
self.company = frappe.get_cached_value("Warehouse", self.warehouse, "company")
|
self.company = frappe.get_cached_value("Warehouse", self.warehouse, "company")
|
||||||
|
|
||||||
def set_status(self, status=None):
|
def set_status(self, status=None):
|
||||||
if not status:
|
if not status:
|
||||||
status = 'Queued'
|
status = 'Queued'
|
||||||
@ -54,7 +54,6 @@ def repost(doc):
|
|||||||
|
|
||||||
repost_sl_entries(doc)
|
repost_sl_entries(doc)
|
||||||
repost_gl_entries(doc)
|
repost_gl_entries(doc)
|
||||||
check_if_stock_and_account_balance_synced(doc.posting_date, doc.company)
|
|
||||||
|
|
||||||
doc.set_status('Completed')
|
doc.set_status('Completed')
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -103,7 +102,7 @@ def notify_error_to_stock_managers(doc, traceback):
|
|||||||
recipients = get_users_with_role("Stock Manager")
|
recipients = get_users_with_role("Stock Manager")
|
||||||
if not recipients:
|
if not recipients:
|
||||||
get_users_with_role("System Manager")
|
get_users_with_role("System Manager")
|
||||||
|
|
||||||
subject = _("Error while reposting item valuation")
|
subject = _("Error while reposting item valuation")
|
||||||
message = (_("Hi,") + "<br>"
|
message = (_("Hi,") + "<br>"
|
||||||
+ _("An error has been appeared while reposting item valuation via {0}")
|
+ _("An error has been appeared while reposting item valuation via {0}")
|
||||||
@ -112,4 +111,24 @@ def notify_error_to_stock_managers(doc, traceback):
|
|||||||
)
|
)
|
||||||
frappe.sendmail(recipients=recipients, subject=subject, message=message)
|
frappe.sendmail(recipients=recipients, subject=subject, message=message)
|
||||||
|
|
||||||
|
def repost_entries():
|
||||||
|
riv_entries = get_repost_item_valuation_entries()
|
||||||
|
|
||||||
|
for row in riv_entries:
|
||||||
|
doc = frappe.get_cached_doc('Repost Item Valuation', row.name)
|
||||||
|
repost(doc)
|
||||||
|
|
||||||
|
riv_entries = get_repost_item_valuation_entries()
|
||||||
|
if riv_entries:
|
||||||
|
return
|
||||||
|
|
||||||
|
for d in frappe.get_all('Company', filters= {'enable_perpetual_inventory': 1}):
|
||||||
|
check_if_stock_and_account_balance_synced(today(), d.company)
|
||||||
|
|
||||||
|
def get_repost_item_valuation_entries():
|
||||||
|
date = add_to_date(today(), hours=-12)
|
||||||
|
|
||||||
|
return frappe.db.sql(""" SELECT name from `tabRepost Item Valuation`
|
||||||
|
WHERE status != 'Completed' and creation <= %s and docstatus = 1
|
||||||
|
ORDER BY timestamp(posting_date, posting_time) asc, creation asc
|
||||||
|
""", date, as_dict=1)
|
||||||
Loading…
x
Reference in New Issue
Block a user