diff --git a/frappe/core/doctype/transaction_log/transaction_log.py b/frappe/core/doctype/transaction_log/transaction_log.py index a1a6a74d77..79e1cc30ac 100644 --- a/frappe/core/doctype/transaction_log/transaction_log.py +++ b/frappe/core/doctype/transaction_log/transaction_log.py @@ -1,13 +1,14 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2018, Frappe Technologies and contributors +# Copyright (c) 2021, Frappe Technologies and contributors # License: MIT. See LICENSE +import hashlib + import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import cint, now_datetime -import hashlib from frappe.query_builder import DocType +from frappe.utils import cint, now_datetime + class TransactionLog(Document): def before_insert(self): @@ -50,7 +51,9 @@ def get_current_index(): frappe.qb.from_(series) .where(series.name == "TRANSACTLOG") .for_update() - .select("current").run()) + .select("current") + ).run() + if current and current[0][0] is not None: current = current[0][0] diff --git a/frappe/core/report/transaction_log_report/transaction_log_report.py b/frappe/core/report/transaction_log_report/transaction_log_report.py index fe391fc645..e9c68cb0c7 100644 --- a/frappe/core/report/transaction_log_report/transaction_log_report.py +++ b/frappe/core/report/transaction_log_report/transaction_log_report.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019, Frappe Technologies and contributors +# Copyright (c) 2021, Frappe Technologies and contributors # License: MIT. See LICENSE import frappe @@ -12,9 +12,9 @@ def execute(filters=None): return columns, data def get_data(filters=None): - - logs = frappe.get_all("Transaction Log", fields=["*"], order_by="creation desc") result = [] + logs = frappe.get_all("Transaction Log", fields=["*"], order_by="creation desc") + for l in logs: row_index = int(l.row_index) if row_index > 1: diff --git a/frappe/desk/doctype/tag/tag.py b/frappe/desk/doctype/tag/tag.py index e99bc6b2ee..b894a6bfbc 100644 --- a/frappe/desk/doctype/tag/tag.py +++ b/frappe/desk/doctype/tag/tag.py @@ -47,7 +47,8 @@ def get_tagged_docs(doctype, tag): return ( frappe.qb.from_(doctype) .where(doctype._user_tags.like(tag)) - .select(doctype.name).run()) + .select(doctype.name) + ).run() @frappe.whitelist() def get_tags(doctype, txt): diff --git a/frappe/model/naming.py b/frappe/model/naming.py index b602514b06..deea6698b3 100644 --- a/frappe/model/naming.py +++ b/frappe/model/naming.py @@ -201,7 +201,9 @@ def getseries(key, digits): frappe.qb.from_(series) .where(series.name == key) .for_update() - .select("current").run()) + .select("current") + ).run() + if current and current[0][0] is not None: current = current[0][0] # yes, update it @@ -272,7 +274,8 @@ def revert_series_if_last(key, name, doc=None): frappe.qb.from_(series) .where(series.name == prefix) .for_update() - .select("current").run()) + .select("current") + ).run() if current and current[0][0]==count: frappe.db.sql("UPDATE `tabSeries` SET `current` = `current` - 1 WHERE `name`=%s", prefix)