diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py index c3e23fe6e50..be723915951 100644 --- a/erpnext/accounts/deferred_revenue.py +++ b/erpnext/accounts/deferred_revenue.py @@ -450,12 +450,14 @@ def process_deferred_accounting(posting_date=None): for company in companies: for record_type in ("Income", "Expense"): doc = frappe.get_doc( - doctype="Process Deferred Accounting", - company=company.name, - posting_date=posting_date, - start_date=start_date, - end_date=end_date, - type=record_type, + dict( + doctype="Process Deferred Accounting", + company=company.name, + posting_date=posting_date, + start_date=start_date, + end_date=end_date, + type=record_type, + ) ) doc.insert() diff --git a/erpnext/accounts/doctype/account/test_account.py b/erpnext/accounts/doctype/account/test_account.py index 6deff1ac3e6..795ee006806 100644 --- a/erpnext/accounts/doctype/account/test_account.py +++ b/erpnext/accounts/doctype/account/test_account.py @@ -415,13 +415,15 @@ def create_account(**kwargs): return account.name else: account = frappe.get_doc( - doctype="Account", - is_group=kwargs.get("is_group", 0), - account_name=kwargs.get("account_name"), - account_type=kwargs.get("account_type"), - parent_account=kwargs.get("parent_account"), - company=kwargs.get("company"), - account_currency=kwargs.get("account_currency"), + dict( + doctype="Account", + is_group=kwargs.get("is_group", 0), + account_name=kwargs.get("account_name"), + account_type=kwargs.get("account_type"), + parent_account=kwargs.get("parent_account"), + company=kwargs.get("company"), + account_currency=kwargs.get("account_currency"), + ) ) account.save() diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index 3020e4e6659..4da7e2828e4 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -182,7 +182,7 @@ frappe.ui.form.on("Payment Entry", { "Dunning", ]; - if (party_type_doctypes.includes(child.reference_doctype)) { + if (in_list(party_type_doctypes, child.reference_doctype)) { filters[doc.party_type.toLowerCase()] = doc.party; } @@ -1041,7 +1041,7 @@ frappe.ui.form.on("Payment Entry", { c.allocated_amount = d.allocated_amount; c.account = d.account; - if (!frm.events.get_order_doctypes(frm).includes(d.voucher_type)) { + if (!in_list(frm.events.get_order_doctypes(frm), d.voucher_type)) { if (flt(d.outstanding_amount) > 0) total_positive_outstanding += flt(d.outstanding_amount); else total_negative_outstanding += Math.abs(flt(d.outstanding_amount)); @@ -1057,7 +1057,7 @@ frappe.ui.form.on("Payment Entry", { } else { c.exchange_rate = 1; } - if (frm.events.get_invoice_doctypes(frm).includes(d.reference_doctype)) { + if (in_list(frm.events.get_invoice_doctypes(frm), d.reference_doctype)) { c.due_date = d.due_date; } }); diff --git a/erpnext/accounts/doctype/payment_order/test_payment_order.py b/erpnext/accounts/doctype/payment_order/test_payment_order.py index f12491fdf15..a261bc6b0b8 100644 --- a/erpnext/accounts/doctype/payment_order/test_payment_order.py +++ b/erpnext/accounts/doctype/payment_order/test_payment_order.py @@ -50,10 +50,12 @@ class TestPaymentOrder(IntegrationTestCase): def create_payment_order_against_payment_entry(ref_doc, order_type, bank_account): payment_order = frappe.get_doc( - doctype="Payment Order", - company="_Test Company", - payment_order_type=order_type, - company_bank_account=bank_account, + dict( + doctype="Payment Order", + company="_Test Company", + payment_order_type=order_type, + company_bank_account=bank_account, + ) ) doc = make_payment_order(ref_doc.name, payment_order) doc.save() diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js index 7cce98f3323..fda519e0851 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js @@ -171,7 +171,7 @@ frappe.ui.form.on("Pricing Rule", { set_field_options("applicable_for", options.join("\n")); - if (!options.includes(applicable_for)) applicable_for = null; + if (!in_list(options, applicable_for)) applicable_for = null; frm.set_value("applicable_for", applicable_for); }, }); diff --git a/erpnext/accounts/doctype/process_deferred_accounting/test_process_deferred_accounting.py b/erpnext/accounts/doctype/process_deferred_accounting/test_process_deferred_accounting.py index 8d35b7fcf85..b987d1579e8 100644 --- a/erpnext/accounts/doctype/process_deferred_accounting/test_process_deferred_accounting.py +++ b/erpnext/accounts/doctype/process_deferred_accounting/test_process_deferred_accounting.py @@ -48,11 +48,13 @@ class TestProcessDeferredAccounting(IntegrationTestCase): check_gl_entries(self, si.name, original_gle, "2023-07-01") process_deferred_accounting = frappe.get_doc( - doctype="Process Deferred Accounting", - posting_date="2023-07-01", - start_date="2023-05-01", - end_date="2023-06-30", - type="Income", + dict( + doctype="Process Deferred Accounting", + posting_date="2023-07-01", + start_date="2023-05-01", + end_date="2023-06-30", + type="Income", + ) ) process_deferred_accounting.insert() @@ -78,11 +80,13 @@ class TestProcessDeferredAccounting(IntegrationTestCase): def test_pda_submission_and_cancellation(self): pda = frappe.get_doc( - doctype="Process Deferred Accounting", - posting_date="2019-01-01", - start_date="2019-01-01", - end_date="2019-01-31", - type="Income", + dict( + doctype="Process Deferred Accounting", + posting_date="2019-01-01", + start_date="2019-01-01", + end_date="2019-01-31", + type="Income", + ) ) pda.submit() pda.cancel() diff --git a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.js b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.js index 920b9a99eac..43261e4080a 100644 --- a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.js +++ b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.js @@ -46,7 +46,7 @@ frappe.ui.form.on("Promotional Scheme", { set_field_options("applicable_for", options.join("\n")); - if (!options.includes(applicable_for)) applicable_for = null; + if (!in_list(options, applicable_for)) applicable_for = null; frm.set_value("applicable_for", applicable_for); }, diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index adb11f8d615..9392a0e3220 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -1249,12 +1249,14 @@ class TestPurchaseInvoice(IntegrationTestCase, StockTestMixin): pi.submit() pda1 = frappe.get_doc( - doctype="Process Deferred Accounting", - posting_date=nowdate(), - start_date="2019-01-01", - end_date="2019-03-31", - type="Expense", - company="_Test Company", + dict( + doctype="Process Deferred Accounting", + posting_date=nowdate(), + start_date="2019-01-01", + end_date="2019-03-31", + type="Expense", + company="_Test Company", + ) ) pda1.insert() diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 67dae79d083..1b98556f0c6 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2510,12 +2510,14 @@ class TestSalesInvoice(ERPNextTestSuite): si.submit() pda1 = frappe.get_doc( - doctype="Process Deferred Accounting", - posting_date=nowdate(), - start_date="2019-01-01", - end_date="2019-03-31", - type="Income", - company="_Test Company", + dict( + doctype="Process Deferred Accounting", + posting_date=nowdate(), + start_date="2019-01-01", + end_date="2019-03-31", + type="Income", + company="_Test Company", + ) ) pda1.insert() @@ -2566,12 +2568,14 @@ class TestSalesInvoice(ERPNextTestSuite): si.submit() pda1 = frappe.get_doc( - doctype="Process Deferred Accounting", - posting_date="2019-03-31", - start_date="2019-01-01", - end_date="2019-03-31", - type="Income", - company="_Test Company", + dict( + doctype="Process Deferred Accounting", + posting_date="2019-03-31", + start_date="2019-01-01", + end_date="2019-03-31", + type="Income", + company="_Test Company", + ) ) pda1.insert() @@ -3474,12 +3478,14 @@ class TestSalesInvoice(ERPNextTestSuite): frappe.db.set_value("Company", "_Test Company", "accounts_frozen_till_date", getdate("2019-01-31")) pda1 = frappe.get_doc( - doctype="Process Deferred Accounting", - posting_date=nowdate(), - start_date="2019-01-01", - end_date="2019-03-31", - type="Income", - company="_Test Company", + dict( + doctype="Process Deferred Accounting", + posting_date=nowdate(), + start_date="2019-01-01", + end_date="2019-03-31", + type="Income", + company="_Test Company", + ) ) pda1.insert() diff --git a/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py b/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py index fcd9075a30f..d918a936091 100644 --- a/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py +++ b/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py @@ -101,12 +101,14 @@ class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin): si.submit() pda = frappe.get_doc( - doctype="Process Deferred Accounting", - posting_date=nowdate(), - start_date="2021-05-01", - end_date="2021-08-01", - type="Income", - company=self.company, + dict( + doctype="Process Deferred Accounting", + posting_date=nowdate(), + start_date="2021-05-01", + end_date="2021-08-01", + type="Income", + company=self.company, + ) ) pda.insert() pda.submit() @@ -171,12 +173,14 @@ class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin): pi.submit() pda = frappe.get_doc( - doctype="Process Deferred Accounting", - posting_date=nowdate(), - start_date="2021-05-01", - end_date="2021-08-01", - type="Expense", - company=self.company, + dict( + doctype="Process Deferred Accounting", + posting_date=nowdate(), + start_date="2021-05-01", + end_date="2021-08-01", + type="Expense", + company=self.company, + ) ) pda.insert() pda.submit() @@ -236,12 +240,14 @@ class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin): si.submit() pda = frappe.get_doc( - doctype="Process Deferred Accounting", - posting_date=nowdate(), - start_date="2021-05-01", - end_date="2021-08-01", - type="Income", - company=self.company, + dict( + doctype="Process Deferred Accounting", + posting_date=nowdate(), + start_date="2021-05-01", + end_date="2021-08-01", + type="Income", + company=self.company, + ) ) pda.insert() pda.submit() diff --git a/erpnext/buying/doctype/supplier/test_supplier.py b/erpnext/buying/doctype/supplier/test_supplier.py index f3f0ede3e17..b6a8c7b288c 100644 --- a/erpnext/buying/doctype/supplier/test_supplier.py +++ b/erpnext/buying/doctype/supplier/test_supplier.py @@ -131,14 +131,16 @@ class TestSupplier(IntegrationTestCase): self.assertEqual(details.tax_category, "_Test Tax Category 1") address = frappe.get_doc( - doctype="Address", - address_title="_Test Address With Tax Category", - tax_category="_Test Tax Category 2", - address_type="Billing", - address_line1="Station Road", - city="_Test City", - country="India", - links=[dict(link_doctype="Supplier", link_name="_Test Supplier With Tax Category")], + dict( + doctype="Address", + address_title="_Test Address With Tax Category", + tax_category="_Test Tax Category 2", + address_type="Billing", + address_line1="Station Road", + city="_Test City", + country="India", + links=[dict(link_doctype="Supplier", link_name="_Test Supplier With Tax Category")], + ) ).insert() # Tax Category with Address diff --git a/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.js b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.js index 90d9d6a0412..2651023639e 100644 --- a/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.js +++ b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.js @@ -97,7 +97,7 @@ frappe.query_reports["Purchase Order Analysis"] = { value = default_formatter(value, row, column, data); let format_fields = ["received_qty", "billed_amount"]; - if (format_fields.includes(column.fieldname) && data && data[column.fieldname] > 0) { + if (in_list(format_fields, column.fieldname) && data && data[column.fieldname] > 0) { value = "" + value + ""; } return value; diff --git a/erpnext/patches/v11_0/update_sales_partner_type.py b/erpnext/patches/v11_0/update_sales_partner_type.py index 75c28613a53..ced77d97276 100644 --- a/erpnext/patches/v11_0/update_sales_partner_type.py +++ b/erpnext/patches/v11_0/update_sales_partner_type.py @@ -30,4 +30,4 @@ def execute(): def insert_sales_partner_type(s): if not frappe.db.exists("Sales Partner Type", s): - frappe.get_doc(doctype="Sales Partner Type", sales_partner_type=s).insert() + frappe.get_doc(dict(doctype="Sales Partner Type", sales_partner_type=s)).insert() diff --git a/erpnext/patches/v13_0/update_project_template_tasks.py b/erpnext/patches/v13_0/update_project_template_tasks.py index 4ba8f853a9e..c9a23222424 100644 --- a/erpnext/patches/v13_0/update_project_template_tasks.py +++ b/erpnext/patches/v13_0/update_project_template_tasks.py @@ -30,13 +30,15 @@ def execute(): if task.subject: replace_tasks = True new_task = frappe.get_doc( - doctype="Task", - subject=task.subject, - start=task.start, - duration=task.duration, - task_weight=task.task_weight, - description=task.description, - is_template=1, + dict( + doctype="Task", + subject=task.subject, + start=task.start, + duration=task.duration, + task_weight=task.task_weight, + description=task.description, + is_template=1, + ) ).insert() new_tasks.append(new_task) diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index c7023dd9423..13da8d10774 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -127,20 +127,22 @@ class Project(Document): def create_task_from_template(self, task_details): return frappe.get_doc( - doctype="Task", - subject=task_details.subject, - project=self.name, - status="Open", - exp_start_date=self.calculate_start_date(task_details), - exp_end_date=self.calculate_end_date(task_details), - description=task_details.description, - task_weight=task_details.task_weight, - type=task_details.type, - issue=task_details.issue, - is_group=task_details.is_group, - color=task_details.color, - template_task=task_details.name, - priority=task_details.priority, + dict( + doctype="Task", + subject=task_details.subject, + project=self.name, + status="Open", + exp_start_date=self.calculate_start_date(task_details), + exp_end_date=self.calculate_end_date(task_details), + description=task_details.description, + task_weight=task_details.task_weight, + type=task_details.type, + issue=task_details.issue, + is_group=task_details.is_group, + color=task_details.color, + template_task=task_details.name, + priority=task_details.priority, + ) ).insert() def calculate_start_date(self, task_details): diff --git a/erpnext/projects/doctype/project/test_project.py b/erpnext/projects/doctype/project/test_project.py index 2f1974ee4cb..5d353a3cdbd 100644 --- a/erpnext/projects/doctype/project/test_project.py +++ b/erpnext/projects/doctype/project/test_project.py @@ -255,12 +255,14 @@ class TestProject(ERPNextTestSuite): def get_project(name, template): project = frappe.get_doc( - doctype="Project", - project_name=name, - status="Open", - project_template=template.name, - expected_start_date=nowdate(), - company="_Test Company", + dict( + doctype="Project", + project_name=name, + status="Open", + project_template=template.name, + expected_start_date=nowdate(), + company="_Test Company", + ) ).insert() return project @@ -273,11 +275,13 @@ def make_project(args): return frappe.get_doc("Project", {"project_name": args.project_name}) project = frappe.get_doc( - doctype="Project", - project_name=args.project_name, - status="Open", - expected_start_date=args.start_date, - company=args.company or "_Test Company", + dict( + doctype="Project", + project_name=args.project_name, + status="Open", + expected_start_date=args.start_date, + company=args.company or "_Test Company", + ) ) if args.project_template_name: diff --git a/erpnext/projects/doctype/project_template/test_project_template.py b/erpnext/projects/doctype/project_template/test_project_template.py index 2671d7a02ec..7d94e5226ca 100644 --- a/erpnext/projects/doctype/project_template/test_project_template.py +++ b/erpnext/projects/doctype/project_template/test_project_template.py @@ -20,7 +20,7 @@ def make_project_template(project_template_name, project_tasks=None): create_task(subject="_Test Template Task 1", is_template=1, begin=0, duration=3), create_task(subject="_Test Template Task 2", is_template=1, begin=0, duration=2), ] - doc = frappe.get_doc(doctype="Project Template", name=project_template_name) + doc = frappe.get_doc(dict(doctype="Project Template", name=project_template_name)) for task in project_tasks: doc.append("tasks", {"task": task.name}) doc.insert() diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 87ec985ad18..855dbfe67e9 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -1106,7 +1106,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { var payment_types = $.map(this.frm.doc.payments, function (d) { return d.type; }); - if (payment_types.includes("Cash")) { + if (in_list(payment_types, "Cash")) { var grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total; var base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total; diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 0ea2bac6591..fb782b12e0e 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -904,7 +904,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe get_incoming_rate(item, posting_date, posting_time, voucher_type, company) { let item_args = { item_code: item.item_code, - warehouse: "Purchase Receipt".includes("Purchase Invoice") ? item.from_warehouse : item.warehouse, + warehouse: in_list("Purchase Receipt", "Purchase Invoice") ? item.from_warehouse : item.warehouse, posting_date: posting_date, posting_time: posting_time, qty: item.qty * item.conversion_factor, @@ -2248,7 +2248,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe child.apply_rule_on_other_items && JSON.parse(child.apply_rule_on_other_items).length ) { - if (!JSON.parse(child.apply_rule_on_other_items).includes(child.item_code)) { + if (!in_list(JSON.parse(child.apply_rule_on_other_items), child.item_code)) { continue; } } @@ -2296,7 +2296,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe if (JSON.parse(data.apply_rule_on_other_items).includes(d[data.apply_rule_on])) { for (var k in data) { if ( - fields.includes(k) && + in_list(fields, k) && data[k] && (data.price_or_product_discount === "Price" || k === "pricing_rules") ) { @@ -2768,7 +2768,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } has_discount_in_schedule() { - let is_eligible = ["Sales Order", "Sales Invoice", "Purchase Order", "Purchase Invoice"].includes( + let is_eligible = in_list( + ["Sales Order", "Sales Invoice", "Purchase Order", "Purchase Invoice"], this.frm.doctype ); let has_payment_schedule = this.frm.doc.payment_schedule && this.frm.doc.payment_schedule.length; @@ -3204,13 +3205,16 @@ erpnext.show_serial_batch_selector = function (frm, item_row, callback, on_close } if ( - [ - "Material Transfer", - "Send to Subcontractor", - "Material Issue", - "Material Consumption for Manufacture", - "Material Transfer for Manufacture", - ].includes(frm.doc.purpose) + in_list( + [ + "Material Transfer", + "Send to Subcontractor", + "Material Issue", + "Material Consumption for Manufacture", + "Material Transfer for Manufacture", + ], + frm.doc.purpose + ) ) { warehouse_field = "s_warehouse"; } else { diff --git a/erpnext/public/js/utils/barcode_scanner.js b/erpnext/public/js/utils/barcode_scanner.js index 2e580f83c18..822a9902a38 100644 --- a/erpnext/public/js/utils/barcode_scanner.js +++ b/erpnext/public/js/utils/barcode_scanner.js @@ -338,7 +338,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { ? this.dialog.get_value("serial_no").split("\n") : []; - if (serial_nos.includes(serial_no)) { + if (in_list(serial_nos, serial_no)) { frappe.throw(__("Serial No {0} already scanned", [serial_no])); } } @@ -359,7 +359,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { ]; for (let key in prev_row) { - if (ignore_fields.includes(key)) { + if (in_list(ignore_fields, key)) { continue; } diff --git a/erpnext/public/js/utils/party.js b/erpnext/public/js/utils/party.js index d86296f1eea..fcd6c05e4ac 100644 --- a/erpnext/public/js/utils/party.js +++ b/erpnext/public/js/utils/party.js @@ -36,14 +36,14 @@ erpnext.utils.get_party_details = function (frm, method, args, callback) { } if (!args) { - if (SALES_DOCTYPES.includes(frm.doc.doctype)) { + if (in_list(SALES_DOCTYPES, frm.doc.doctype)) { args = { party: frm.doc.customer || frm.doc.party_name, party_type: "Customer", }; } - if (PURCHASE_DOCTYPES.includes(frm.doc.doctype)) { + if (in_list(PURCHASE_DOCTYPES, frm.doc.doctype)) { args = { party: frm.doc.supplier, party_type: "Supplier", @@ -57,13 +57,13 @@ erpnext.utils.get_party_details = function (frm, method, args, callback) { args.fetch_payment_terms_template = cint(!frm.doc.ignore_default_payment_terms_template); } - if (SALES_DOCTYPES.includes(frm.doc.doctype)) { + if (in_list(SALES_DOCTYPES, frm.doc.doctype)) { if (!args.company_address && frm.doc.company_address) { args.company_address = frm.doc.company_address; } } - if (PURCHASE_DOCTYPES.includes(frm.doc.doctype)) { + if (in_list(PURCHASE_DOCTYPES, frm.doc.doctype)) { if (!args.company_address && frm.doc.billing_address) { args.company_address = frm.doc.billing_address; } diff --git a/erpnext/quality_management/doctype/quality_feedback/test_quality_feedback.py b/erpnext/quality_management/doctype/quality_feedback/test_quality_feedback.py index 35a326ad943..7baf908b3df 100644 --- a/erpnext/quality_management/doctype/quality_feedback/test_quality_feedback.py +++ b/erpnext/quality_management/doctype/quality_feedback/test_quality_feedback.py @@ -9,16 +9,20 @@ from frappe.tests import IntegrationTestCase class TestQualityFeedback(IntegrationTestCase): def test_quality_feedback(self): template = frappe.get_doc( - doctype="Quality Feedback Template", - template="Test Template", - parameters=[dict(parameter="Test Parameter 1"), dict(parameter="Test Parameter 2")], + dict( + doctype="Quality Feedback Template", + template="Test Template", + parameters=[dict(parameter="Test Parameter 1"), dict(parameter="Test Parameter 2")], + ) ).insert() feedback = frappe.get_doc( - doctype="Quality Feedback", - template=template.name, - document_type="User", - document_name=frappe.session.user, + dict( + doctype="Quality Feedback", + template=template.name, + document_type="User", + document_name=frappe.session.user, + ) ).insert() self.assertEqual(template.parameters[0].parameter, feedback.parameters[0].parameter) diff --git a/erpnext/quality_management/doctype/quality_goal/test_quality_goal.py b/erpnext/quality_management/doctype/quality_goal/test_quality_goal.py index 57d0a94ed0a..1b3727500b3 100644 --- a/erpnext/quality_management/doctype/quality_goal/test_quality_goal.py +++ b/erpnext/quality_management/doctype/quality_goal/test_quality_goal.py @@ -16,8 +16,10 @@ class TestQualityGoal(IntegrationTestCase): def get_quality_goal(): return frappe.get_doc( - doctype="Quality Goal", - goal="Test Quality Module", - frequency="Daily", - objectives=[dict(objective="Check test cases", target="100", uom="Percent")], + dict( + doctype="Quality Goal", + goal="Test Quality Module", + frequency="Daily", + objectives=[dict(objective="Check test cases", target="100", uom="Percent")], + ) ).insert() diff --git a/erpnext/regional/address_template/setup.py b/erpnext/regional/address_template/setup.py index 793767e0a90..684c76620a4 100644 --- a/erpnext/regional/address_template/setup.py +++ b/erpnext/regional/address_template/setup.py @@ -50,5 +50,5 @@ def update_address_template(country, html, is_default=0): frappe.db.set_value("Address Template", country, "is_default", is_default) else: frappe.get_doc( - doctype="Address Template", country=country, is_default=is_default, template=html + dict(doctype="Address Template", country=country, is_default=is_default, template=html) ).insert() diff --git a/erpnext/regional/italy/setup.py b/erpnext/regional/italy/setup.py index 9f9115ca12d..b0296c948de 100644 --- a/erpnext/regional/italy/setup.py +++ b/erpnext/regional/italy/setup.py @@ -470,9 +470,11 @@ def setup_report(): if not frappe.db.get_value("Custom Role", dict(report=report_name)): frappe.get_doc( - doctype="Custom Role", - report=report_name, - roles=[dict(role="Accounts User"), dict(role="Accounts Manager")], + dict( + doctype="Custom Role", + report=report_name, + roles=[dict(role="Accounts User"), dict(role="Accounts Manager")], + ) ).insert() diff --git a/erpnext/regional/south_africa/setup.py b/erpnext/regional/south_africa/setup.py index 3c9f492edfc..289f2726e9b 100644 --- a/erpnext/regional/south_africa/setup.py +++ b/erpnext/regional/south_africa/setup.py @@ -50,7 +50,9 @@ def add_permissions(): if not frappe.db.get_value("Custom Role", dict(report="VAT Audit Report")): frappe.get_doc( - doctype="Custom Role", - report="VAT Audit Report", - roles=[dict(role="Accounts User"), dict(role="Accounts Manager"), dict(role="Auditor")], + dict( + doctype="Custom Role", + report="VAT Audit Report", + roles=[dict(role="Accounts User"), dict(role="Accounts Manager"), dict(role="Auditor")], + ) ).insert() diff --git a/erpnext/regional/united_arab_emirates/setup.py b/erpnext/regional/united_arab_emirates/setup.py index 6541d5539e5..6a8c7b9438b 100644 --- a/erpnext/regional/united_arab_emirates/setup.py +++ b/erpnext/regional/united_arab_emirates/setup.py @@ -261,9 +261,11 @@ def add_custom_roles_for_reports(): """Add Access Control to UAE VAT 201.""" if not frappe.db.get_value("Custom Role", dict(report="UAE VAT 201")): frappe.get_doc( - doctype="Custom Role", - report="UAE VAT 201", - roles=[dict(role="Accounts User"), dict(role="Accounts Manager"), dict(role="Auditor")], + dict( + doctype="Custom Role", + report="UAE VAT 201", + roles=[dict(role="Accounts User"), dict(role="Accounts Manager"), dict(role="Auditor")], + ) ).insert() diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index 2e7b7233fb1..85bb04c3409 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -104,24 +104,28 @@ class TestCustomer(IntegrationTestCase): self.assertEqual(details.tax_category, "_Test Tax Category 1") billing_address = frappe.get_doc( - doctype="Address", - address_title="_Test Address With Tax Category", - tax_category="_Test Tax Category 2", - address_type="Billing", - address_line1="Station Road", - city="_Test City", - country="India", - links=[dict(link_doctype="Customer", link_name="_Test Customer With Tax Category")], + dict( + doctype="Address", + address_title="_Test Address With Tax Category", + tax_category="_Test Tax Category 2", + address_type="Billing", + address_line1="Station Road", + city="_Test City", + country="India", + links=[dict(link_doctype="Customer", link_name="_Test Customer With Tax Category")], + ) ).insert() shipping_address = frappe.get_doc( - doctype="Address", - address_title="_Test Address With Tax Category", - tax_category="_Test Tax Category 3", - address_type="Shipping", - address_line1="Station Road", - city="_Test City", - country="India", - links=[dict(link_doctype="Customer", link_name="_Test Customer With Tax Category")], + dict( + doctype="Address", + address_title="_Test Address With Tax Category", + tax_category="_Test Tax Category 3", + address_type="Shipping", + address_line1="Station Road", + city="_Test City", + country="India", + links=[dict(link_doctype="Customer", link_name="_Test Customer With Tax Category")], + ) ).insert() settings = frappe.get_single("Accounts Settings") diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 5bdf8da738a..a3c0ef2f52d 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -1743,16 +1743,18 @@ def make_work_orders(items, sales_order, company, project=None): frappe.throw(_("Please select Qty against item {0}").format(i.get("item_code"))) work_order = frappe.get_doc( - doctype="Work Order", - production_item=i["item_code"], - bom_no=i.get("bom"), - qty=i["pending_qty"], - company=company, - sales_order=sales_order, - sales_order_item=i["sales_order_item"], - project=project, - fg_warehouse=i["warehouse"], - description=i["description"], + dict( + doctype="Work Order", + production_item=i["item_code"], + bom_no=i.get("bom"), + qty=i["pending_qty"], + company=company, + sales_order=sales_order, + sales_order_item=i["sales_order_item"], + project=project, + fg_warehouse=i["warehouse"], + description=i["description"], + ) ).insert() work_order.set_work_order_operations() work_order.flags.ignore_mandatory = True diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index dea7b3bff97..7ff4c3e5c63 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -2713,8 +2713,8 @@ def make_sales_order_workflow(): doc.save() return doc - frappe.get_doc(doctype="Role", role_name="Test Junior Approver").insert(ignore_if_duplicate=True) - frappe.get_doc(doctype="Role", role_name="Test Approver").insert(ignore_if_duplicate=True) + frappe.get_doc(dict(doctype="Role", role_name="Test Junior Approver")).insert(ignore_if_duplicate=True) + frappe.get_doc(dict(doctype="Role", role_name="Test Approver")).insert(ignore_if_duplicate=True) frappe.cache().hdel("roles", frappe.session.user) workflow = frappe.get_doc( diff --git a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.js b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.js index 14d6d71a0b6..2b4b8e714ed 100644 --- a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.js +++ b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.js @@ -54,7 +54,7 @@ frappe.query_reports["Item-wise Sales History"] = { value = default_formatter(value, row, column, data); let format_fields = ["delivered_quantity", "billed_amount"]; - if (format_fields.includes(column.fieldname) && data && data[column.fieldname] > 0) { + if (in_list(format_fields, column.fieldname) && data && data[column.fieldname] > 0) { value = "" + value + ""; } return value; diff --git a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.js b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.js index 3b7fa966927..b7f7a34c1b8 100644 --- a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.js +++ b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.js @@ -96,7 +96,7 @@ frappe.query_reports["Sales Order Analysis"] = { value = default_formatter(value, row, column, data); let format_fields = ["delivered_qty", "billed_amount"]; - if (format_fields.includes(column.fieldname) && data && data[column.fieldname] > 0) { + if (in_list(format_fields, column.fieldname) && data && data[column.fieldname] > 0) { value = "" + value + ""; } diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index f8daf3c6f31..a4cdbe223f1 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -257,7 +257,7 @@ erpnext.company.set_chart_of_accounts_options = function (doc) { callback: function (r) { if (!r.exc) { set_field_options("chart_of_accounts", [""].concat(r.message).join("\n")); - if (r.message.includes(selected_value)) + if (in_list(r.message, selected_value)) cur_frm.set_value("chart_of_accounts", selected_value); } }, diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index c67060a8699..10de964d19f 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -306,7 +306,7 @@ def get_batches_by_oldest(item_code, warehouse): @frappe.whitelist() def split_batch(batch_no: str, item_code: str, warehouse: str, qty: float, new_batch_id: str | None = None): """Split the batch into a new batch""" - batch = frappe.get_doc(doctype="Batch", item=item_code, batch_id=new_batch_id).insert() + batch = frappe.get_doc(dict(doctype="Batch", item=item_code, batch_id=new_batch_id)).insert() qty = flt(qty) company = frappe.db.get_value("Warehouse", warehouse, "company") @@ -330,18 +330,22 @@ def split_batch(batch_no: str, item_code: str, warehouse: str, qty: float, new_b ) stock_entry = frappe.get_doc( - doctype="Stock Entry", - purpose="Repack", - company=company, - items=[ - dict( - item_code=item_code, - qty=qty, - s_warehouse=warehouse, - serial_and_batch_bundle=from_bundle_id, - ), - dict(item_code=item_code, qty=qty, t_warehouse=warehouse, serial_and_batch_bundle=to_bundle_id), - ], + dict( + doctype="Stock Entry", + purpose="Repack", + company=company, + items=[ + dict( + item_code=item_code, + qty=qty, + s_warehouse=warehouse, + serial_and_batch_bundle=from_bundle_id, + ), + dict( + item_code=item_code, qty=qty, t_warehouse=warehouse, serial_and_batch_bundle=to_bundle_id + ), + ], + ) ) stock_entry.set_stock_entry_type() stock_entry.insert() diff --git a/erpnext/stock/doctype/batch/test_batch.py b/erpnext/stock/doctype/batch/test_batch.py index 6154a982c98..bc06e2beb39 100644 --- a/erpnext/stock/doctype/batch/test_batch.py +++ b/erpnext/stock/doctype/batch/test_batch.py @@ -45,10 +45,12 @@ class TestBatch(IntegrationTestCase): self.make_batch_item("ITEM-BATCH-1") receipt = frappe.get_doc( - doctype="Purchase Receipt", - supplier="_Test Supplier", - company="_Test Company", - items=[dict(item_code="ITEM-BATCH-1", qty=batch_qty, rate=10, warehouse="Stores - _TC")], + dict( + doctype="Purchase Receipt", + supplier="_Test Supplier", + company="_Test Company", + items=[dict(item_code="ITEM-BATCH-1", qty=batch_qty, rate=10, warehouse="Stores - _TC")], + ) ).insert() receipt.submit() @@ -64,10 +66,12 @@ class TestBatch(IntegrationTestCase): self.make_batch_item("ITEM-BATCH-1") receipt = frappe.get_doc( - doctype="Purchase Receipt", - supplier="_Test Supplier", - company="_Test Company", - items=[dict(item_code="ITEM-BATCH-1", qty=10, rate=10, warehouse="Stores - _TC")], + dict( + doctype="Purchase Receipt", + supplier="_Test Supplier", + company="_Test Company", + items=[dict(item_code="ITEM-BATCH-1", qty=10, rate=10, warehouse="Stores - _TC")], + ) ).insert() receipt.submit() @@ -92,18 +96,20 @@ class TestBatch(IntegrationTestCase): ) receipt2 = frappe.get_doc( - doctype="Purchase Receipt", - supplier="_Test Supplier", - company="_Test Company", - items=[ - dict( - item_code="ITEM-BATCH-1", - qty=20, - rate=10, - warehouse="_Test Warehouse - _TC", - serial_and_batch_bundle=bundle_id, - ) - ], + dict( + doctype="Purchase Receipt", + supplier="_Test Supplier", + company="_Test Company", + items=[ + dict( + item_code="ITEM-BATCH-1", + qty=20, + rate=10, + warehouse="_Test Warehouse - _TC", + serial_and_batch_bundle=bundle_id, + ) + ], + ) ).insert() receipt2.submit() @@ -129,18 +135,20 @@ class TestBatch(IntegrationTestCase): self.make_batch_item("ITEM-BATCH-1") stock_entry = frappe.get_doc( - doctype="Stock Entry", - purpose="Material Receipt", - company="_Test Company", - items=[ - dict( - item_code="ITEM-BATCH-1", - qty=90, - t_warehouse="_Test Warehouse - _TC", - cost_center="Main - _TC", - rate=10, - ) - ], + dict( + doctype="Stock Entry", + purpose="Material Receipt", + company="_Test Company", + items=[ + dict( + item_code="ITEM-BATCH-1", + qty=90, + t_warehouse="_Test Warehouse - _TC", + cost_center="Main - _TC", + rate=10, + ) + ], + ) ) stock_entry.set_stock_entry_type() @@ -179,18 +187,20 @@ class TestBatch(IntegrationTestCase): ) delivery_note = frappe.get_doc( - doctype="Delivery Note", - customer="_Test Customer", - company=receipt.company, - items=[ - dict( - item_code=item_code, - qty=batch_qty, - rate=10, - warehouse=receipt.items[0].warehouse, - serial_and_batch_bundle=bundle_id, - ) - ], + dict( + doctype="Delivery Note", + customer="_Test Customer", + company=receipt.company, + items=[ + dict( + item_code=item_code, + qty=batch_qty, + rate=10, + warehouse=receipt.items[0].warehouse, + serial_and_batch_bundle=bundle_id, + ) + ], + ) ).insert() delivery_note.submit() @@ -251,17 +261,19 @@ class TestBatch(IntegrationTestCase): ) stock_entry = frappe.get_doc( - doctype="Stock Entry", - purpose="Material Issue", - company=receipt.company, - items=[ - dict( - item_code=item_code, - qty=batch_qty, - s_warehouse=receipt.items[0].warehouse, - serial_and_batch_bundle=bundle_id, - ) - ], + dict( + doctype="Stock Entry", + purpose="Material Issue", + company=receipt.company, + items=[ + dict( + item_code=item_code, + qty=batch_qty, + s_warehouse=receipt.items[0].warehouse, + serial_and_batch_bundle=bundle_id, + ) + ], + ) ) stock_entry.set_stock_entry_type() @@ -361,7 +373,7 @@ class TestBatch(IntegrationTestCase): """Make a new stock entry for given target warehouse and batch name of item""" if not frappe.db.exists("Batch", batch_name): - batch = frappe.get_doc(doctype="Batch", item=item_name, batch_id=batch_name).insert( + batch = frappe.get_doc(dict(doctype="Batch", item=item_name, batch_id=batch_name)).insert( ignore_permissions=True ) batch.save() @@ -381,20 +393,22 @@ class TestBatch(IntegrationTestCase): ).make_serial_and_batch_bundle() stock_entry = frappe.get_doc( - doctype="Stock Entry", - purpose="Material Receipt", - company="_Test Company", - items=[ - dict( - item_code=item_name, - qty=90, - serial_and_batch_bundle=sn_doc.name, - t_warehouse=warehouse, - cost_center="Main - _TC", - rate=10, - allow_zero_valuation_rate=1, - ) - ], + dict( + doctype="Stock Entry", + purpose="Material Receipt", + company="_Test Company", + items=[ + dict( + item_code=item_name, + qty=90, + serial_and_batch_bundle=sn_doc.name, + t_warehouse=warehouse, + cost_center="Main - _TC", + rate=10, + allow_zero_valuation_rate=1, + ) + ], + ) ) stock_entry.set_stock_entry_type() diff --git a/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js b/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js index f3d60548b65..1b5f4a5743f 100644 --- a/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js +++ b/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js @@ -56,7 +56,7 @@ frappe.ui.form.on("Inventory Dimension", { ]; frm.fields.forEach((field) => { - if (!allow_to_edit_fields.includes(field.df.fieldname)) { + if (!in_list(allow_to_edit_fields, field.df.fieldname)) { frm.set_df_property(field.df.fieldname, "read_only", "1"); } }); diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 56cdb427acd..eb251dbf2c5 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -1089,9 +1089,9 @@ function open_form(frm, doctype, child_doctype, parentfield) { let new_child_doc = frappe.model.add_child(new_doc, child_doctype, parentfield); new_child_doc.item_code = frm.doc.name; new_child_doc.item_name = frm.doc.item_name; - if (SALES_DOCTYPES.includes(doctype) && frm.doc.sales_uom) { + if (in_list(SALES_DOCTYPES, doctype) && frm.doc.sales_uom) { new_child_doc.uom = frm.doc.sales_uom; - } else if (PURCHASE_DOCTYPES.includes(doctype) && frm.doc.purchase_uom) { + } else if (in_list(PURCHASE_DOCTYPES, doctype) && frm.doc.purchase_uom) { new_child_doc.uom = frm.doc.purchase_uom; } else { new_child_doc.uom = frm.doc.stock_uom; diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js index 6807177e582..d906b85a031 100644 --- a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js +++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js @@ -30,9 +30,9 @@ frappe.ui.form.on("Item Variant Settings", { field_label_map[d.fieldname] = __(d.label, null, d.parent) + ` (${d.fieldname})`; if ( - !exclude_field_types.includes(d.fieldtype) && + !in_list(exclude_field_types, d.fieldtype) && !d.no_copy && - !exclude_fields.includes(d.fieldname) + !in_list(exclude_fields, d.fieldname) ) { allow_fields.push({ label: field_label_map[d.fieldname], diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 65161699807..d113ccdf7f1 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -1290,11 +1290,10 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle // Clear Work Order record from locals, because it is updated via Stock Entry if ( this.frm.doc.work_order && - [ - "Manufacture", - "Material Transfer for Manufacture", - "Material Consumption for Manufacture", - ].includes(this.frm.doc.purpose) + in_list( + ["Manufacture", "Material Transfer for Manufacture", "Material Consumption for Manufacture"], + this.frm.doc.purpose + ) ) { frappe.model.remove_from_locals("Work Order", this.frm.doc.work_order); } diff --git a/erpnext/stock/doctype/stock_settings/test_stock_settings.py b/erpnext/stock/doctype/stock_settings/test_stock_settings.py index 18c523f9998..138cb536995 100644 --- a/erpnext/stock/doctype/stock_settings/test_stock_settings.py +++ b/erpnext/stock/doctype/stock_settings/test_stock_settings.py @@ -13,10 +13,12 @@ class TestStockSettings(IntegrationTestCase): def test_settings(self): item = frappe.get_doc( - doctype="Item", - item_code="Item for description test", - item_group="Products", - description='

Drawing No. 07-xxx-PO132
1800 x 1685 x 750
All parts made of Marine Ply
Top w/ Corian dd
CO, CS, VIP Day Cabin

', + dict( + doctype="Item", + item_code="Item for description test", + item_group="Products", + description='

Drawing No. 07-xxx-PO132
1800 x 1685 x 750
All parts made of Marine Ply
Top w/ Corian dd
CO, CS, VIP Day Cabin

', + ) ).insert() settings = frappe.get_single("Stock Settings") @@ -38,10 +40,12 @@ class TestStockSettings(IntegrationTestCase): settings.save() item = frappe.get_doc( - doctype="Item", - item_code="Item for description test", - item_group="Products", - description='

Drawing No. 07-xxx-PO132
1800 x 1685 x 750
All parts made of Marine Ply
Top w/ Corian dd
CO, CS, VIP Day Cabin

', + dict( + doctype="Item", + item_code="Item for description test", + item_group="Products", + description='

Drawing No. 07-xxx-PO132
1800 x 1685 x 750
All parts made of Marine Ply
Top w/ Corian dd
CO, CS, VIP Day Cabin

', + ) ).insert() self.assertEqual( diff --git a/erpnext/templates/utils.py b/erpnext/templates/utils.py index 164a52f58c2..15af9f0f014 100644 --- a/erpnext/templates/utils.py +++ b/erpnext/templates/utils.py @@ -26,15 +26,17 @@ def send_message(sender, message, subject="Website Query"): lead = frappe.db.get_value("Lead", dict(email_id=sender)) if not lead: new_lead = frappe.get_doc( - doctype="Lead", email_id=sender, lead_name=sender.split("@")[0].title() + dict(doctype="Lead", email_id=sender, lead_name=sender.split("@")[0].title()) ).insert(ignore_permissions=True) opportunity = frappe.get_doc( - doctype="Opportunity", - opportunity_from="Customer" if customer else "Lead", - status="Open", - title=subject, - contact_email=sender, + dict( + doctype="Opportunity", + opportunity_from="Customer" if customer else "Lead", + status="Open", + title=subject, + contact_email=sender, + ) ) if customer: