Skip to content

Commit 7577e60

Browse files
committed
Merge branch 'develop' into Abdeali/account-category-enhancement
2 parents c3fa967 + d2e039a commit 7577e60

File tree

25 files changed

+227
-29
lines changed

25 files changed

+227
-29
lines changed

erpnext/assets/doctype/asset_capitalization/asset_capitalization.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ erpnext.assets.AssetCapitalization = class AssetCapitalization extends erpnext.s
1616

1717
refresh() {
1818
this.show_general_ledger();
19+
erpnext.toggle_serial_batch_fields(this.frm);
1920

2021
if (this.frm.doc.stock_items && this.frm.doc.stock_items.length) {
2122
this.show_stock_ledger();

erpnext/crm/doctype/lead/lead.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from frappe.contacts.doctype.address.address import get_default_address
1111
from frappe.contacts.doctype.contact.contact import get_default_contact
1212
from frappe.email.inbox import link_communication_to_document
13+
from frappe.model.document import Document
1314
from frappe.model.mapper import get_mapped_doc
1415
from frappe.utils import comma_and, get_link_to_form, has_gravatar, validate_email_address
1516

@@ -314,7 +315,7 @@ def create_prospect(self, company_name):
314315

315316

316317
@frappe.whitelist()
317-
def make_customer(source_name, target_doc=None):
318+
def make_customer(source_name: str, target_doc: str | Document | None = None):
318319
return _make_customer(source_name, target_doc)
319320

320321

@@ -361,7 +362,7 @@ def set_missing_values(source, target):
361362

362363

363364
@frappe.whitelist()
364-
def make_opportunity(source_name, target_doc=None):
365+
def make_opportunity(source_name: str, target_doc: str | Document | None = None):
365366
def set_missing_values(source, target):
366367
_set_missing_values(source, target)
367368

@@ -391,7 +392,7 @@ def set_missing_values(source, target):
391392

392393

393394
@frappe.whitelist()
394-
def make_quotation(source_name, target_doc=None):
395+
def make_quotation(source_name: str, target_doc: str | Document | None = None):
395396
def set_missing_values(source, target):
396397
_set_missing_values(source, target)
397398

erpnext/crm/doctype/opportunity/opportunity.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from frappe import _
99
from frappe.contacts.address_and_contact import load_address_and_contact
1010
from frappe.email.inbox import link_communication_to_document
11+
from frappe.model.document import Document
1112
from frappe.model.mapper import get_mapped_doc
1213
from frappe.query_builder import DocType, Interval
1314
from frappe.query_builder.functions import Now
@@ -380,7 +381,7 @@ def get_item_details(item_code):
380381

381382

382383
@frappe.whitelist()
383-
def make_quotation(source_name, target_doc=None):
384+
def make_quotation(source_name: str, target_doc: str | Document | None = None):
384385
def set_missing_values(source, target):
385386
from erpnext.controllers.accounts_controller import get_default_taxes_and_charges
386387

@@ -433,7 +434,7 @@ def set_missing_values(source, target):
433434

434435

435436
@frappe.whitelist()
436-
def make_request_for_quotation(source_name, target_doc=None):
437+
def make_request_for_quotation(source_name: str, target_doc: str | Document | None = None):
437438
def update_item(obj, target, source_parent):
438439
target.conversion_factor = 1.0
439440

@@ -455,7 +456,7 @@ def update_item(obj, target, source_parent):
455456

456457

457458
@frappe.whitelist()
458-
def make_customer(source_name, target_doc=None):
459+
def make_customer(source_name: str, target_doc: str | Document | None = None):
459460
def set_missing_values(source, target):
460461
target.opportunity_name = source.name
461462

@@ -479,7 +480,7 @@ def set_missing_values(source, target):
479480

480481

481482
@frappe.whitelist()
482-
def make_supplier_quotation(source_name, target_doc=None):
483+
def make_supplier_quotation(source_name: str, target_doc: str | Document | None = None):
483484
doclist = get_mapped_doc(
484485
"Opportunity",
485486
source_name,

erpnext/crm/doctype/prospect/prospect.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
delete_contact_and_address,
77
load_address_and_contact,
88
)
9+
from frappe.model.document import Document
910
from frappe.model.mapper import get_mapped_doc
1011

1112
from erpnext.crm.utils import CRMNote, copy_comments, link_communications, link_open_events
@@ -87,7 +88,7 @@ def link_with_lead_contact_and_address(self):
8788

8889

8990
@frappe.whitelist()
90-
def make_customer(source_name, target_doc=None):
91+
def make_customer(source_name: str, target_doc: str | Document | None = None):
9192
def set_missing_values(source, target):
9293
target.customer_type = "Company"
9394
target.company_name = source.name
@@ -111,7 +112,7 @@ def set_missing_values(source, target):
111112

112113

113114
@frappe.whitelist()
114-
def make_opportunity(source_name, target_doc=None):
115+
def make_opportunity(source_name: str, target_doc: str | Document | None = None):
115116
def set_missing_values(source, target):
116117
target.opportunity_from = "Prospect"
117118
target.customer_name = source.company_name

erpnext/hooks.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,16 @@
219219
{"from_route": "/tasks", "to_route": "Task"},
220220
]
221221

222+
standard_navbar_items = [
223+
{
224+
"item_label": "Clear Demo Data",
225+
"item_type": "Action",
226+
"action": "erpnext.demo.clear_demo();",
227+
"is_standard": 1,
228+
"condition": "eval: frappe.boot.sysdefaults.demo_company",
229+
},
230+
]
231+
222232
standard_portal_menu_items = [
223233
{"title": "Projects", "route": "/project", "reference_doctype": "Project", "role": "Customer"},
224234
{

erpnext/patches.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,4 +470,5 @@ erpnext.patches.v15_0.delete_quotation_lost_record_detail
470470
erpnext.patches.v16_0.add_portal_redirects
471471
erpnext.patches.v16_0.update_order_qty_and_requested_qty_based_on_mr_and_po
472472
erpnext.patches.v16_0.complete_onboarding_steps_for_older_sites #2
473+
erpnext.patches.v16_0.enable_serial_batch_setting
473474
erpnext.patches.v16_0.set_root_type_in_account_categories
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import frappe
2+
3+
4+
def execute():
5+
if not frappe.get_all("Serial No", limit=1) and not frappe.get_all("Batch", limit=1):
6+
return
7+
8+
frappe.db.set_single_value("Stock Settings", "enable_serial_and_batch_no_for_item", 1)
9+
frappe.db.set_default("enable_serial_and_batch_no_for_item", 1)

erpnext/public/js/controllers/transaction.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
580580
this.validate_has_items();
581581
erpnext.utils.view_serial_batch_nos(this.frm);
582582
this.set_route_options_for_new_doc();
583+
erpnext.toggle_serial_batch_fields(this.frm);
583584
}
584585

585586
set_route_options_for_new_doc() {

erpnext/public/js/utils.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,71 @@ $.extend(erpnext, {
1919
return currency_list;
2020
},
2121

22+
toggle_serial_batch_fields(frm) {
23+
let hide_fields = cint(frappe.user_defaults?.enable_serial_and_batch_no_for_item) === 0 ? 1 : 0;
24+
let fields = ["serial_and_batch_bundle", "use_serial_batch_fields", "serial_no", "batch_no"];
25+
26+
if (
27+
[
28+
"Stock Entry",
29+
"Purchase Receipt",
30+
"Purchase Invoice",
31+
"Stock Reconciliation",
32+
"Subcontracting Receipt",
33+
].includes(frm.doc.doctype)
34+
) {
35+
fields.push("add_serial_batch_bundle");
36+
}
37+
38+
if (["Stock Reconciliation"].includes(frm.doc.doctype)) {
39+
fields.push("reconcile_all_serial_batch");
40+
}
41+
42+
if (["Sales Invoice", "Delivery Note", "Pick List"].includes(frm.doc.doctype)) {
43+
fields.push("pick_serial_and_batch");
44+
}
45+
46+
if (["Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"].includes(frm.doc.doctype)) {
47+
fields.push("add_serial_batch_for_rejected_qty", "rejected_serial_and_batch_bundle");
48+
}
49+
50+
let child_name = "items";
51+
if (frm.doc.doctype === "Pick List") {
52+
child_name = "locations";
53+
}
54+
55+
if (frm.doc.doctype === "Asset Capitalization") {
56+
child_name = "stock_items";
57+
}
58+
59+
fields.forEach((field) => {
60+
frm.fields_dict[child_name].grid.update_docfield_property(field, "hidden", hide_fields);
61+
62+
frm.fields_dict[child_name].grid.update_docfield_property(
63+
field,
64+
"in_list_view",
65+
hide_fields ? 0 : 1
66+
);
67+
68+
if (
69+
frm.doc.doctype === "Subcontracting Receipt" &&
70+
!["add_serial_batch_for_rejected_qty", "rejected_serial_and_batch_bundle"].includes(field)
71+
) {
72+
frm.fields_dict["supplied_items"].grid.update_docfield_property(field, "hidden", hide_fields);
73+
74+
frm.fields_dict["supplied_items"].grid.update_docfield_property(
75+
field,
76+
"in_list_view",
77+
hide_fields ? 0 : 1
78+
);
79+
80+
frm.fields_dict["supplied_items"].grid.reset_grid();
81+
}
82+
});
83+
84+
frm.fields_dict[child_name].grid.reset_grid();
85+
},
86+
2287
toggle_naming_series: function () {
2388
if (
2489
cur_frm &&

erpnext/setup/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ def set_defaults_for_tests():
221221
frappe.db.set_default(key, value)
222222
frappe.db.set_single_value("Stock Settings", "auto_insert_price_list_rate_if_missing", 0)
223223

224+
frappe.db.set_single_value("Stock Settings", "enable_serial_and_batch_no_for_item", 1)
225+
224226

225227
def insert_record(records):
226228
from frappe.desk.page.setup_wizard.setup_wizard import make_records

0 commit comments

Comments
 (0)