def _get_cart_quotation(party=None):
 if (not party):
  party = get_party()
 quotation = frappe.get_all(u'Quotation', fields=[u'name'], filters={party.doctype.lower(): party.name, u'order_type': u'Shopping Cart', u'docstatus': 0}, order_by=u'modified desc', limit_page_length=1)
 if quotation:
  qdoc = frappe.get_doc(u'Quotation', quotation[0].name)
 else:
  qdoc = frappe.get_doc({u'doctype': u'Quotation', u'naming_series': (get_shopping_cart_settings().quotation_series or u'QTN-CART-'), u'quotation_to': party.doctype, u'company': frappe.db.get_value(u'Shopping Cart Settings', None, u'company'), u'order_type': u'Shopping Cart', u'status': u'Draft', u'docstatus': 0, u'__islocal': 1, party.doctype.lower(): party.name})
  qdoc.contact_person = frappe.db.get_value(u'Contact', {u'email_id': frappe.session.user})
  qdoc.contact_email = frappe.session.user
  qdoc.flags.ignore_permissions = True
  qdoc.run_method(u'set_missing_values')
  apply_cart_settings(party, qdoc)
 return qdoc

def _get_cart_quotation ( party = None ) : if ( not party ) : party = get_party ( ) quotation = frappe . get_all ( u'Quotation' , fields = [ u'name' ] , filters = { party . doctype . lower ( ) : party . name , u'order_type' : u'Shopping Cart' , u'docstatus' : 0 } , order_by = u'modified desc' , limit_page_length = 1 ) if quotation : qdoc = frappe . get_doc ( u'Quotation' , quotation [ 0 ] . name ) else : qdoc = frappe . get_doc ( { u'doctype' : u'Quotation' , u'naming_series' : ( get_shopping_cart_settings ( ) . quotation_series or u'QTN-CART-' ) , u'quotation_to' : party . doctype , u'company' : frappe . db . get_value ( u'Shopping Cart Settings' , None , u'company' ) , u'order_type' : u'Shopping Cart' , u'status' : u'Draft' , u'docstatus' : 0 , u'__islocal' : 1 , party . doctype . lower ( ) : party . name } ) qdoc . contact_person = frappe . db . get_value ( u'Contact' , { u'email_id' : frappe . session . user } ) qdoc . contact_email = frappe . session . user qdoc . flags . ignore_permissions = True qdoc . run_method ( u'set_missing_values' ) apply_cart_settings ( party , qdoc ) return qdoc
return the open quotation of type "shopping cart" or make a new one .