fix: refactor

This commit is contained in:
Afshan 2020-11-10 13:19:21 +05:30
parent cdc17bb9f3
commit 1924019531

View File

@ -386,14 +386,12 @@ class SellingController(StockController):
po_nos = []
self.get_po_nos('Sales Order', 'against_sales_order', po_nos)
self.get_po_nos('Sales Invoice', 'against_sales_invoice', po_nos)
self.po_no = ', '.join(list(set(po_nos)))
self.po_no = ', '.join(list(set((x.strip() for x in ','.join(po_nos).split(',')))))
def get_po_nos(self, ref_doctype, ref_fieldname, po_nos):
doc_list = list(set([d.get(ref_fieldname) for d in self.items if d.get(ref_fieldname)]))
if doc_list:
po_no_list = frappe.get_all(ref_doctype, 'po_no', filters = {'name': ('in', doc_list)})
if po_no_list and po_no_list[0].get('po_no'):
po_nos += [d.po_no for d in po_no_list if d.po_no]
po_nos += [d.po_no for d in frappe.get_all(ref_doctype, 'po_no', filters = {'name': ('in', doc_list)}) if d.get('po_no')]
def set_gross_profit(self):
if self.doctype in ["Sales Order", "Quotation"]: