Skip to content

Commit

Permalink
Merge pull request #41942 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
ruthra-kumar authored Jun 19, 2024
2 parents 32fba94 + ee49e83 commit 8902895
Show file tree
Hide file tree
Showing 39 changed files with 206 additions and 114 deletions.
6 changes: 5 additions & 1 deletion erpnext/accounts/doctype/fiscal_year/fiscal_year.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"icon": "fa fa-calendar",
"idx": 1,
"links": [],
"modified": "2020-11-05 12:16:53.081573",
"modified": "2024-05-27 17:29:55.560840",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Fiscal Year",
Expand Down Expand Up @@ -126,6 +126,10 @@
{
"read": 1,
"role": "Stock Manager"
},
{
"read": 1,
"role": "Auditor"
}
],
"show_name_in_global_search": 1,
Expand Down
6 changes: 3 additions & 3 deletions erpnext/accounts/doctype/journal_entry/journal_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ frappe.ui.form.on("Journal Entry", {
!(frm.doc.accounts || []).length ||
((frm.doc.accounts || []).length === 1 && !frm.doc.accounts[0].account)
) {
if (in_list(["Bank Entry", "Cash Entry"], frm.doc.voucher_type)) {
if (["Bank Entry", "Cash Entry"].includes(frm.doc.voucher_type)) {
return frappe.call({
type: "GET",
method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_default_bank_cash_account",
Expand Down Expand Up @@ -283,7 +283,7 @@ erpnext.accounts.JournalEntry = class JournalEntry extends frappe.ui.form.Contro
filters: [[jvd.reference_type, "docstatus", "=", 1]],
};

if (in_list(["Sales Invoice", "Purchase Invoice"], jvd.reference_type)) {
if (["Sales Invoice", "Purchase Invoice"].includes(jvd.reference_type)) {
out.filters.push([jvd.reference_type, "outstanding_amount", "!=", 0]);
// Filter by cost center
if (jvd.cost_center) {
Expand All @@ -295,7 +295,7 @@ erpnext.accounts.JournalEntry = class JournalEntry extends frappe.ui.form.Contro
out.filters.push([jvd.reference_type, party_account_field, "=", jvd.account]);
}

if (in_list(["Sales Order", "Purchase Order"], jvd.reference_type)) {
if (["Sales Order", "Purchase Order"].includes(jvd.reference_type)) {
// party_type and party mandatory
frappe.model.validate_missing(jvd, "party_type");
frappe.model.validate_missing(jvd, "party");
Expand Down
16 changes: 8 additions & 8 deletions erpnext/accounts/doctype/payment_entry/payment_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ frappe.ui.form.on('Payment Entry', {
frm.set_query("paid_from", function() {
frm.events.validate_company(frm);

var account_types = in_list(["Pay", "Internal Transfer"], frm.doc.payment_type) ?
var account_types = ["Pay", "Internal Transfer"].includes(frm.doc.payment_type) ?
["Bank", "Cash"] : [frappe.boot.party_account_types[frm.doc.party_type]];
return {
filters: {
Expand Down Expand Up @@ -75,7 +75,7 @@ frappe.ui.form.on('Payment Entry', {
frm.set_query("paid_to", function() {
frm.events.validate_company(frm);

var account_types = in_list(["Receive", "Internal Transfer"], frm.doc.payment_type) ?
var account_types = ["Receive", "Internal Transfer"].includes(frm.doc.payment_type) ?
["Bank", "Cash"] : [frappe.boot.party_account_types[frm.doc.party_type]];
return {
filters: {
Expand Down Expand Up @@ -121,7 +121,7 @@ frappe.ui.form.on('Payment Entry', {

frm.set_query('payment_term', 'references', function(frm, cdt, cdn) {
const child = locals[cdt][cdn];
if (in_list(['Purchase Invoice', 'Sales Invoice'], child.reference_doctype) && child.reference_name) {
if (['Purchase Invoice', 'Sales Invoice'].includes(child.reference_doctype) && child.reference_name) {
return {
query: "erpnext.controllers.queries.get_payment_terms_for_references",
filters: {
Expand Down Expand Up @@ -485,7 +485,7 @@ frappe.ui.form.on('Payment Entry', {
if (frm.doc.paid_from_account_currency == company_currency) {
frm.set_value("source_exchange_rate", 1);
} else if (frm.doc.paid_from){
if (in_list(["Internal Transfer", "Pay"], frm.doc.payment_type)) {
if (["Internal Transfer", "Pay"].includes(frm.doc.payment_type)) {
let company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
frappe.call({
method: "erpnext.setup.utils.get_exchange_rate",
Expand Down Expand Up @@ -853,7 +853,7 @@ frappe.ui.form.on('Payment Entry', {
}

var allocated_positive_outstanding = paid_amount + allocated_negative_outstanding;
} else if (in_list(["Customer", "Supplier"], frm.doc.party_type)) {
} else if (["Customer", "Supplier"].includes(frm.doc.party_type)) {
total_negative_outstanding = flt(total_negative_outstanding, precision("outstanding_amount"))
if(paid_amount > total_negative_outstanding) {
if(total_negative_outstanding == 0) {
Expand Down Expand Up @@ -988,15 +988,15 @@ frappe.ui.form.on('Payment Entry', {
}

if(frm.doc.party_type=="Customer" &&
!in_list(["Sales Order", "Sales Invoice", "Journal Entry", "Dunning"], row.reference_doctype)
!["Sales Order", "Sales Invoice", "Journal Entry", "Dunning"].includes(row.reference_doctype)
) {
frappe.model.set_value(row.doctype, row.name, "reference_doctype", null);
frappe.msgprint(__("Row #{0}: Reference Document Type must be one of Sales Order, Sales Invoice, Journal Entry or Dunning", [row.idx]));
return false;
}

if(frm.doc.party_type=="Supplier" &&
!in_list(["Purchase Order", "Purchase Invoice", "Journal Entry"], row.reference_doctype)
!["Purchase Order", "Purchase Invoice", "Journal Entry"].includes(row.reference_doctype)
) {
frappe.model.set_value(row.doctype, row.name, "against_voucher_type", null);
frappe.msgprint(__("Row #{0}: Reference Document Type must be one of Purchase Order, Purchase Invoice or Journal Entry", [row.idx]));
Expand Down Expand Up @@ -1080,7 +1080,7 @@ frappe.ui.form.on('Payment Entry', {

bank_account: function(frm) {
const field = frm.doc.payment_type == "Pay" ? "paid_from":"paid_to";
if (frm.doc.bank_account && in_list(['Pay', 'Receive'], frm.doc.payment_type)) {
if (frm.doc.bank_account && ['Pay', 'Receive'].includes(frm.doc.payment_type)) {
frappe.call({
method: "erpnext.accounts.doctype.bank_account.bank_account.get_bank_account_details",
args: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ frappe.ui.form.on("Payment Request", "refresh", function (frm) {
if (
frm.doc.payment_request_type == "Inward" &&
frm.doc.payment_channel !== "Phone" &&
!in_list(["Initiated", "Paid"], frm.doc.status) &&
!["Initiated", "Paid"].includes(frm.doc.status) &&
!frm.doc.__islocal &&
frm.doc.docstatus == 1
) {
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/sales_invoice/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
if(cur_frm.meta._default_print_format) {
cur_frm.meta.default_print_format = cur_frm.meta._default_print_format;
cur_frm.meta._default_print_format = null;
} else if(in_list([cur_frm.pos_print_format, cur_frm.return_print_format], cur_frm.meta.default_print_format)) {
} else if([cur_frm.pos_print_format, cur_frm.return_print_format].includes(cur_frm.meta.default_print_format)) {
cur_frm.meta.default_print_format = null;
cur_frm.meta._default_print_format = null;
}
Expand Down
6 changes: 3 additions & 3 deletions erpnext/assets/doctype/asset/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ frappe.ui.form.on("Asset", {
frm.events.make_schedules_editable(frm);

if (frm.doc.docstatus == 1) {
if (in_list(["Submitted", "Partially Depreciated", "Fully Depreciated"], frm.doc.status)) {
if (["Submitted", "Partially Depreciated", "Fully Depreciated"].includes(frm.doc.status)) {
frm.add_custom_button(
__("Transfer Asset"),
function () {
Expand Down Expand Up @@ -280,7 +280,7 @@ frappe.ui.form.on("Asset", {
if (v.journal_entry) {
asset_values.push(asset_value);
} else {
if (in_list(["Scrapped", "Sold"], frm.doc.status)) {
if (["Scrapped", "Sold"].includes(frm.doc.status)) {
asset_values.push(null);
} else {
asset_values.push(asset_value);
Expand Down Expand Up @@ -312,7 +312,7 @@ frappe.ui.form.on("Asset", {
});
}

if (in_list(["Scrapped", "Sold"], frm.doc.status)) {
if (["Scrapped", "Sold"].includes(frm.doc.status)) {
x_intervals.push(frappe.format(frm.doc.disposal_date, { fieldtype: "Date" }));
asset_values.push(0);
}
Expand Down
8 changes: 4 additions & 4 deletions erpnext/buying/doctype/purchase_order/purchase_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ frappe.provide("erpnext.accounts.dimensions");
{% include 'erpnext/public/js/controllers/buying.js' %};

frappe.ui.form.on("Purchase Order", {
setup: function(frm) {

setup: function (frm) {
frm.ignore_doctypes_on_cancel_all = ["Unreconcile Payment", "Unreconcile Payment Entries"];
if (frm.doc.is_old_subcontracting_flow) {
frm.set_query("reserve_warehouse", "supplied_items", function() {
return {
Expand Down Expand Up @@ -180,7 +180,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
this.frm.fields_dict.items_section.wrapper.removeClass("hide-border");
}

if(!in_list(["Closed", "Delivered"], doc.status)) {
if(!["Closed", "Delivered"].includes(doc.status)) {
if(this.frm.doc.status !== 'Closed' && flt(this.frm.doc.per_received) < 100 && flt(this.frm.doc.per_billed) < 100) {
// Don't add Update Items button if the PO is following the new subcontracting flow.
if (!(this.frm.doc.is_subcontracted && !this.frm.doc.is_old_subcontracting_flow)) {
Expand Down Expand Up @@ -211,7 +211,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e

this.frm.page.set_inner_btn_group_as_primary(__("Status"));
}
} else if(in_list(["Closed", "Delivered"], doc.status)) {
} else if(["Closed", "Delivered"].includes(doc.status)) {
if (this.frm.has_perm("submit")) {
this.frm.add_custom_button(__('Re-open'), () => this.unclose_purchase_order(), __("Status"));
}
Expand Down
8 changes: 7 additions & 1 deletion erpnext/buying/doctype/purchase_order/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,13 @@ def on_submit(self):
update_linked_doc(self.doctype, self.name, self.inter_company_order_reference)

def on_cancel(self):
self.ignore_linked_doctypes = ("GL Entry", "Payment Ledger Entry")
self.ignore_linked_doctypes = (
"GL Entry",
"Payment Ledger Entry",
"Unreconcile Payment",
"Unreconcile Payment Entries",
)

super().on_cancel()

if self.is_against_so():
Expand Down
8 changes: 8 additions & 0 deletions erpnext/controllers/buying_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from frappe.utils import cint, cstr, flt, getdate
from frappe.utils.data import nowtime

import erpnext
from erpnext.accounts.doctype.budget.budget import validate_expense_against_budget
from erpnext.accounts.party import get_party_details
from erpnext.buying.utils import update_last_purchase_rate, validate_for_items
Expand Down Expand Up @@ -305,6 +306,8 @@ def update_valuation_rate(self, reset_outgoing_rate=True):
else:
item.valuation_rate = 0.0

update_regional_item_valuation_rate(self)

def set_incoming_rate(self):
if self.doctype not in ("Purchase Receipt", "Purchase Invoice", "Purchase Order"):
return
Expand Down Expand Up @@ -894,3 +897,8 @@ def validate_item_type(doc, fieldname, message):
).format(items, message)

frappe.throw(error_message)


@erpnext.allow_regional
def update_regional_item_valuation_rate(doc):
pass
8 changes: 6 additions & 2 deletions erpnext/controllers/stock_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def validate(self):
self.validate_internal_transfer()
self.validate_putaway_capacity()

def make_gl_entries(self, gl_entries=None, from_repost=False):
def make_gl_entries(self, gl_entries=None, from_repost=False, via_landed_cost_voucher=False):
if self.docstatus == 2:
make_reverse_gl_entries(voucher_type=self.doctype, voucher_no=self.name)

Expand All @@ -72,7 +72,11 @@ def make_gl_entries(self, gl_entries=None, from_repost=False):

if self.docstatus == 1:
if not gl_entries:
gl_entries = self.get_gl_entries(warehouse_account)
gl_entries = (
self.get_gl_entries(warehouse_account, via_landed_cost_voucher)
if self.doctype == "Purchase Receipt"
else self.get_gl_entries(warehouse_account)
)
make_gl_entries(gl_entries, from_repost=from_repost)

def validate_serialized_batch(self):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/manufacturing/doctype/bom/bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ frappe.ui.form.on("BOM", {
},

rm_cost_as_per(frm) {
if (in_list(["Valuation Rate", "Last Purchase Rate"], frm.doc.rm_cost_as_per)) {
if (["Valuation Rate", "Last Purchase Rate"].includes(frm.doc.rm_cost_as_per)) {
frm.set_value("plc_conversion_rate", 1.0);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ frappe.ui.form.on("Production Plan", {
if (
frm.doc.mr_items &&
frm.doc.mr_items.length &&
!in_list(["Material Requested", "Closed"], frm.doc.status)
!["Material Requested", "Closed"].includes(frm.doc.status)
) {
frm.add_custom_button(
__("Material Request"),
Expand Down
4 changes: 2 additions & 2 deletions erpnext/manufacturing/doctype/work_order/work_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ frappe.ui.form.on("Work Order", {
},

add_custom_button_to_return_components: function (frm) {
if (frm.doc.docstatus === 1 && in_list(["Closed", "Completed"], frm.doc.status)) {
if (frm.doc.docstatus === 1 && ["Closed", "Completed"].includes(frm.doc.status)) {
let non_consumed_items = frm.doc.required_items.filter((d) => {
return flt(d.consumed_qty) < flt(d.transferred_qty - d.returned_qty);
});
Expand Down Expand Up @@ -594,7 +594,7 @@ erpnext.work_order = {
);
}

if (doc.docstatus === 1 && !in_list(["Closed", "Completed"], doc.status)) {
if (doc.docstatus === 1 && !["Closed", "Completed"].includes(doc.status)) {
if (doc.status != "Stopped" && doc.status != "Completed") {
frm.add_custom_button(
__("Stop"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ def execute():

dt = frappe.qb.DocType(doctype)
records = (
frappe.qb.from_(dt)
.select(dt.name, dt.notes, dt.modified_by, dt.modified)
.where(dt.notes.isnotnull() & dt.notes != "")
frappe.qb.from_(dt).select(dt.name, dt.notes).where(dt.notes.isnotnull() & dt.notes != "")
).run(as_dict=True)

for d in records:
if strip_html(cstr(d.notes)).strip():
doc = frappe.get_doc(doctype, d.name)
doc.append("notes", {"note": d.notes, "added_by": d.modified_by, "added_on": d.modified})
doc.append("notes", {"note": d.notes})
doc.update_child_table("notes")

frappe.db.sql_ddl(f"alter table `tab{doctype}` drop column `notes`")
2 changes: 1 addition & 1 deletion erpnext/public/js/account_tree_grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ erpnext.AccountTreeGrid = class AccountTreeGrid extends frappe.views.TreeGridRep
flt(account.closing_dr) -
flt(account.closing_cr);
me.set_debit_or_credit(parent_account, "closing", bal);
} else if (in_list(["debit", "credit"], col.field)) {
} else if (["debit", "credit"].includes(col.field)) {
parent_account[col.field] =
flt(parent_account[col.field]) + flt(account[col.field]);
}
Expand Down
2 changes: 1 addition & 1 deletion erpnext/public/js/communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ frappe.ui.form.on("Communication", {
);
}

if (!in_list(["Lead", "Opportunity"], frm.doc.reference_doctype)) {
if (!["Lead", "Opportunity"].includes(frm.doc.reference_doctype)) {
frm.add_custom_button(
__("Lead"),
() => {
Expand Down
2 changes: 1 addition & 1 deletion erpnext/public/js/controllers/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ frappe.ui.form.on(cur_frm.doctype, {
setup: function(frm) {
// set conditional display for rate column in taxes
$(frm.wrapper).on('grid-row-render', function(e, grid_row) {
if(in_list(['Sales Taxes and Charges', 'Purchase Taxes and Charges'], grid_row.doc.doctype)) {
if(['Sales Taxes and Charges', 'Purchase Taxes and Charges'].includes(grid_row.doc.doctype)) {
erpnext.taxes.set_conditional_mandatory_rate_or_amount(grid_row);
}
});
Expand Down
2 changes: 1 addition & 1 deletion erpnext/public/js/controllers/buying.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ erpnext.buying.BuyingController = class BuyingController extends erpnext.Transac
}

toggle_subcontracting_fields() {
if (in_list(['Purchase Receipt', 'Purchase Invoice'], this.frm.doc.doctype)) {
if (['Purchase Receipt', 'Purchase Invoice'].includes(this.frm.doc.doctype)) {
this.frm.fields_dict.supplied_items.grid.update_docfield_property('consumed_qty',
'read_only', this.frm.doc.__onload && this.frm.doc.__onload.backflush_based_on === 'BOM');

Expand Down
Loading

0 comments on commit 8902895

Please sign in to comment.