diff --git a/erpnext/patches/v13_0/set_return_against_in_pos_invoice_references.py b/erpnext/patches/v13_0/set_return_against_in_pos_invoice_references.py index 6c24f520274..6af9617bcee 100644 --- a/erpnext/patches/v13_0/set_return_against_in_pos_invoice_references.py +++ b/erpnext/patches/v13_0/set_return_against_in_pos_invoice_references.py @@ -2,18 +2,19 @@ import frappe def execute(): - ''' + """ Fetch and Set is_return & return_against from POS Invoice in POS Invoice References table. - ''' + """ POSClosingEntry = frappe.qb.DocType("POS Closing Entry") open_pos_closing_entries = ( - frappe.qb - .from_(POSClosingEntry) - .select(POSClosingEntry.name) - .where(POSClosingEntry.docstatus == 0) - .run(pluck=True) - ) + frappe.qb.from_(POSClosingEntry) + .select(POSClosingEntry.name) + .where(POSClosingEntry.docstatus == 0) + .run() + ) + if open_pos_closing_entries: + open_pos_closing_entries = [d[0] for d in open_pos_closing_entries] if not open_pos_closing_entries: return @@ -21,13 +22,12 @@ def execute(): POSInvoiceReference = frappe.qb.DocType("POS Invoice Reference") POSInvoice = frappe.qb.DocType("POS Invoice") pos_invoice_references = ( - frappe.qb - .from_(POSInvoiceReference) - .join(POSInvoice) - .on(POSInvoiceReference.pos_invoice == POSInvoice.name) - .select(POSInvoiceReference.name, POSInvoice.is_return, POSInvoice.return_against) - .where(POSInvoiceReference.parent.isin(open_pos_closing_entries)) - .run(as_dict=True) + frappe.qb.from_(POSInvoiceReference) + .join(POSInvoice) + .on(POSInvoiceReference.pos_invoice == POSInvoice.name) + .select(POSInvoiceReference.name, POSInvoice.is_return, POSInvoice.return_against) + .where(POSInvoiceReference.parent.isin(open_pos_closing_entries)) + .run(as_dict=True) ) for row in pos_invoice_references: