Merge pull request #51441 from mihir-kandoi/semgrep-autofixes

This commit is contained in:
Mihir Kandoi
2026-01-01 22:11:32 +05:30
committed by GitHub
41 changed files with 294 additions and 373 deletions

View File

@@ -450,14 +450,12 @@ def process_deferred_accounting(posting_date=None):
for company in companies: for company in companies:
for record_type in ("Income", "Expense"): for record_type in ("Income", "Expense"):
doc = frappe.get_doc( doc = frappe.get_doc(
dict( doctype="Process Deferred Accounting",
doctype="Process Deferred Accounting", company=company.name,
company=company.name, posting_date=posting_date,
posting_date=posting_date, start_date=start_date,
start_date=start_date, end_date=end_date,
end_date=end_date, type=record_type,
type=record_type,
)
) )
doc.insert() doc.insert()

View File

@@ -415,15 +415,13 @@ def create_account(**kwargs):
return account.name return account.name
else: else:
account = frappe.get_doc( account = frappe.get_doc(
dict( doctype="Account",
doctype="Account", is_group=kwargs.get("is_group", 0),
is_group=kwargs.get("is_group", 0), account_name=kwargs.get("account_name"),
account_name=kwargs.get("account_name"), account_type=kwargs.get("account_type"),
account_type=kwargs.get("account_type"), parent_account=kwargs.get("parent_account"),
parent_account=kwargs.get("parent_account"), company=kwargs.get("company"),
company=kwargs.get("company"), account_currency=kwargs.get("account_currency"),
account_currency=kwargs.get("account_currency"),
)
) )
account.save() account.save()

View File

@@ -182,7 +182,7 @@ frappe.ui.form.on("Payment Entry", {
"Dunning", "Dunning",
]; ];
if (in_list(party_type_doctypes, child.reference_doctype)) { if (party_type_doctypes.includes(child.reference_doctype)) {
filters[doc.party_type.toLowerCase()] = doc.party; filters[doc.party_type.toLowerCase()] = doc.party;
} }
@@ -1041,7 +1041,7 @@ frappe.ui.form.on("Payment Entry", {
c.allocated_amount = d.allocated_amount; c.allocated_amount = d.allocated_amount;
c.account = d.account; c.account = d.account;
if (!in_list(frm.events.get_order_doctypes(frm), d.voucher_type)) { if (!frm.events.get_order_doctypes(frm).includes(d.voucher_type)) {
if (flt(d.outstanding_amount) > 0) if (flt(d.outstanding_amount) > 0)
total_positive_outstanding += flt(d.outstanding_amount); total_positive_outstanding += flt(d.outstanding_amount);
else total_negative_outstanding += Math.abs(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 { } else {
c.exchange_rate = 1; c.exchange_rate = 1;
} }
if (in_list(frm.events.get_invoice_doctypes(frm), d.reference_doctype)) { if (frm.events.get_invoice_doctypes(frm).includes(d.reference_doctype)) {
c.due_date = d.due_date; c.due_date = d.due_date;
} }
}); });

View File

@@ -50,12 +50,10 @@ class TestPaymentOrder(IntegrationTestCase):
def create_payment_order_against_payment_entry(ref_doc, order_type, bank_account): def create_payment_order_against_payment_entry(ref_doc, order_type, bank_account):
payment_order = frappe.get_doc( payment_order = frappe.get_doc(
dict( doctype="Payment Order",
doctype="Payment Order", company="_Test Company",
company="_Test Company", payment_order_type=order_type,
payment_order_type=order_type, company_bank_account=bank_account,
company_bank_account=bank_account,
)
) )
doc = make_payment_order(ref_doc.name, payment_order) doc = make_payment_order(ref_doc.name, payment_order)
doc.save() doc.save()

View File

@@ -171,7 +171,7 @@ frappe.ui.form.on("Pricing Rule", {
set_field_options("applicable_for", options.join("\n")); set_field_options("applicable_for", options.join("\n"));
if (!in_list(options, applicable_for)) applicable_for = null; if (!options.includes(applicable_for)) applicable_for = null;
frm.set_value("applicable_for", applicable_for); frm.set_value("applicable_for", applicable_for);
}, },
}); });

View File

@@ -48,13 +48,11 @@ class TestProcessDeferredAccounting(IntegrationTestCase):
check_gl_entries(self, si.name, original_gle, "2023-07-01") check_gl_entries(self, si.name, original_gle, "2023-07-01")
process_deferred_accounting = frappe.get_doc( process_deferred_accounting = frappe.get_doc(
dict( doctype="Process Deferred Accounting",
doctype="Process Deferred Accounting", posting_date="2023-07-01",
posting_date="2023-07-01", start_date="2023-05-01",
start_date="2023-05-01", end_date="2023-06-30",
end_date="2023-06-30", type="Income",
type="Income",
)
) )
process_deferred_accounting.insert() process_deferred_accounting.insert()
@@ -80,13 +78,11 @@ class TestProcessDeferredAccounting(IntegrationTestCase):
def test_pda_submission_and_cancellation(self): def test_pda_submission_and_cancellation(self):
pda = frappe.get_doc( pda = frappe.get_doc(
dict( doctype="Process Deferred Accounting",
doctype="Process Deferred Accounting", posting_date="2019-01-01",
posting_date="2019-01-01", start_date="2019-01-01",
start_date="2019-01-01", end_date="2019-01-31",
end_date="2019-01-31", type="Income",
type="Income",
)
) )
pda.submit() pda.submit()
pda.cancel() pda.cancel()

