From de937a6badca9f7af0ed8530b2d164dd4a1e2c9b Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 23 May 2025 13:50:46 +0530 Subject: [PATCH 1/4] refactor: full name field in contract (cherry picked from commit 016924361a781c94c821c18c438bb93df1aa9efd) # Conflicts: # erpnext/crm/doctype/contract/contract.json # erpnext/crm/doctype/contract/contract.py --- erpnext/crm/doctype/contract/contract.json | 15 +++++++- erpnext/crm/doctype/contract/contract.py | 40 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/erpnext/crm/doctype/contract/contract.json b/erpnext/crm/doctype/contract/contract.json index de3230f0e67..4c76adeb248 100755 --- a/erpnext/crm/doctype/contract/contract.json +++ b/erpnext/crm/doctype/contract/contract.json @@ -14,6 +14,7 @@ "party_user", "status", "fulfilment_status", + "party_full_name", "sb_terms", "start_date", "cb_date", @@ -244,11 +245,22 @@ "fieldname": "authorised_by_section", "fieldtype": "Section Break", "label": "Authorised By" + }, + { + "fieldname": "party_full_name", + "fieldtype": "Data", + "label": "Party Full Name", + "read_only": 1 } ], + "grid_page_length": 50, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2020-12-07 11:15:58.385521", +======= + "modified": "2025-05-23 13:54:03.346537", +>>>>>>> 016924361a (refactor: full name field in contract) "modified_by": "Administrator", "module": "CRM", "name": "Contract", @@ -315,9 +327,10 @@ "write": 1 } ], + "row_format": "Dynamic", "show_name_in_global_search": 1, "sort_field": "modified", "sort_order": "DESC", "track_changes": 1, "track_seen": 1 -} \ No newline at end of file +} diff --git a/erpnext/crm/doctype/contract/contract.py b/erpnext/crm/doctype/contract/contract.py index db23d570644..849fce7ba1a 100644 --- a/erpnext/crm/doctype/contract/contract.py +++ b/erpnext/crm/doctype/contract/contract.py @@ -9,6 +9,46 @@ from frappe.utils import getdate, nowdate class Contract(Document): +<<<<<<< HEAD +======= + # begin: auto-generated types + # This code is auto-generated. Do not modify anything in this block. + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from frappe.types import DF + + from erpnext.crm.doctype.contract_fulfilment_checklist.contract_fulfilment_checklist import ( + ContractFulfilmentChecklist, + ) + + amended_from: DF.Link | None + contract_template: DF.Link | None + contract_terms: DF.TextEditor + document_name: DF.DynamicLink | None + document_type: DF.Literal[ + "", "Quotation", "Project", "Sales Order", "Purchase Order", "Sales Invoice", "Purchase Invoice" + ] + end_date: DF.Date | None + fulfilment_deadline: DF.Date | None + fulfilment_status: DF.Literal["N/A", "Unfulfilled", "Partially Fulfilled", "Fulfilled", "Lapsed"] + fulfilment_terms: DF.Table[ContractFulfilmentChecklist] + ip_address: DF.Data | None + is_signed: DF.Check + party_full_name: DF.Data | None + party_name: DF.DynamicLink + party_type: DF.Literal["Customer", "Supplier", "Employee"] + party_user: DF.Link | None + requires_fulfilment: DF.Check + signed_by_company: DF.Link | None + signed_on: DF.Datetime | None + signee: DF.Data | None + start_date: DF.Date | None + status: DF.Literal["Unsigned", "Active", "Inactive"] + # end: auto-generated types + +>>>>>>> 016924361a (refactor: full name field in contract) def autoname(self): name = self.party_name From 05911ad563604a62f5c51f27432b542d3c41b6b6 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 23 May 2025 14:04:07 +0530 Subject: [PATCH 2/4] refactor: fetch party name on selection (cherry picked from commit 752024e222b9d74b4193f410bf4a3ec840810b28) --- erpnext/crm/doctype/contract/contract.js | 6 ++++++ erpnext/crm/doctype/contract/contract.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/erpnext/crm/doctype/contract/contract.js b/erpnext/crm/doctype/contract/contract.js index 8d44c22db28..42bd7f9b769 100644 --- a/erpnext/crm/doctype/contract/contract.js +++ b/erpnext/crm/doctype/contract/contract.js @@ -29,4 +29,10 @@ frappe.ui.form.on("Contract", { }); } }, + party_name: function (frm) { + let field = frm.doc.party_type.toLowerCase() + "_name"; + frappe.db.get_value(frm.doc.party_type, frm.doc.party_name, field, (r) => { + frm.set_value("party_full_name", r[field]); + }); + }, }); diff --git a/erpnext/crm/doctype/contract/contract.py b/erpnext/crm/doctype/contract/contract.py index 849fce7ba1a..eb1dcbfa957 100644 --- a/erpnext/crm/doctype/contract/contract.py +++ b/erpnext/crm/doctype/contract/contract.py @@ -63,10 +63,17 @@ class Contract(Document): self.name = _(name) def validate(self): + self.set_missing_values() self.validate_dates() self.update_contract_status() self.update_fulfilment_status() + def set_missing_values(self): + if not self.party_full_name: + field = self.party_type.lower() + "_name" + if res := frappe.db.get_value(self.party_type, self.party_name, field): + self.party_full_name = res + def before_submit(self): self.signed_by_company = frappe.session.user From caf145e3ca5fa696e5cb6c96d1a574fd9f54f99a Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 23 May 2025 14:24:50 +0530 Subject: [PATCH 3/4] refactor: patch old contract with full party name (cherry picked from commit 8e2221178b00f8f148ad38bb90a6928ade9bdc23) # Conflicts: # erpnext/patches.txt --- erpnext/patches.txt | 9 +++++++++ .../patches/v14_0/update_full_name_in_contract.py | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 erpnext/patches/v14_0/update_full_name_in_contract.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 83e4c7bb569..f6ee99c86c3 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -375,4 +375,13 @@ erpnext.stock.doctype.stock_ledger_entry.patches.ensure_sle_indexes erpnext.patches.v14_0.rename_group_by_to_categorize_by execute:frappe.db.set_single_value("Accounts Settings", "receivable_payable_fetch_method", "Buffered Cursor") erpnext.patches.v14_0.set_update_price_list_based_on +<<<<<<< HEAD erpnext.patches.v14_0.rename_group_by_to_categorize_by_in_custom_reports +======= +erpnext.patches.v15_0.update_journal_entry_type +erpnext.patches.v15_0.set_grand_total_to_default_mop +execute:frappe.db.set_single_value("Accounts Settings", "use_new_budget_controller", True) +erpnext.patches.v15_0.rename_group_by_to_categorize_by_in_custom_reports +erpnext.patches.v15_0.remove_agriculture_roles +erpnext.patches.v14_0.update_full_name_in_contract +>>>>>>> 8e2221178b (refactor: patch old contract with full party name) diff --git a/erpnext/patches/v14_0/update_full_name_in_contract.py b/erpnext/patches/v14_0/update_full_name_in_contract.py new file mode 100644 index 00000000000..19ee055ad12 --- /dev/null +++ b/erpnext/patches/v14_0/update_full_name_in_contract.py @@ -0,0 +1,15 @@ +import frappe +from frappe import qb + + +def execute(): + con = qb.DocType("Contract") + for c in ( + qb.from_(con) + .select(con.name, con.party_type, con.party_name) + .where(con.party_full_name.isnull()) + .run(as_dict=True) + ): + field = c.party_type.lower() + "_name" + if res := frappe.db.get_value(c.party_type, c.party_name, field): + frappe.db.set_value("Contract", c.name, "party_full_name", res) From 274ce1032913dc56b4844f0f1eb8443664a4db3c Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 26 May 2025 17:46:10 +0530 Subject: [PATCH 4/4] chore: resolve conflicts --- erpnext/crm/doctype/contract/contract.json | 4 --- erpnext/crm/doctype/contract/contract.py | 40 ---------------------- erpnext/patches.txt | 8 ----- 3 files changed, 52 deletions(-) diff --git a/erpnext/crm/doctype/contract/contract.json b/erpnext/crm/doctype/contract/contract.json index 4c76adeb248..948243402fe 100755 --- a/erpnext/crm/doctype/contract/contract.json +++ b/erpnext/crm/doctype/contract/contract.json @@ -256,11 +256,7 @@ "grid_page_length": 50, "is_submittable": 1, "links": [], -<<<<<<< HEAD - "modified": "2020-12-07 11:15:58.385521", -======= "modified": "2025-05-23 13:54:03.346537", ->>>>>>> 016924361a (refactor: full name field in contract) "modified_by": "Administrator", "module": "CRM", "name": "Contract", diff --git a/erpnext/crm/doctype/contract/contract.py b/erpnext/crm/doctype/contract/contract.py index eb1dcbfa957..f30d576213f 100644 --- a/erpnext/crm/doctype/contract/contract.py +++ b/erpnext/crm/doctype/contract/contract.py @@ -9,46 +9,6 @@ from frappe.utils import getdate, nowdate class Contract(Document): -<<<<<<< HEAD -======= - # begin: auto-generated types - # This code is auto-generated. Do not modify anything in this block. - - from typing import TYPE_CHECKING - - if TYPE_CHECKING: - from frappe.types import DF - - from erpnext.crm.doctype.contract_fulfilment_checklist.contract_fulfilment_checklist import ( - ContractFulfilmentChecklist, - ) - - amended_from: DF.Link | None - contract_template: DF.Link | None - contract_terms: DF.TextEditor - document_name: DF.DynamicLink | None - document_type: DF.Literal[ - "", "Quotation", "Project", "Sales Order", "Purchase Order", "Sales Invoice", "Purchase Invoice" - ] - end_date: DF.Date | None - fulfilment_deadline: DF.Date | None - fulfilment_status: DF.Literal["N/A", "Unfulfilled", "Partially Fulfilled", "Fulfilled", "Lapsed"] - fulfilment_terms: DF.Table[ContractFulfilmentChecklist] - ip_address: DF.Data | None - is_signed: DF.Check - party_full_name: DF.Data | None - party_name: DF.DynamicLink - party_type: DF.Literal["Customer", "Supplier", "Employee"] - party_user: DF.Link | None - requires_fulfilment: DF.Check - signed_by_company: DF.Link | None - signed_on: DF.Datetime | None - signee: DF.Data | None - start_date: DF.Date | None - status: DF.Literal["Unsigned", "Active", "Inactive"] - # end: auto-generated types - ->>>>>>> 016924361a (refactor: full name field in contract) def autoname(self): name = self.party_name diff --git a/erpnext/patches.txt b/erpnext/patches.txt index f6ee99c86c3..1d051fd2489 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -375,13 +375,5 @@ erpnext.stock.doctype.stock_ledger_entry.patches.ensure_sle_indexes erpnext.patches.v14_0.rename_group_by_to_categorize_by execute:frappe.db.set_single_value("Accounts Settings", "receivable_payable_fetch_method", "Buffered Cursor") erpnext.patches.v14_0.set_update_price_list_based_on -<<<<<<< HEAD erpnext.patches.v14_0.rename_group_by_to_categorize_by_in_custom_reports -======= -erpnext.patches.v15_0.update_journal_entry_type -erpnext.patches.v15_0.set_grand_total_to_default_mop -execute:frappe.db.set_single_value("Accounts Settings", "use_new_budget_controller", True) -erpnext.patches.v15_0.rename_group_by_to_categorize_by_in_custom_reports -erpnext.patches.v15_0.remove_agriculture_roles erpnext.patches.v14_0.update_full_name_in_contract ->>>>>>> 8e2221178b (refactor: patch old contract with full party name)