From d3759394756cc2679b5002a296690b5689c2e081 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 10 Jun 2022 19:23:17 +0530 Subject: [PATCH 1/5] fix: Company address filter in quotation (cherry picked from commit 2fc04f661ac0dc3df1f6d1cc2bd37920f7c98917) --- erpnext/selling/doctype/quotation/quotation.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 474cf56fc1b..34062fd1a88 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -20,6 +20,20 @@ frappe.ui.form.on('Quotation', { frm.set_df_property('packed_items', 'cannot_add_rows', true); frm.set_df_property('packed_items', 'cannot_delete_rows', true); + + frm.set_query('company_address', function(doc) { + if(!doc.company) { + frappe.throw(__('Please set Company')); + } + + return { + query: 'frappe.contacts.doctype.address.address.address_query', + filters: { + link_doctype: 'Company', + link_name: doc.company + } + }; + }); }, refresh: function(frm) { From a1ba8475d03202e601227f2db1e4d0f2eefa8ecc Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 10 Jun 2022 22:05:58 +0530 Subject: [PATCH 2/5] fix(India): Sales taxes and charges template fetching in quotation (cherry picked from commit 243625898ee884b641c5fcbb437ce35e77eb22d9) --- erpnext/accounts/party.py | 2 +- erpnext/regional/india/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 177624ca032..f07fc64737c 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -212,7 +212,7 @@ def set_address_details( else: party_details.update(get_company_address(company)) - if doctype and doctype in ["Delivery Note", "Sales Invoice", "Sales Order"]: + if doctype and doctype in ["Delivery Note", "Sales Invoice", "Sales Order", "Quotation"]: if party_details.company_address: party_details.update( get_fetch_values(doctype, "company_address", party_details.company_address) diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index 88c899734ed..eb9d6743e13 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -288,7 +288,7 @@ def get_regional_address_details(party_details, doctype, company): return party_details if ( - doctype in ("Sales Invoice", "Delivery Note", "Sales Order") + doctype in ("Sales Invoice", "Delivery Note", "Sales Order", "Quotation") and party_details.company_gstin and party_details.company_gstin[:2] != party_details.place_of_supply[:2] ) or ( From 37ba5503987b55e41a174437bca9c99232d256b1 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 11 Jun 2022 21:55:59 +0530 Subject: [PATCH 3/5] fix: Partially Ordered status for quotation (cherry picked from commit 118c786e63173413864dfd0f08a1748eef377059) # Conflicts: # erpnext/selling/doctype/quotation/quotation.json --- erpnext/controllers/status_updater.py | 3 +- .../selling/doctype/quotation/quotation.js | 2 +- .../selling/doctype/quotation/quotation.json | 6 +++- .../selling/doctype/quotation/quotation.py | 28 +++++++++++++++++-- .../doctype/quotation/quotation_list.js | 2 ++ 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 3c0a10e0860..517e080c972 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -35,7 +35,8 @@ status_map = { ["Draft", None], ["Open", "eval:self.docstatus==1"], ["Lost", "eval:self.status=='Lost'"], - ["Ordered", "has_sales_order"], + ["Partially Ordered", "is_partially_ordered"], + ["Ordered", "is_fully_ordered"], ["Cancelled", "eval:self.docstatus==2"], ], "Sales Order": [ diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 34062fd1a88..3bb9774044a 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -83,7 +83,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ } } - if(doc.docstatus == 1 && doc.status!=='Lost') { + if(doc.docstatus == 1 && !(['Lost', 'Ordered']).includes(doc.status)) { if(!doc.valid_till || frappe.datetime.get_diff(doc.valid_till, frappe.datetime.get_today()) >= 0) { cur_frm.add_custom_button(__('Sales Order'), cur_frm.cscript['Make Sales Order'], __('Create')); diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json index dcc0c784639..c819dafd106 100644 --- a/erpnext/selling/doctype/quotation/quotation.json +++ b/erpnext/selling/doctype/quotation/quotation.json @@ -1084,7 +1084,7 @@ "no_copy": 1, "oldfieldname": "status", "oldfieldtype": "Select", - "options": "Draft\nOpen\nReplied\nOrdered\nLost\nCancelled\nExpired", + "options": "Draft\nOpen\nReplied\nPartially Ordered\nOrdered\nLost\nCancelled\nExpired", "print_hide": 1, "read_only": 1, "reqd": 1, @@ -1174,7 +1174,11 @@ "idx": 82, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2022-03-23 16:49:36.297403", +======= + "modified": "2022-06-11 20:35:32.635804", +>>>>>>> 118c786e63 (fix: Partially Ordered status for quotation) "modified_by": "Administrator", "module": "Selling", "name": "Quotation", diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 5759b504cee..ceb922c0e53 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -59,8 +59,32 @@ class Quotation(SellingController): title=_("Unpublished Item"), ) - def has_sales_order(self): - return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.name, "docstatus": 1}) + def get_ordered_status(self): + ordered_items = frappe._dict( + frappe.db.get_all( + "Sales Order Item", + {"prevdoc_docname": self.name, "docstatus": 1}, + ["item_code", "sum(qty)"], + group_by="item_code", + as_list=1, + ) + ) + + status = "Open" + if ordered_items: + status = "Ordered" + + for item in self.get("items"): + if item.qty > ordered_items.get(item.item_code, 0.0): + status = "Partially Ordered" + + return status + + def is_fully_ordered(self): + return self.get_ordered_status() == "Ordered" + + def is_partially_ordered(self): + return self.get_ordered_status() == "Partially Ordered" def update_lead(self): if self.quotation_to == "Lead" and self.party_name: diff --git a/erpnext/selling/doctype/quotation/quotation_list.js b/erpnext/selling/doctype/quotation/quotation_list.js index b631685bd19..93da1bd122f 100644 --- a/erpnext/selling/doctype/quotation/quotation_list.js +++ b/erpnext/selling/doctype/quotation/quotation_list.js @@ -17,6 +17,8 @@ frappe.listview_settings['Quotation'] = { get_indicator: function(doc) { if(doc.status==="Open") { return [__("Open"), "orange", "status,=,Open"]; + } else if(doc.status==="Partially Ordered") { + return [__("Partially Ordered"), "yellow", "status,=,Partially Ordered"]; } else if(doc.status==="Ordered") { return [__("Ordered"), "green", "status,=,Ordered"]; } else if(doc.status==="Lost") { From 823cf88c3c66fe66dbf29f63c9fe6a329d9fe0c7 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 14 Jun 2022 10:50:38 +0530 Subject: [PATCH 4/5] chore: linting issues (cherry picked from commit fb3da124e5ca97ab0194a1da21f40f8e4db30f90) --- erpnext/selling/doctype/quotation/quotation_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/quotation/quotation_list.js b/erpnext/selling/doctype/quotation/quotation_list.js index 93da1bd122f..990f449a209 100644 --- a/erpnext/selling/doctype/quotation/quotation_list.js +++ b/erpnext/selling/doctype/quotation/quotation_list.js @@ -17,7 +17,7 @@ frappe.listview_settings['Quotation'] = { get_indicator: function(doc) { if(doc.status==="Open") { return [__("Open"), "orange", "status,=,Open"]; - } else if(doc.status==="Partially Ordered") { + } else if (doc.status==="Partially Ordered") { return [__("Partially Ordered"), "yellow", "status,=,Partially Ordered"]; } else if(doc.status==="Ordered") { return [__("Ordered"), "green", "status,=,Ordered"]; From da1a948a2842eabea89e2cada04548d6260a47ea Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 14 Jun 2022 11:36:43 +0530 Subject: [PATCH 5/5] chore: resolve conflicts --- erpnext/selling/doctype/quotation/quotation.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json index c819dafd106..eeaa4fda585 100644 --- a/erpnext/selling/doctype/quotation/quotation.json +++ b/erpnext/selling/doctype/quotation/quotation.json @@ -1174,11 +1174,7 @@ "idx": 82, "is_submittable": 1, "links": [], -<<<<<<< HEAD - "modified": "2022-03-23 16:49:36.297403", -======= "modified": "2022-06-11 20:35:32.635804", ->>>>>>> 118c786e63 (fix: Partially Ordered status for quotation) "modified_by": "Administrator", "module": "Selling", "name": "Quotation", @@ -1274,4 +1270,4 @@ "sort_order": "DESC", "timeline_field": "party_name", "title_field": "title" -} \ No newline at end of file +}