View File

@@ -46,7 +46,7 @@ frappe.ui.form.on("Promotional Scheme", {
set_field_options("applicable_for", options.join("\n")); set_field_options("applicable_for", options.join("\n"));
if (!in_list(options, applicable_for)) applicable_for = null; if (!options.includes(applicable_for)) applicable_for = null;
frm.set_value("applicable_for", applicable_for); frm.set_value("applicable_for", applicable_for);
}, },

View File

@@ -1249,14 +1249,12 @@ class TestPurchaseInvoice(IntegrationTestCase, StockTestMixin):
pi.submit() pi.submit()
pda1 = frappe.get_doc( pda1 = frappe.get_doc(
dict( doctype="Process Deferred Accounting",
doctype="Process Deferred Accounting", posting_date=nowdate(),
posting_date=nowdate(), start_date="2019-01-01",
start_date="2019-01-01", end_date="2019-03-31",
end_date="2019-03-31", type="Expense",
type="Expense", company="_Test Company",
company="_Test Company",
)
) )
pda1.insert() pda1.insert()

View File

@@ -2510,14 +2510,12 @@ class TestSalesInvoice(ERPNextTestSuite):
si.submit() si.submit()
pda1 = frappe.get_doc( pda1 = frappe.get_doc(
dict( doctype="Process Deferred Accounting",
doctype="Process Deferred Accounting", posting_date=nowdate(),
posting_date=nowdate(), start_date="2019-01-01",
start_date="2019-01-01", end_date="2019-03-31",
end_date="2019-03-31", type="Income",
type="Income", company="_Test Company",
company="_Test Company",
)
) )
pda1.insert() pda1.insert()
@@ -2568,14 +2566,12 @@ class TestSalesInvoice(ERPNextTestSuite):
si.submit() si.submit()
pda1 = frappe.get_doc( pda1 = frappe.get_doc(
dict( doctype="Process Deferred Accounting",
doctype="Process Deferred Accounting", posting_date="2019-03-31",
posting_date="2019-03-31", start_date="2019-01-01",
start_date="2019-01-01", end_date="2019-03-31",
end_date="2019-03-31", type="Income",
type="Income", company="_Test Company",
company="_Test Company",
)
) )
pda1.insert() pda1.insert()
@@ -3478,14 +3474,12 @@ class TestSalesInvoice(ERPNextTestSuite):
frappe.db.set_value("Company", "_Test Company", "accounts_frozen_till_date", getdate("2019-01-31")) frappe.db.set_value("Company", "_Test Company", "accounts_frozen_till_date", getdate("2019-01-31"))
pda1 = frappe.get_doc( pda1 = frappe.get_doc(
dict( doctype="Process Deferred Accounting",
doctype="Process Deferred Accounting", posting_date=nowdate(),
posting_date=nowdate(), start_date="2019-01-01",
start_date="2019-01-01", end_date="2019-03-31",
end_date="2019-03-31", type="Income",
type="Income", company="_Test Company",
company="_Test Company",
)
) )
pda1.insert() pda1.insert()

View File

@@ -101,14 +101,12 @@ class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin):
si.submit() si.submit()
pda = frappe.get_doc( pda = frappe.get_doc(
dict( doctype="Process Deferred Accounting",
doctype="Process Deferred Accounting", posting_date=nowdate(),
posting_date=nowdate(), start_date="2021-05-01",
start_date="2021-05-01", end_date="2021-08-01",
end_date="2021-08-01", type="Income",
type="Income", company=self.company,
company=self.company,
)
) )
pda.insert() pda.insert()
pda.submit() pda.submit()
@@ -173,14 +171,12 @@ class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin):
pi.submit() pi.submit()
pda = frappe.get_doc( pda = frappe.get_doc(
dict( doctype="Process Deferred Accounting",
doctype="Process Deferred Accounting", posting_date=nowdate(),
posting_date=nowdate(), start_date="2021-05-01",
start_date="2021-05-01", end_date="2021-08-01",
end_date="2021-08-01", type="Expense",
type="Expense", company=self.company,
company=self.company,
)
) )
pda.insert() pda.insert()
pda.submit() pda.submit()
@@ -240,14 +236,12 @@ class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin):
si.submit() si.submit()
pda = frappe.get_doc( pda = frappe.get_doc(
dict( doctype="Process Deferred Accounting",
doctype="Process Deferred Accounting", posting_date=nowdate(),
posting_date=nowdate(), start_date="2021-05-01",
start_date="2021-05-01", end_date="2021-08-01",
end_date="2021-08-01", type="Income",
type="Income", company=self.company,
company=self.company,
)
) )
pda.insert() pda.insert()
pda.submit() pda.submit()

View File

@@ -131,16 +131,14 @@ class TestSupplier(IntegrationTestCase):
self.assertEqual(details.tax_category, "_Test Tax Category 1") self.assertEqual(details.tax_category, "_Test Tax Category 1")
address = frappe.get_doc( address = frappe.get_doc(
dict( doctype="Address",
doctype="Address", address_title="_Test Address With Tax Category",
address_title="_Test Address With Tax Category", tax_category="_Test Tax Category 2",
tax_category="_Test Tax Category 2", address_type="Billing",
address_type="Billing", address_line1="Station Road",
address_line1="Station Road", city="_Test City",
city="_Test City", country="India",
country="India", links=[dict(link_doctype="Supplier", link_name="_Test Supplier With Tax Category")],
links=[dict(link_doctype="Supplier", link_name="_Test Supplier With Tax Category")],
)
).insert() ).insert()
# Tax Category with Address # Tax Category with Address

