From 9d829532420689bb2d4692b77180f3c47c54e3b5 Mon Sep 17 00:00:00 2001 From: Anupam K Date: Thu, 6 Aug 2020 23:58:56 +0530 Subject: [PATCH 1/3] fix: Opportunity Status fix --- erpnext/selling/doctype/quotation/quotation.py | 17 ++++++++--------- .../selling/doctype/sales_order/sales_order.py | 1 - 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 449a968a4f..01479a1654 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -25,7 +25,6 @@ class Quotation(SellingController): def validate(self): super(Quotation, self).validate() self.set_status() - self.update_opportunity() self.validate_uom_is_integer("stock_uom", "qty") self.validate_valid_till() self.set_customer_name() @@ -50,20 +49,20 @@ class Quotation(SellingController): lead_name, company_name = frappe.db.get_value("Lead", self.party_name, ["lead_name", "company_name"]) self.customer_name = company_name or lead_name - def update_opportunity(self): + def update_opportunity(self, status): for opportunity in list(set([d.prevdoc_docname for d in self.get("items")])): if opportunity: - self.update_opportunity_status(opportunity) + self.update_opportunity_status(status, opportunity) if self.opportunity: - self.update_opportunity_status() + self.update_opportunity_status(status) - def update_opportunity_status(self, opportunity=None): + def update_opportunity_status(self, status, opportunity=None): if not opportunity: opportunity = self.opportunity opp = frappe.get_doc("Opportunity", opportunity) - opp.status = None + opp.status = status opp.set_status(update=True) def declare_enquiry_lost(self, lost_reasons_list, detailed_reason=None): @@ -82,7 +81,7 @@ class Quotation(SellingController): else: frappe.throw(_("Invalid lost reason {0}, please create a new lost reason").format(frappe.bold(reason.get('lost_reason')))) - self.update_opportunity() + self.update_opportunity('Lost') self.update_lead() self.save() @@ -95,7 +94,7 @@ class Quotation(SellingController): self.company, self.base_grand_total, self) #update enquiry status - self.update_opportunity() + self.update_opportunity('Quotation') self.update_lead() def on_cancel(self): @@ -105,7 +104,7 @@ class Quotation(SellingController): #update enquiry status self.set_status(update=True) - self.update_opportunity() + self.update_opportunity('Open') self.update_lead() def print_other_charges(self,docname): diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index ffb66354fa..f17af69e5b 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -159,7 +159,6 @@ class SalesOrder(SellingController): frappe.throw(_("Quotation {0} is cancelled").format(quotation)) doc.set_status(update=True) - doc.update_opportunity() def validate_drop_ship(self): for d in self.get('items'): From 73d944da21045d1f6387b5fc583e37e37850c30d Mon Sep 17 00:00:00 2001 From: Anupam Date: Tue, 13 Oct 2020 18:11:05 +0530 Subject: [PATCH 2/3] fix: review changes --- erpnext/selling/doctype/quotation/quotation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 7c55d7742f..3157982d52 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -62,7 +62,7 @@ class Quotation(SellingController): opportunity = self.opportunity opp = frappe.get_doc("Opportunity", opportunity) - opp.status = status + opp.set_status(status=status) opp.set_status(update=True) def declare_enquiry_lost(self, lost_reasons_list, detailed_reason=None): From aff3f611d35dd5c6538a16e4bcebf32c2f06d138 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Mon, 11 Jan 2021 12:48:11 +0530 Subject: [PATCH 3/3] fix: allow medication entries to be deleted from the table --- .../inpatient_medication_entry.js | 1 + .../inpatient_medication_entry.json | 3 +-- .../inpatient_medication_entry.py | 18 ------------------ 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.js b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.js index ca97489b8d..a7b06b1718 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.js +++ b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.js @@ -5,6 +5,7 @@ frappe.ui.form.on('Inpatient Medication Entry', { refresh: function(frm) { // Ignore cancellation of doctype on cancel all frm.ignore_doctypes_on_cancel_all = ['Stock Entry']; + frm.fields_dict['medication_orders'].grid.wrapper.find('.grid-add-row').hide(); frm.set_query('item_code', () => { return { diff --git a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.json b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.json index dd4c423a9e..b1a6ee4ed1 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.json +++ b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.json @@ -139,7 +139,6 @@ "fieldtype": "Table", "label": "Inpatient Medication Orders", "options": "Inpatient Medication Entry Detail", - "read_only": 1, "reqd": 1 }, { @@ -180,7 +179,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2020-11-03 13:22:37.820707", + "modified": "2021-01-11 12:37:46.749659", "modified_by": "Administrator", "module": "Healthcare", "name": "Inpatient Medication Entry", diff --git a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py index 70ae713866..bba521313d 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py +++ b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py @@ -15,8 +15,6 @@ class InpatientMedicationEntry(Document): self.validate_medication_orders() def get_medication_orders(self): - self.validate_datetime_filters() - # pull inpatient medication orders based on selected filters orders = get_pending_medication_orders(self) @@ -27,22 +25,6 @@ class InpatientMedicationEntry(Document): self.set('medication_orders', []) frappe.msgprint(_('No pending medication orders found for selected criteria')) - def validate_datetime_filters(self): - if self.from_date and self.to_date: - self.validate_from_to_dates('from_date', 'to_date') - - if self.from_date and getdate(self.from_date) > getdate(): - frappe.throw(_('From Date cannot be after the current date.')) - - if self.to_date and getdate(self.to_date) > getdate(): - frappe.throw(_('To Date cannot be after the current date.')) - - if self.from_time and self.from_time > nowtime(): - frappe.throw(_('From Time cannot be after the current time.')) - - if self.to_time and self.to_time > nowtime(): - frappe.throw(_('To Time cannot be after the current time.')) - def add_mo_to_table(self, orders): # Add medication orders in the child table self.set('medication_orders', [])