fix: Partially Ordered status for quotation

This commit is contained in:
Deepesh Garg 2022-06-11 21:55:59 +05:30
parent 243625898e
commit 118c786e63
5 changed files with 33 additions and 6 deletions

View File

@ -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": [

View File

@ -84,7 +84,7 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext.
}
}
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'));

View File

@ -897,7 +897,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
@ -986,7 +986,7 @@
"idx": 82,
"is_submittable": 1,
"links": [],
"modified": "2022-04-07 11:01:31.157084",
"modified": "2022-06-11 20:35:32.635804",
"modified_by": "Administrator",
"module": "Selling",
"name": "Quotation",

View File

@ -70,8 +70,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:

View File

@ -25,6 +25,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") {