View File

@@ -97,7 +97,7 @@ frappe.query_reports["Purchase Order Analysis"] = {
value = default_formatter(value, row, column, data); value = default_formatter(value, row, column, data);
let format_fields = ["received_qty", "billed_amount"]; let format_fields = ["received_qty", "billed_amount"];
if (in_list(format_fields, column.fieldname) && data && data[column.fieldname] > 0) { if (format_fields.includes(column.fieldname) && data && data[column.fieldname] > 0) {
value = "<span style='color:green'>" + value + "</span>"; value = "<span style='color:green'>" + value + "</span>";
} }
return value; return value;

View File

@@ -30,4 +30,4 @@ def execute():
def insert_sales_partner_type(s): def insert_sales_partner_type(s):
if not frappe.db.exists("Sales Partner Type", s): if not frappe.db.exists("Sales Partner Type", s):
frappe.get_doc(dict(doctype="Sales Partner Type", sales_partner_type=s)).insert() frappe.get_doc(doctype="Sales Partner Type", sales_partner_type=s).insert()

View File

@@ -30,15 +30,13 @@ def execute():
if task.subject: if task.subject:
replace_tasks = True replace_tasks = True
new_task = frappe.get_doc( new_task = frappe.get_doc(
dict( doctype="Task",
doctype="Task", subject=task.subject,
subject=task.subject, start=task.start,
start=task.start, duration=task.duration,
duration=task.duration, task_weight=task.task_weight,
task_weight=task.task_weight, description=task.description,
description=task.description, is_template=1,
is_template=1,
)
).insert() ).insert()
new_tasks.append(new_task) new_tasks.append(new_task)

View File

@@ -127,22 +127,20 @@ class Project(Document):
def create_task_from_template(self, task_details): def create_task_from_template(self, task_details):
return frappe.get_doc( return frappe.get_doc(
dict( doctype="Task",
doctype="Task", subject=task_details.subject,
subject=task_details.subject, project=self.name,
project=self.name, status="Open",
status="Open", exp_start_date=self.calculate_start_date(task_details),
exp_start_date=self.calculate_start_date(task_details), exp_end_date=self.calculate_end_date(task_details),
exp_end_date=self.calculate_end_date(task_details), description=task_details.description,
description=task_details.description, task_weight=task_details.task_weight,
task_weight=task_details.task_weight, type=task_details.type,
type=task_details.type, issue=task_details.issue,
issue=task_details.issue, is_group=task_details.is_group,
is_group=task_details.is_group, color=task_details.color,
color=task_details.color, template_task=task_details.name,
template_task=task_details.name, priority=task_details.priority,
priority=task_details.priority,
)
).insert() ).insert()
def calculate_start_date(self, task_details): def calculate_start_date(self, task_details):

View File

@@ -255,14 +255,12 @@ class TestProject(ERPNextTestSuite):
def get_project(name, template): def get_project(name, template):
project = frappe.get_doc( project = frappe.get_doc(
dict( doctype="Project",
doctype="Project", project_name=name,
project_name=name, status="Open",
status="Open", project_template=template.name,
project_template=template.name, expected_start_date=nowdate(),
expected_start_date=nowdate(), company="_Test Company",
company="_Test Company",
)
).insert() ).insert()
return project return project
@@ -275,13 +273,11 @@ def make_project(args):
return frappe.get_doc("Project", {"project_name": args.project_name}) return frappe.get_doc("Project", {"project_name": args.project_name})
project = frappe.get_doc( project = frappe.get_doc(
dict( doctype="Project",
doctype="Project", project_name=args.project_name,
project_name=args.project_name, status="Open",
status="Open", expected_start_date=args.start_date,
expected_start_date=args.start_date, company=args.company or "_Test Company",
company=args.company or "_Test Company",
)
) )
if args.project_template_name: if args.project_template_name:

View File

@@ -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 1", is_template=1, begin=0, duration=3),
create_task(subject="_Test Template Task 2", is_template=1, begin=0, duration=2), create_task(subject="_Test Template Task 2", is_template=1, begin=0, duration=2),
] ]
doc = frappe.get_doc(dict(doctype="Project Template", name=project_template_name)) doc = frappe.get_doc(doctype="Project Template", name=project_template_name)
for task in project_tasks: for task in project_tasks:
doc.append("tasks", {"task": task.name}) doc.append("tasks", {"task": task.name})
doc.insert() doc.insert()

View File

