From fc86df64532dfd63d01d27ba2ba99b0e0720a530 Mon Sep 17 00:00:00 2001 From: Anurag Mishra <32095923+Anurag810@users.noreply.github.com> Date: Sat, 18 May 2019 13:03:08 +0530 Subject: [PATCH] fix: Allow return if delivery note or sales order is required in selling settings(v12) (#17631) * fix: Allow retrun if delivery note or sales order is required in selling settings * fix: combined condition * style: refactor --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index ae253cc2f3a..20b5fb391e2 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -501,12 +501,15 @@ class SalesInvoice(SellingController): def so_dn_required(self): """check in manage account if sales order / delivery note required or not.""" + if self.is_return: + return dic = {'Sales Order':['so_required', 'is_pos'],'Delivery Note':['dn_required', 'update_stock']} for i in dic: if frappe.db.get_single_value('Selling Settings', dic[i][0]) == 'Yes': for d in self.get('items'): - if (d.item_code and frappe.get_cached_value('Item', d.item_code, 'is_stock_item') == 1 - and not d.get(i.lower().replace(' ','_')) and not self.get(dic[i][1])): + is_stock_item = frappe.get_cached_value('Item', d.item_code, 'is_stock_item') + if d.item_code and is_stock_item == 1\ + and not d.get(i.lower().replace(' ','_')) and not self.get(dic[i][1]): msgprint(_("{0} is mandatory for Item {1}").format(i,d.item_code), raise_exception=1)