diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.js b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.js index 4938e6690e5..2f2b9e876a8 100644 --- a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.js +++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.js @@ -50,6 +50,7 @@ frappe.ui.form.on("Opening Invoice Creation Tool", { refresh: function (frm) { frm.disable_save(); + frm.trigger("create_missing_party"); !frm.doc.import_in_progress && frm.trigger("make_dashboard"); frm.page.set_primary_action(__("Create Invoices"), () => { let btn_primary = frm.page.btn_primary.get(0); @@ -162,9 +163,35 @@ frappe.ui.form.on("Opening Invoice Creation Tool", { row.party_type = frm.doc.invoice_type == "Sales" ? "Customer" : "Supplier"; }); }, + + create_missing_party: function (frm) { + if (frm.doc.create_missing_party) { + frm.fields_dict["invoices"].grid.update_docfield_property("party", "reqd", 0); + frm.fields_dict["invoices"].grid.update_docfield_property("party_name", "read_only", 0); + } else { + frm.fields_dict["invoices"].grid.update_docfield_property("party", "reqd", 1); + frm.fields_dict["invoices"].grid.update_docfield_property("party_name", "read_only", 1); + } + frm.refresh_field("invoices"); + }, }); frappe.ui.form.on("Opening Invoice Creation Tool Item", { + party: function (frm, cdt, cdn) { + let row = locals[cdt][cdn]; + if (!row.party) { + frappe.model.set_value(cdt, cdn, "party_name", ""); + return; + } + + let party_type = frm.doc.invoice_type == "Sales" ? "Customer" : "Supplier"; + let name_field = party_type === "Customer" ? "customer_name" : "supplier_name"; + + frappe.db.get_value(party_type, row.party, name_field, (r) => { + frappe.model.set_value(cdt, cdn, "party_name", r?.[name_field] || ""); + }); + }, + invoices_add: (frm) => { frm.trigger("update_invoice_table"); }, diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.json b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.json index deeee72c18a..8d1c3e87ba1 100644 --- a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.json +++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.json @@ -8,9 +8,9 @@ "engine": "InnoDB", "field_order": [ "company", - "create_missing_party", "column_break_3", "invoice_type", + "create_missing_party", "accounting_dimensions_section", "cost_center", "dimension_col_break", @@ -29,7 +29,7 @@ }, { "default": "0", - "description": "Create missing customer or supplier.", + "description": "If party does not exist, create it using the Party Name field.", "fieldname": "create_missing_party", "fieldtype": "Check", "label": "Create Missing Party" @@ -65,10 +65,10 @@ "options": "Cost Center" }, { - "fieldname": "project", - "fieldtype": "Link", - "label": "Project", - "options": "Project" + "fieldname": "project", + "fieldtype": "Link", + "label": "Project", + "options": "Project" }, { "collapsible": 1, @@ -84,7 +84,7 @@ "hide_toolbar": 1, "issingle": 1, "links": [], - "modified": "2024-03-27 13:10:06.564397", + "modified": "2026-03-23 00:32:15.600086", "modified_by": "Administrator", "module": "Accounts", "name": "Opening Invoice Creation Tool", @@ -101,8 +101,9 @@ } ], "quick_entry": 1, + "row_format": "Dynamic", "sort_field": "creation", "sort_order": "DESC", "states": [], "track_changes": 1 -} \ No newline at end of file +} diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py index 2f3a893a73f..04d9bd544f6 100644 --- a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py +++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py @@ -32,6 +32,7 @@ class OpeningInvoiceCreationTool(Document): create_missing_party: DF.Check invoice_type: DF.Literal["Sales", "Purchase"] invoices: DF.Table[OpeningInvoiceCreationToolItem] + project: DF.Link | None # end: auto-generated types def onload(self): @@ -102,10 +103,21 @@ class OpeningInvoiceCreationTool(Document): row.due_date = row.due_date or nowdate() def validate_mandatory_invoice_fields(self, row): - if not frappe.db.exists(row.party_type, row.party): - if self.create_missing_party: + if self.create_missing_party: + if not row.party and not row.party_name: + frappe.throw(_("Row #{}: Either Party ID or Party Name is required").format(row.idx)) + + if not row.party and row.party_name: + self.add_party(row.party_type, row.party_name) + row.party = row.party_name + + if row.party and not frappe.db.exists(row.party_type, row.party): self.add_party(row.party_type, row.party) - else: + + else: + if not row.party: + frappe.throw(_("Row #{}: Party ID is required").format(row.idx)) + if not frappe.db.exists(row.party_type, row.party): frappe.throw( _("Row #{}: {} {} does not exist.").format( row.idx, frappe.bold(row.party_type), frappe.bold(row.party) @@ -113,7 +125,7 @@ class OpeningInvoiceCreationTool(Document): ) mandatory_error_msg = _("Row #{0}: {1} is required to create the Opening {2} Invoices") - for d in ("Party", "Outstanding Amount", "Temporary Opening Account"): + for d in ("Outstanding Amount", "Temporary Opening Account"): if not row.get(scrub(d)): frappe.throw(mandatory_error_msg.format(row.idx, d, self.invoice_type)) diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool_dashboard.html b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool_dashboard.html index afbcfa5602a..43be52717c3 100644 --- a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool_dashboard.html +++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool_dashboard.html @@ -1,5 +1,5 @@ {% $.each(data, (company, summary) => { %} -
{{ company }}
+
{{ company }}
@@ -23,7 +23,7 @@ - + {% endif %} {% }); %} diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.json b/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.json index 29daab42439..74ce2a6fb67 100644 --- a/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.json +++ b/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.json @@ -8,6 +8,7 @@ "invoice_number", "party_type", "party", + "party_name", "temporary_opening_account", "column_break_3", "posting_date", @@ -35,9 +36,9 @@ "fieldname": "party", "fieldtype": "Dynamic Link", "in_list_view": 1, - "label": "Party", - "options": "party_type", - "reqd": 1 + "label": "Party ID", + "mandatory_depends_on": "eval: !parent.create_missing_party", + "options": "party_type" }, { "fieldname": "temporary_opening_account", @@ -118,11 +119,17 @@ "fieldname": "supplier_invoice_date", "fieldtype": "Date", "label": "Supplier Invoice Date" + }, + { + "fieldname": "party_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Party Name" } ], "istable": 1, "links": [], - "modified": "2025-12-01 16:18:07.997594", + "modified": "2026-03-20 02:11:42.023575", "modified_by": "Administrator", "module": "Accounts", "name": "Opening Invoice Creation Tool Item", diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.py b/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.py index 1ea025322b4..38e97672c96 100644 --- a/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.py +++ b/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.py @@ -22,7 +22,8 @@ class OpeningInvoiceCreationToolItem(Document): parent: DF.Data parentfield: DF.Data parenttype: DF.Data - party: DF.DynamicLink + party: DF.DynamicLink | None + party_name: DF.Data | None party_type: DF.Link | None posting_date: DF.Date | None qty: DF.Data | None
{{ format_currency(summary[doctype].outstanding_amount, summary.currency, 2) }}