@@ -1106,7 +1106,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
var payment_types = $.map(this.frm.doc.payments, function (d) { var payment_types = $.map(this.frm.doc.payments, function (d) {
return d.type; return d.type;
}); });
if (in_list(payment_types, "Cash")) { if (payment_types.includes("Cash")) {
var grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total; 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; var base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total;

View File

@@ -904,7 +904,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
get_incoming_rate(item, posting_date, posting_time, voucher_type, company) { get_incoming_rate(item, posting_date, posting_time, voucher_type, company) {
let item_args = { let item_args = {
item_code: item.item_code, item_code: item.item_code,
warehouse: in_list("Purchase Receipt", "Purchase Invoice") ? item.from_warehouse : item.warehouse, warehouse: item.warehouse,
posting_date: posting_date, posting_date: posting_date,
posting_time: posting_time, posting_time: posting_time,
qty: item.qty * item.conversion_factor, qty: item.qty * item.conversion_factor,
@@ -2248,7 +2248,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
child.apply_rule_on_other_items && child.apply_rule_on_other_items &&
JSON.parse(child.apply_rule_on_other_items).length JSON.parse(child.apply_rule_on_other_items).length
) { ) {
if (!in_list(JSON.parse(child.apply_rule_on_other_items), child.item_code)) { if (!JSON.parse(child.apply_rule_on_other_items).includes(child.item_code)) {
continue; 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])) { if (JSON.parse(data.apply_rule_on_other_items).includes(d[data.apply_rule_on])) {
for (var k in data) { for (var k in data) {
if ( if (
in_list(fields, k) && fields.includes(k) &&
data[k] && data[k] &&
(data.price_or_product_discount === "Price" || k === "pricing_rules") (data.price_or_product_discount === "Price" || k === "pricing_rules")
) { ) {
@@ -2768,8 +2768,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
} }
has_discount_in_schedule() { has_discount_in_schedule() {
let is_eligible = in_list( let is_eligible = ["Sales Order", "Sales Invoice", "Purchase Order", "Purchase Invoice"].includes(
["Sales Order", "Sales Invoice", "Purchase Order", "Purchase Invoice"],
this.frm.doctype this.frm.doctype
); );
let has_payment_schedule = this.frm.doc.payment_schedule && this.frm.doc.payment_schedule.length; let has_payment_schedule = this.frm.doc.payment_schedule && this.frm.doc.payment_schedule.length;
@@ -3205,16 +3204,13 @@ erpnext.show_serial_batch_selector = function (frm, item_row, callback, on_close
} }
if ( if (
in_list( [
[ "Material Transfer",
"Material Transfer", "Send to Subcontractor",
"Send to Subcontractor", "Material Issue",
"Material Issue", "Material Consumption for Manufacture",
"Material Consumption for Manufacture", "Material Transfer for Manufacture",
"Material Transfer for Manufacture", ].includes(frm.doc.purpose)
],
frm.doc.purpose
)
) { ) {
warehouse_field = "s_warehouse"; warehouse_field = "s_warehouse";
} else { } else {

View File

@@ -338,7 +338,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
? this.dialog.get_value("serial_no").split("\n") ? this.dialog.get_value("serial_no").split("\n")
: []; : [];
if (in_list(serial_nos, serial_no)) { if (serial_nos.includes(serial_no)) {
frappe.throw(__("Serial No {0} already scanned", [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) { for (let key in prev_row) {
if (in_list(ignore_fields, key)) { if (ignore_fields.includes(key)) {
continue; continue;
} }

View File

@@ -36,14 +36,14 @@ erpnext.utils.get_party_details = function (frm, method, args, callback) {
} }
if (!args) { if (!args) {
if (in_list(SALES_DOCTYPES, frm.doc.doctype)) { if (SALES_DOCTYPES.includes(frm.doc.doctype)) {
args = { args = {
party: frm.doc.customer || frm.doc.party_name, party: frm.doc.customer || frm.doc.party_name,
party_type: "Customer", party_type: "Customer",
}; };
} }
if (in_list(PURCHASE_DOCTYPES, frm.doc.doctype)) { if (PURCHASE_DOCTYPES.includes(frm.doc.doctype)) {
args = { args = {
party: frm.doc.supplier, party: frm.doc.supplier,
party_type: "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); args.fetch_payment_terms_template = cint(!frm.doc.ignore_default_payment_terms_template);
} }
if (in_list(SALES_DOCTYPES, frm.doc.doctype)) { if (SALES_DOCTYPES.includes(frm.doc.doctype)) {
if (!args.company_address && frm.doc.company_address) { if (!args.company_address && frm.doc.company_address) {
args.company_address = frm.doc.company_address; args.company_address = frm.doc.company_address;
} }
} }
if (in_list(PURCHASE_DOCTYPES, frm.doc.doctype)) { if (PURCHASE_DOCTYPES.includes(frm.doc.doctype)) {
if (!args.company_address && frm.doc.billing_address) { if (!args.company_address && frm.doc.billing_address) {
args.company_address = frm.doc.billing_address; args.company_address = frm.doc.billing_address;
} }

View File

@@ -9,20 +9,16 @@ from frappe.tests import IntegrationTestCase
class TestQualityFeedback(IntegrationTestCase): class TestQualityFeedback(IntegrationTestCase):
def test_quality_feedback(self): def test_quality_feedback(self):
template = frappe.get_doc( template = frappe.get_doc(
dict( doctype="Quality Feedback Template",
doctype="Quality Feedback Template", template="Test Template",
template="Test Template", parameters=[dict(parameter="Test Parameter 1"), dict(parameter="Test Parameter 2")],
parameters=[dict(parameter="Test Parameter 1"), dict(parameter="Test Parameter 2")],
)
).insert() ).insert()
feedback = frappe.get_doc( feedback = frappe.get_doc(
dict( doctype="Quality Feedback",
doctype="Quality Feedback", template=template.name,
template=template.name, document_type="User",
document_type="User", document_name=frappe.session.user,
document_name=frappe.session.user,
)
).insert() ).insert()
self.assertEqual(template.parameters[0].parameter, feedback.parameters[0].parameter) self.assertEqual(template.parameters[0].parameter, feedback.parameters[0].parameter)

View File

@@ -16,10 +16,8 @@ class TestQualityGoal(IntegrationTestCase):
def get_quality_goal(): def get_quality_goal():
return frappe.get_doc( return frappe.get_doc(
dict( doctype="Quality Goal",
doctype="Quality Goal", goal="Test Quality Module",
goal="Test Quality Module", frequency="Daily",
frequency="Daily", objectives=[dict(objective="Check test cases", target="100", uom="Percent")],
objectives=[dict(objective="Check test cases", target="100", uom="Percent")],
)
).insert() ).insert()

View File

@@ -50,5 +50,5 @@ def update_address_template(country, html, is_default=0):
frappe.db.set_value("Address Template", country, "is_default", is_default) frappe.db.set_value("Address Template", country, "is_default", is_default)
else: else:
frappe.get_doc( frappe.get_doc(
dict(doctype="Address Template", country=country, is_default=is_default, template=html) doctype="Address Template", country=country, is_default=is_default, template=html
).insert() ).insert()

View File

@@ -470,11 +470,9 @@ def setup_report():
if not frappe.db.get_value("Custom Role", dict(report=report_name)): if not frappe.db.get_value("Custom Role", dict(report=report_name)):
frappe.get_doc( frappe.get_doc(
dict( doctype="Custom Role",
doctype="Custom Role", report=report_name,
report=report_name, roles=[dict(role="Accounts User"), dict(role="Accounts Manager")],
roles=[dict(role="Accounts User"), dict(role="Accounts Manager")],
)
).insert() ).insert()

View File

@@ -50,9 +50,7 @@ def add_permissions():
if not frappe.db.get_value("Custom Role", dict(report="VAT Audit Report")): if not frappe.db.get_value("Custom Role", dict(report="VAT Audit Report")):
frappe.get_doc( frappe.get_doc(
dict( doctype="Custom Role",
doctype="Custom Role", report="VAT Audit Report",
report="VAT Audit Report", roles=[dict(role="Accounts User"), dict(role="Accounts Manager"), dict(role="Auditor")],
roles=[dict(role="Accounts User"), dict(role="Accounts Manager"), dict(role="Auditor")],
)
).insert() ).insert()

View File

@@ -261,11 +261,9 @@ def add_custom_roles_for_reports():
"""Add Access Control to UAE VAT 201.""" """Add Access Control to UAE VAT 201."""
if not frappe.db.get_value("Custom Role", dict(report="UAE VAT 201")): if not frappe.db.get_value("Custom Role", dict(report="UAE VAT 201")):
frappe.get_doc( frappe.get_doc(
dict( doctype="Custom Role",
doctype="Custom Role", report="UAE VAT 201",
report="UAE VAT 201", roles=[dict(role="Accounts User"), dict(role="Accounts Manager"), dict(role="Auditor")],
roles=[dict(role="Accounts User"), dict(role="Accounts Manager"), dict(role="Auditor")],
)
).insert() ).insert()

View File

@@ -104,28 +104,24 @@ class TestCustomer(IntegrationTestCase):
self.assertEqual(details.tax_category, "_Test Tax Category 1") self.assertEqual(details.tax_category, "_Test Tax Category 1")
billing_address = frappe.get_doc( billing_address = frappe.get_doc(
dict( doctype="Address",
doctype="Address", address_title="_Test Address With Tax Category",
address_title="_Test Address With Tax Category", tax_category="_Test Tax Category 2",
tax_category="_Test Tax Category 2", address_type="Billing",
address_type="Billing", address_line1="Station Road",
address_line1="Station Road", city="_Test City",
city="_Test City", country="India",
country="India", links=[dict(link_doctype="Customer", link_name="_Test Customer With Tax Category")],
links=[dict(link_doctype="Customer", link_name="_Test Customer With Tax Category")],
)
).insert() ).insert()
shipping_address = frappe.get_doc( shipping_address = frappe.get_doc(
dict( doctype="Address",
doctype="Address", address_title="_Test Address With Tax Category",
address_title="_Test Address With Tax Category", tax_category="_Test Tax Category 3",
tax_category="_Test Tax Category 3", address_type="Shipping",
address_type="Shipping", address_line1="Station Road",
address_line1="Station Road", city="_Test City",
city="_Test City", country="India",
country="India", links=[dict(link_doctype="Customer", link_name="_Test Customer With Tax Category")],
links=[dict(link_doctype="Customer", link_name="_Test Customer With Tax Category")],
)
).insert() ).insert()
settings = frappe.get_single("Accounts Settings") settings = frappe.get_single("Accounts Settings")

View File

@@ -1743,18 +1743,16 @@ def make_work_orders(items, sales_order, company, project=None):
frappe.throw(_("Please select Qty against item {0}").format(i.get("item_code"))) frappe.throw(_("Please select Qty against item {0}").format(i.get("item_code")))
work_order = frappe.get_doc( work_order = frappe.get_doc(
dict( doctype="Work Order",
doctype="Work Order", production_item=i["item_code"],
production_item=i["item_code"], bom_no=i.get("bom"),
bom_no=i.get("bom"), qty=i["pending_qty"],
qty=i["pending_qty"], company=company,
company=company, sales_order=sales_order,
sales_order=sales_order, sales_order_item=i["sales_order_item"],
sales_order_item=i["sales_order_item"], project=project,
project=project, fg_warehouse=i["warehouse"],
fg_warehouse=i["warehouse"], description=i["description"],
description=i["description"],
)
).insert() ).insert()
work_order.set_work_order_operations() work_order.set_work_order_operations()
work_order.flags.ignore_mandatory = True work_order.flags.ignore_mandatory = True

View File

@@ -2713,8 +2713,8 @@ def make_sales_order_workflow():
doc.save() doc.save()
return doc return doc
frappe.get_doc(dict(doctype="Role", role_name="Test Junior Approver")).insert(ignore_if_duplicate=True) frappe.get_doc(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.get_doc(doctype="Role", role_name="Test Approver").insert(ignore_if_duplicate=True)
frappe.cache().hdel("roles", frappe.session.user) frappe.cache().hdel("roles", frappe.session.user)
workflow = frappe.get_doc( workflow = frappe.get_doc(

View File

@@ -54,7 +54,7 @@ frappe.query_reports["Item-wise Sales History"] = {
value = default_formatter(value, row, column, data); value = default_formatter(value, row, column, data);
let format_fields = ["delivered_quantity", "billed_amount"]; let format_fields = ["delivered_quantity", "billed_amount"];
if (in_list(format_fields, column.fieldname) && data && data[column.fieldname] > 0) { if (format_fields.includes(column.fieldname) && data && data[column.fieldname] > 0) {
value = "<span style='color:green;'>" + value + "</span>"; value = "<span style='color:green;'>" + value + "</span>";
} }
return value; return value;

View File

@@ -96,7 +96,7 @@ frappe.query_reports["Sales Order Analysis"] = {
value = default_formatter(value, row, column, data); value = default_formatter(value, row, column, data);
let format_fields = ["delivered_qty", "billed_amount"]; let format_fields = ["delivered_qty", "billed_amount"];
if (in_list(format_fields, column.fieldname) && data && data[column.fieldname] > 0) { if (format_fields.includes(column.fieldname) && data && data[column.fieldname] > 0) {
value = "<span style='color:green;'>" + value + "</span>"; value = "<span style='color:green;'>" + value + "</span>";
} }

View File

@@ -257,7 +257,7 @@ erpnext.company.set_chart_of_accounts_options = function (doc) {
callback: function (r) { callback: function (r) {
if (!r.exc) { if (!r.exc) {
set_field_options("chart_of_accounts", [""].concat(r.message).join("\n")); set_field_options("chart_of_accounts", [""].concat(r.message).join("\n"));
if (in_list(r.message, selected_value)) if (r.message.includes(selected_value))
cur_frm.set_value("chart_of_accounts", selected_value); cur_frm.set_value("chart_of_accounts", selected_value);
} }
}, },

View File

@@ -306,7 +306,7 @@ def get_batches_by_oldest(item_code, warehouse):
@frappe.whitelist() @frappe.whitelist()
def split_batch(batch_no: str, item_code: str, warehouse: str, qty: float, new_batch_id: str | None = None): 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""" """Split the batch into a new batch"""
batch = frappe.get_doc(dict(doctype="Batch", item=item_code, batch_id=new_batch_id)).insert() batch = frappe.get_doc(doctype="Batch", item=item_code, batch_id=new_batch_id).insert()
qty = flt(qty) qty = flt(qty)
company = frappe.db.get_value("Warehouse", warehouse, "company") company = frappe.db.get_value("Warehouse", warehouse, "company")
@@ -330,22 +330,18 @@ def split_batch(batch_no: str, item_code: str, warehouse: str, qty: float, new_b
) )
stock_entry = frappe.get_doc( stock_entry = frappe.get_doc(
dict( doctype="Stock Entry",
doctype="Stock Entry", purpose="Repack",
purpose="Repack", company=company,
company=company, items=[
items=[ dict(
dict( item_code=item_code,
item_code=item_code, qty=qty,
qty=qty, s_warehouse=warehouse,
s_warehouse=warehouse, serial_and_batch_bundle=from_bundle_id,
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( ],
item_code=item_code, qty=qty, t_warehouse=warehouse, serial_and_batch_bundle=to_bundle_id
),
],
)
) )
stock_entry.set_stock_entry_type() stock_entry.set_stock_entry_type()
stock_entry.insert() stock_entry.insert()

View File

@@ -45,12 +45,10 @@ class TestBatch(IntegrationTestCase):
self.make_batch_item("ITEM-BATCH-1") self.make_batch_item("ITEM-BATCH-1")
receipt = frappe.get_doc( receipt = frappe.get_doc(
dict( doctype="Purchase Receipt",
doctype="Purchase Receipt", supplier="_Test Supplier",
supplier="_Test Supplier", company="_Test Company",
company="_Test Company", items=[dict(item_code="ITEM-BATCH-1", qty=batch_qty, rate=10, warehouse="Stores - _TC")],
items=[dict(item_code="ITEM-BATCH-1", qty=batch_qty, rate=10, warehouse="Stores - _TC")],
)
).insert() ).insert()
receipt.submit() receipt.submit()
@@ -66,12 +64,10 @@ class TestBatch(IntegrationTestCase):
self.make_batch_item("ITEM-BATCH-1") self.make_batch_item("ITEM-BATCH-1")
receipt = frappe.get_doc( receipt = frappe.get_doc(
dict( doctype="Purchase Receipt",
doctype="Purchase Receipt", supplier="_Test Supplier",
supplier="_Test Supplier", company="_Test Company",
company="_Test Company", items=[dict(item_code="ITEM-BATCH-1", qty=10, rate=10, warehouse="Stores - _TC")],
items=[dict(item_code="ITEM-BATCH-1", qty=10, rate=10, warehouse="Stores - _TC")],
)
).insert() ).insert()
receipt.submit() receipt.submit()
@@ -96,20 +92,18 @@ class TestBatch(IntegrationTestCase):
) )
receipt2 = frappe.get_doc( receipt2 = frappe.get_doc(
dict( doctype="Purchase Receipt",
doctype="Purchase Receipt", supplier="_Test Supplier",
supplier="_Test Supplier", company="_Test Company",
company="_Test Company", items=[
items=[ dict(
dict( item_code="ITEM-BATCH-1",
item_code="ITEM-BATCH-1", qty=20,
qty=20, rate=10,
rate=10, warehouse="_Test Warehouse - _TC",
warehouse="_Test Warehouse - _TC", serial_and_batch_bundle=bundle_id,
serial_and_batch_bundle=bundle_id, )
) ],
],
)
).insert() ).insert()
receipt2.submit() receipt2.submit()
@@ -135,20 +129,18 @@ class TestBatch(IntegrationTestCase):
self.make_batch_item("ITEM-BATCH-1") self.make_batch_item("ITEM-BATCH-1")
stock_entry = frappe.get_doc( stock_entry = frappe.get_doc(
dict( doctype="Stock Entry",
doctype="Stock Entry", purpose="Material Receipt",
purpose="Material Receipt", company="_Test Company",
company="_Test Company", items=[
items=[ dict(
dict( item_code="ITEM-BATCH-1",
item_code="ITEM-BATCH-1", qty=90,
qty=90, t_warehouse="_Test Warehouse - _TC",
t_warehouse="_Test Warehouse - _TC", cost_center="Main - _TC",
cost_center="Main - _TC", rate=10,
rate=10, )
) ],
],
)
) )
stock_entry.set_stock_entry_type() stock_entry.set_stock_entry_type()
@@ -187,20 +179,18 @@ class TestBatch(IntegrationTestCase):
) )
delivery_note = frappe.get_doc( delivery_note = frappe.get_doc(
dict( doctype="Delivery Note",
doctype="Delivery Note", customer="_Test Customer",
customer="_Test Customer", company=receipt.company,
company=receipt.company, items=[
items=[ dict(
dict( item_code=item_code,
item_code=item_code, qty=batch_qty,
qty=batch_qty, rate=10,
rate=10, warehouse=receipt.items[0].warehouse,
warehouse=receipt.items[0].warehouse, serial_and_batch_bundle=bundle_id,
serial_and_batch_bundle=bundle_id, )
) ],
],
)
).insert() ).insert()
delivery_note.submit() delivery_note.submit()
@@ -261,19 +251,17 @@ class TestBatch(IntegrationTestCase):
) )
stock_entry = frappe.get_doc( stock_entry = frappe.get_doc(
dict( doctype="Stock Entry",
doctype="Stock Entry", purpose="Material Issue",
purpose="Material Issue", company=receipt.company,
company=receipt.company, items=[
items=[ dict(
dict( item_code=item_code,
item_code=item_code, qty=batch_qty,
qty=batch_qty, s_warehouse=receipt.items[0].warehouse,
s_warehouse=receipt.items[0].warehouse, serial_and_batch_bundle=bundle_id,
serial_and_batch_bundle=bundle_id, )
) ],
],
)
) )
stock_entry.set_stock_entry_type() stock_entry.set_stock_entry_type()
@@ -373,7 +361,7 @@ class TestBatch(IntegrationTestCase):
"""Make a new stock entry for given target warehouse and batch name of item""" """Make a new stock entry for given target warehouse and batch name of item"""
if not frappe.db.exists("Batch", batch_name): if not frappe.db.exists("Batch", batch_name):
batch = frappe.get_doc(dict(doctype="Batch", item=item_name, batch_id=batch_name)).insert( batch = frappe.get_doc(doctype="Batch", item=item_name, batch_id=batch_name).insert(
ignore_permissions=True ignore_permissions=True
) )
batch.save() batch.save()
@@ -393,22 +381,20 @@ class TestBatch(IntegrationTestCase):
).make_serial_and_batch_bundle() ).make_serial_and_batch_bundle()
stock_entry = frappe.get_doc( stock_entry = frappe.get_doc(
dict( doctype="Stock Entry",
doctype="Stock Entry", purpose="Material Receipt",
purpose="Material Receipt", company="_Test Company",
company="_Test Company", items=[
items=[ dict(
dict( item_code=item_name,
item_code=item_name, qty=90,
qty=90, serial_and_batch_bundle=sn_doc.name,
serial_and_batch_bundle=sn_doc.name, t_warehouse=warehouse,
t_warehouse=warehouse, cost_center="Main - _TC",
cost_center="Main - _TC", rate=10,
rate=10, allow_zero_valuation_rate=1,
allow_zero_valuation_rate=1, )
) ],
],
)
) )
stock_entry.set_stock_entry_type() stock_entry.set_stock_entry_type()

View File

@@ -56,7 +56,7 @@ frappe.ui.form.on("Inventory Dimension", {
]; ];
frm.fields.forEach((field) => { frm.fields.forEach((field) => {
if (!in_list(allow_to_edit_fields, field.df.fieldname)) { if (!allow_to_edit_fields.includes(field.df.fieldname)) {
frm.set_df_property(field.df.fieldname, "read_only", "1"); frm.set_df_property(field.df.fieldname, "read_only", "1");
} }
}); });

View File

@@ -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); 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_code = frm.doc.name;
new_child_doc.item_name = frm.doc.item_name; new_child_doc.item_name = frm.doc.item_name;
if (in_list(SALES_DOCTYPES, doctype) && frm.doc.sales_uom) { if (SALES_DOCTYPES.includes(doctype) && frm.doc.sales_uom) {
new_child_doc.uom = frm.doc.sales_uom; new_child_doc.uom = frm.doc.sales_uom;
} else if (in_list(PURCHASE_DOCTYPES, doctype) && frm.doc.purchase_uom) { } else if (PURCHASE_DOCTYPES.includes(doctype) && frm.doc.purchase_uom) {
new_child_doc.uom = frm.doc.purchase_uom; new_child_doc.uom = frm.doc.purchase_uom;
} else { } else {
new_child_doc.uom = frm.doc.stock_uom; new_child_doc.uom = frm.doc.stock_uom;

View File

@@ -30,9 +30,9 @@ frappe.ui.form.on("Item Variant Settings", {
field_label_map[d.fieldname] = __(d.label, null, d.parent) + ` (${d.fieldname})`; field_label_map[d.fieldname] = __(d.label, null, d.parent) + ` (${d.fieldname})`;
if ( if (
!in_list(exclude_field_types, d.fieldtype) && !exclude_field_types.includes(d.fieldtype) &&
!d.no_copy && !d.no_copy &&
!in_list(exclude_fields, d.fieldname) !exclude_fields.includes(d.fieldname)
) { ) {
allow_fields.push({ allow_fields.push({
label: field_label_map[d.fieldname], label: field_label_map[d.fieldname],

View File

@@ -1290,10 +1290,11 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle
// Clear Work Order record from locals, because it is updated via Stock Entry // Clear Work Order record from locals, because it is updated via Stock Entry
if ( if (
this.frm.doc.work_order && this.frm.doc.work_order &&
in_list( [
["Manufacture", "Material Transfer for Manufacture", "Material Consumption for Manufacture"], "Manufacture",
this.frm.doc.purpose "Material Transfer for Manufacture",
) "Material Consumption for Manufacture",
].includes(this.frm.doc.purpose)
) { ) {
frappe.model.remove_from_locals("Work Order", this.frm.doc.work_order); frappe.model.remove_from_locals("Work Order", this.frm.doc.work_order);
} }

View File

@@ -13,12 +13,10 @@ class TestStockSettings(IntegrationTestCase):
def test_settings(self): def test_settings(self):
item = frappe.get_doc( item = frappe.get_doc(
dict( doctype="Item",
doctype="Item", item_code="Item for description test",
item_code="Item for description test", item_group="Products",
item_group="Products", description='<p><span style="font-size: 12px;">Drawing No. 07-xxx-PO132<br></span><span style="font-size: 12px;">1800 x 1685 x 750<br></span><span style="font-size: 12px;">All parts made of Marine Ply<br></span><span style="font-size: 12px;">Top w/ Corian dd<br></span><span style="font-size: 12px;">CO, CS, VIP Day Cabin</span></p>',
description='<p><span style="font-size: 12px;">Drawing No. 07-xxx-PO132<br></span><span style="font-size: 12px;">1800 x 1685 x 750<br></span><span style="font-size: 12px;">All parts made of Marine Ply<br></span><span style="font-size: 12px;">Top w/ Corian dd<br></span><span style="font-size: 12px;">CO, CS, VIP Day Cabin</span></p>',
)
).insert() ).insert()
settings = frappe.get_single("Stock Settings") settings = frappe.get_single("Stock Settings")
@@ -40,12 +38,10 @@ class TestStockSettings(IntegrationTestCase):
settings.save() settings.save()
item = frappe.get_doc( item = frappe.get_doc(
dict( doctype="Item",
doctype="Item", item_code="Item for description test",
item_code="Item for description test", item_group="Products",
item_group="Products", description='<p><span style="font-size: 12px;">Drawing No. 07-xxx-PO132<br></span><span style="font-size: 12px;">1800 x 1685 x 750<br></span><span style="font-size: 12px;">All parts made of Marine Ply<br></span><span style="font-size: 12px;">Top w/ Corian dd<br></span><span style="font-size: 12px;">CO, CS, VIP Day Cabin</span></p>',
description='<p><span style="font-size: 12px;">Drawing No. 07-xxx-PO132<br></span><span style="font-size: 12px;">1800 x 1685 x 750<br></span><span style="font-size: 12px;">All parts made of Marine Ply<br></span><span style="font-size: 12px;">Top w/ Corian dd<br></span><span style="font-size: 12px;">CO, CS, VIP Day Cabin</span></p>',
)
).insert() ).insert()
self.assertEqual( self.assertEqual(

View File

@@ -26,17 +26,15 @@ def send_message(sender, message, subject="Website Query"):
lead = frappe.db.get_value("Lead", dict(email_id=sender)) lead = frappe.db.get_value("Lead", dict(email_id=sender))
if not lead: if not lead:
new_lead = frappe.get_doc( new_lead = frappe.get_doc(
dict(doctype="Lead", email_id=sender, lead_name=sender.split("@")[0].title()) doctype="Lead", email_id=sender, lead_name=sender.split("@")[0].title()
).insert(ignore_permissions=True) ).insert(ignore_permissions=True)
opportunity = frappe.get_doc( opportunity = frappe.get_doc(
dict( doctype="Opportunity",
doctype="Opportunity", opportunity_from="Customer" if customer else "Lead",
opportunity_from="Customer" if customer else "Lead", status="Open",
status="Open", title=subject,
title=subject, contact_email=sender,
contact_email=sender,
)
) )
if customer: if customer: