Skip to content

Commit

Permalink
fix: Partially Ordered status for quotation
Browse files Browse the repository at this point in the history
(cherry picked from commit 118c786)

# Conflicts:
#	erpnext/selling/doctype/quotation/quotation.json
  • Loading branch information
deepeshgarg007 authored and mergify[bot] committed Jun 14, 2022
1 parent a1ba847 commit 37ba550
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
3 changes: 2 additions & 1 deletion erpnext/controllers/status_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def validate_status(status, options):
["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": [
Expand Down
2 changes: 1 addition & 1 deletion erpnext/selling/doctype/quotation/quotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
6 changes: 5 additions & 1 deletion erpnext/selling/doctype/quotation/quotation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
28 changes: 26 additions & 2 deletions erpnext/selling/doctype/quotation/quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,32 @@ def validate_shopping_cart_items(self):
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:
Expand Down
2 changes: 2 additions & 0 deletions erpnext/selling/doctype/quotation/quotation_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

1 comment on commit 37ba550

@tukutela
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi all, removing the method has_sales_order() has caused an error when using declare_enquiry_lost() in the same module.

Please sign in to comment.