a3ea985348
I just applied semgrep autofix. Untested completed, review before merging. ```yaml - id: frappe-set-value-semantics patterns: - pattern-either: - pattern: frappe.db.set_value($DOCTYPE, None, $...AFTER) - pattern: frappe.db.set_value($DOCTYPE, $DOCTYPE, $...AFTER) fix: frappe.db.set_single_value($DOCTYPE, $...AFTER) message: | If $DOCTYPE is a single doctype then using `frappe.db.set_value` is discouraged for setting values in DB. Use db.set_single_value for single doctype instead. languages: [python] severity: ERROR ```
12 lines
388 B
Python
12 lines
388 B
Python
import frappe
|
|
|
|
|
|
def execute():
|
|
data = frappe.db.sql(
|
|
'select value from tabSingles where doctype="Accounts Settings" and field="enable_discount_accounting"'
|
|
)
|
|
discount_account = data and int(data[0][0]) or 0
|
|
if discount_account:
|
|
for doctype in ["Buying Settings", "Selling Settings"]:
|
|
frappe.db.set_single_value(doctype, "enable_discount_accounting", 1, update_modified=False)
|