def fetch_and_set_address_display(doc, method): from erpnext.utilities.doctype.address.address import get_address_display if doc.customer_address and not doc.bill_to_address: doc.bill_to_address = get_address_display(doc.customer_address) if doc.shipping_address_name and not doc.shipping_address: doc.bill_to_address = get_address_display(doc.shipping_address_name)
def fetch_and_set_address_display(doc, method): from erpnext.utilities.doctype.address.address import get_address_display if doc.customer_address and not doc.bill_to_address: doc.bill_to_address = get_address_display(doc.customer_address) if doc.shipping_address_name and not doc.shipping_address: doc.bill_to_address = get_address_display(doc.shipping_address_name)
def set_address_details(out, party, party_type): billing_address_field = "customer_address" if party_type == "Lead" \ else party_type.lower() + "_address" out[billing_address_field] = frappe.db.get_value("Address", {party_type.lower(): party.name, "is_primary_address":1}, "name") # address display out.address_display = get_address_display(out[billing_address_field]) # shipping address if party_type in ["Customer", "Lead"]: out.shipping_address_name = frappe.db.get_value("Address", {party_type.lower(): party.name, "is_shipping_address":1}, "name") out.shipping_address = get_address_display(out["shipping_address_name"])
def set_address_details(out, party, party_type): billing_address_field = "customer_address" if party_type == "Lead" \ else party_type.lower() + "_address" out[billing_address_field] = frappe.db.get_value("Address", {party_type.lower(): party.name, "is_primary_address":1}, "name") # address display out.address_display = get_address_display(out[billing_address_field]) # shipping address if party_type in ["Customer", "Lead"]: out.shipping_address_name = frappe.db.get_value("Address", {party_type.lower(): party.name, "is_shipping_address":1}, "name") out.shipping_address = get_address_display(out["shipping_address_name"])
def selco_stock_entry_validate(doc,method): from erpnext.utilities.doctype.address.address import get_address_display if doc.type_of_stock_entry == "Outward DC": local_warehouse = frappe.db.get_value("Branch",doc.being_dispatched_to,"selco_warehouse") doc.branch_address_link = frappe.db.get_value("Warehouse",local_warehouse,"address") doc.branch_address = "<b>" + doc.being_dispatched_to.upper() + " BRANCH</b><br>" doc.branch_address += "SELCO SOLAR LIGHT PVT. LTD.<br>" doc.branch_address += str(get_address_display(doc.branch_address_link)) elif doc.type_of_stock_entry == "GRN": sender = frappe.db.get_value("Stock Entry",doc.suppliers_ref,"branch") sender_warehouse = frappe.db.get_value("Branch",sender,"selco_warehouse") doc.sender_address_link = frappe.db.get_value("Warehouse",sender_warehouse,"address") doc.sender_address = "<b>" + sender.upper() + " SELCO BRANCH</b><br>" doc.sender_address += "SELCO SOLAR LIGHT PVT. LTD.<br>" doc.sender_address += str(get_address_display(doc.sender_address_link))
def update_cart_address(address_fieldname, address_name): quotation = _get_cart_quotation() address_display = get_address_display(frappe.get_doc("Address", address_name).as_dict()) if address_fieldname == "shipping_address_name": quotation.shipping_address_name = address_name quotation.shipping_address = address_display if not quotation.customer_address: address_fieldname == "customer_address" if address_fieldname == "customer_address": quotation.customer_address = address_name quotation.address_display = address_display apply_cart_settings(quotation=quotation) quotation.flags.ignore_permissions = True quotation.save() context = get_cart_quotation(quotation) return { "taxes": frappe.render_template("templates/includes/order/order_taxes.html", context), }
def update_cart_address(address_fieldname, address_name): quotation = _get_cart_quotation() address_display = get_address_display(frappe.get_doc("Address", address_name).as_dict()) if address_fieldname == "shipping_address_name": quotation.shipping_address_name = address_name quotation.shipping_address = address_display if not quotation.customer_address: address_fieldname == "customer_address" if address_fieldname == "customer_address": quotation.customer_address = address_name quotation.address_display = address_display apply_cart_settings(quotation=quotation) quotation.flags.ignore_permissions = True quotation.save() context = get_cart_quotation(quotation) return { "taxes": frappe.render_template("templates/includes/order/order_taxes.html", context), }
def load_address_and_contact(doc, key): """Loads address list and contact list in `__onload`""" from erpnext.utilities.doctype.address.address import get_address_display doc.get("__onload").addr_list = [a.update({"display": get_address_display(a)}) \ for a in frappe.get_all("Address", fields="*", filters={key: doc.name}, order_by="is_primary_address desc, modified desc")] if doc.doctype != "Lead": doc.get("__onload").contact_list = frappe.get_all( "Contact", fields="*", filters={key: doc.name}, order_by="is_primary_contact desc, modified desc") if doc.doctype == "FFWW": doc.get("__onload").contact_list = frappe.get_all( "Contact", fields="*", filters={key: doc.customer}, order_by="is_primary_contact desc, modified desc") if doc.doctype != "Lead" and doc.doctype != "Supplier": doc.get("__onload").financial_list = frappe.get_all( "Financial Data", fields="*", filters={key: doc.name}, order_by="financial_year desc", limit_page_length=1)
def set_missing_values(source, target): target.customer = source.customer_id target.customer_name = source.customer_name target.run_method("set_missing_values") # set billing address if target.customer_address: target.bill_to_address = get_address_display(target.customer_address)
def get_address(customer): cust_add = frappe.db.sql( """select name from tabAddress where address_title = '%s' and customer = '%s' """ % (customer, customer), as_list=1) if cust_add: address = get_address_display(cust_add[0][0]) return address
def set_missing_values(source, target): target.customer = source.customer_id target.customer_name = source.customer_name target.run_method("set_missing_values") # set billing address if target.customer_address: target.bill_to_address = get_address_display( target.customer_address)
def load_address_and_contact(doc, key): """Loads address list and contact list in `__onload`""" from erpnext.utilities.doctype.address.address import get_address_display doc.get("__onload")["addr_list"] = [a.update({"display": get_address_display(a)}) \ for a in frappe.get_all("Address", fields="*", filters={key: doc.name}, order_by="is_primary_address desc, modified desc")] if doc.doctype != "Lead": doc.get("__onload")["contact_list"] = frappe.get_all("Contact", fields="*", filters={key: doc.name}, order_by="is_primary_contact desc, modified desc")
def get_address_docs(party=None): if not party: party = get_lead_or_customer() address_docs = frappe.db.sql("""select * from `tabAddress` where `%s`=%s order by name""" % (party.doctype.lower(), "%s"), party.name, as_dict=True, update={"doctype": "Address"}) for address in address_docs: address.display = get_address_display(address) address.display = (address.display).replace("\n", "<br>\n") return address_docs
def selco_add_new_address(branch,address_type,address_line1,address_line2,city,district,country,customer): from erpnext.utilities.doctype.address.address import get_address_display local_address = frappe.new_doc("Address") local_address.branch = branch local_address.address_type = address_type local_address.address_line1 = address_line1 local_address_line2 = address_line2 local_address.city = city local_address.district = district local_address.country = country local_address.customer = customer local_address.insert() return local_address.name,str(get_address_display(local_address.name))
def get_address_docs(party=None): if not party: party = get_lead_or_customer() address_docs = frappe.db.sql("""select * from `tabAddress` where `%s`=%s order by name""" % (party.doctype.lower(), "%s"), party.name, as_dict=True, update={"doctype": "Address"}) for address in address_docs: address.display = get_address_display(address) address.display = (address.display).replace("\n", "<br>\n") return address_docs
def get_address_docs(doctype=None, txt=None, filters=None, limit_start=0, limit_page_length=20, party=None): if not party: party = get_party() address_docs = frappe.db.sql("""select * from `tabAddress` where `{0}`=%s order by name limit {1}, {2}""".format(party.doctype.lower(), limit_start, limit_page_length), party.name, as_dict=True, update={"doctype": "Address"}) for address in address_docs: address.display = get_address_display(address) return address_docs
def update_accounts(source, target): target.is_pos = 0 target.ignore_pricing_rule = 1 target.run_method("set_missing_values") if len(target.get("entries")) == 0: frappe.throw(_("All these items have already been invoiced")) target.run_method("calculate_taxes_and_totals") # set billing address if target.customer_address: target.bill_to_address = get_address_display(target.customer_address)
def get_address_docs(doctype=None, txt=None, filters=None, limit_start=0, limit_page_length=20, party=None): if not party: party = get_customer() address_docs = frappe.db.sql("""select * from `tabAddress` where `{0}`=%s order by name limit {1}, {2}""".format(party.doctype.lower(), limit_start, limit_page_length), party.name, as_dict=True, update={"doctype": "Address"}) for address in address_docs: address.display = get_address_display(address) return address_docs
def get_address_docs(doctype, txt, filters, limit_start, limit_page_length=20, party=None): if not party: party = get_lead_or_customer() address_docs = frappe.db.sql("""select * from `tabAddress` where `{0}`=%s order by name limit {1}, {2}""".format(party.doctype.lower(), limit_start, limit_page_length), party.name, as_dict=True, update={"doctype": "Address"}) for address in address_docs: address.display = get_address_display(address) address.display = (address.display).replace("\n", "<br>\n") return address_docs
def load_address_and_contact(doc, key): """Loads address list and contact list in `__onload`""" from erpnext.utilities.doctype.address.address import get_address_display doc.get("__onload").addr_list = [a.update({"display": get_address_display(a)}) \ for a in frappe.get_all("Address", fields="*", filters={key: doc.name}, order_by="is_primary_address desc, modified desc")] if doc.doctype != "Lead": doc.get("__onload").contact_list = frappe.get_all( "Contact", fields="*", filters={key: doc.name}, order_by="is_primary_contact desc, modified desc")
def set_missing_values(source, target): target.is_pos = 0 target.ignore_pricing_rule = 1 target.run_method("set_missing_values") # set billing address if target.customer_address: target.bill_to_address = get_address_display( target.customer_address) target.run_method("calculate_taxes_and_totals") if cint(source.is_recurring) == 1: target.is_recurring = source.is_recurring target.recurring_type = source.recurring_type target.from_date = source.from_date target.to_date = source.to_date target.repeat_on_day_of_month = source.repeat_on_day_of_month target.end_date = source.end_date target.notification_email_address = source.notification_email_address
def update_cart_address(address_fieldname, address_name): quotation = _get_cart_quotation() address_display = get_address_display(frappe.get_doc("Address", address_name).as_dict()) if address_fieldname == "shipping_address_name": quotation.shipping_address_name = address_name quotation.shipping_address = address_display if not quotation.customer_address: address_fieldname == "customer_address" if address_fieldname == "customer_address": quotation.customer_address = address_name quotation.address_display = address_display apply_cart_settings(quotation=quotation) quotation.flags.ignore_permissions = True quotation.save() return get_cart_quotation(quotation)
def update_cart_address(address_fieldname, address_name): quotation = _get_cart_quotation() address_display = get_address_display( frappe.get_doc("Address", address_name).as_dict()) if address_fieldname == "shipping_address_name": quotation.shipping_address_name = address_name quotation.shipping_address = address_display if not quotation.customer_address: address_fieldname == "customer_address" if address_fieldname == "customer_address": quotation.customer_address = address_name quotation.address_display = address_display apply_cart_settings(quotation=quotation) quotation.flags.ignore_permissions = True quotation.save() return get_cart_quotation(quotation)
def update_cart_address(address_fieldname, address_name): quotation = _get_cart_quotation() address_display = get_address_display(webnotes.doc("Address", address_name).fields) if address_fieldname == "shipping_address_name": quotation.doc.shipping_address_name = address_name quotation.doc.shipping_address = address_display if not quotation.doc.customer_address: address_fieldname == "customer_address" if address_fieldname == "customer_address": quotation.doc.customer_address = address_name quotation.doc.address_display = address_display apply_cart_settings(quotation=quotation) quotation.ignore_permissions = True quotation.save() return get_cart_quotation(quotation.doclist)
def load_address_and_contact(doc, key): """Loads address list and contact list in `__onload`""" from erpnext.utilities.doctype.address.address import get_address_display doc.get("__onload").addr_list = [a.update({"display": get_address_display(a)}) \ for a in frappe.get_all("Address", fields="*", filters={key: doc.name}, order_by="is_primary_address desc, modified desc")] if doc.doctype != "Lead": doc.get("__onload").contact_list = frappe.get_all("Contact", fields="*", filters={key: doc.name}, order_by="is_primary_contact desc, modified desc") if doc.doctype == "FFWW": doc.get("__onload").contact_list = frappe.get_all("Contact", fields="*", filters={key: doc.customer}, order_by="is_primary_contact desc, modified desc") if doc.doctype != "Lead" and doc.doctype != "Supplier": doc.get("__onload").financial_list = frappe.get_all("Financial Data", fields="*", filters={key: doc.name},order_by="financial_year desc",limit_page_length=1)
def get_address(customer): cust_add = frappe.db.sql("""select name from tabAddress where address_title = '%s' and customer = '%s' """ %(customer,customer),as_list=1) if cust_add: address = get_address_display(cust_add[0][0]) return address
def test_template_works(self): address = frappe.get_list("Address")[0].name display = get_address_display(frappe.get_doc("Address", address).as_dict()) self.assertTrue(display)
def test_template_works(self): address = frappe.get_list("Address")[0].name display = get_address_display(frappe.get_doc("Address", address).as_dict()) self.assertTrue(display)
def load_address_and_contact(record,key,key1,customer): ffww = frappe.db.get_value('FFWW',{'contact':record,'customer':customer},'name') contact_details = frappe.db.sql("""select contact_type,email_id,mobile_no,country_code from `tabContact Details` where parent='%s' and ffww='%s' and preffered=0"""%(record,ffww),as_dict=1) personal_emailid = [] personal_mobileno = [] personal_code = [] official_emailid = [] official_mobileno = [] official_code = [] if len(contact_details)>0: for i in contact_details: if i['contact_type'] == 'Personal': personal_emailid.append(i['email_id']) personal_mobileno.append(i['mobile_no']) personal_code.append(i['country_code']) else: official_emailid.append(i['email_id']) official_mobileno.append(i['mobile_no']) official_code.append(i['country_code']) contact_list = frappe.get_all("Contact", fields="*", filters={key:record}) from erpnext.utilities.doctype.address.address import get_address_display if ffww: addr_list = [a.update({"display": get_address_display(a)}) \ for a in frappe.get_all("Address", fields="*", filters={key1: record,'ffww_record':ffww}, order_by="is_primary_address desc, modified desc")] if len(contact_list)>0: contact_list[0].update({'personal_emailid':personal_emailid}) contact_list[0].update({'personal_mobileno':personal_mobileno}) contact_list[0].update({'personal_code':personal_code}) contact_list[0].update({'official_emailid':official_emailid}) contact_list[0].update({'official_mobileno':official_mobileno}) contact_list[0].update({'official_code':official_code}) args = {'contact_list':contact_list} else: args = {'contact_list':''} if len(addr_list)>0: #args = {'address_list':address_list} args['addr_list'] = addr_list else: args['addr_list'] = '' if ffww: args['ffww'] = ffww else: args['ffww'] = '' if args: return args
def load_address_and_contact(record, key, key1, customer): ffww = frappe.db.get_value('FFWW', { 'contact': record, 'customer': customer }, 'name') contact_details = frappe.db.sql( """select contact_type,email_id,mobile_no,country_code from `tabContact Details` where parent='%s' and ffww='%s' and preffered=0""" % (record, ffww), as_dict=1) personal_emailid = [] personal_mobileno = [] personal_code = [] official_emailid = [] official_mobileno = [] official_code = [] if len(contact_details) > 0: for i in contact_details: if i['contact_type'] == 'Personal': personal_emailid.append(i['email_id']) personal_mobileno.append(i['mobile_no']) personal_code.append(i['country_code']) else: official_emailid.append(i['email_id']) official_mobileno.append(i['mobile_no']) official_code.append(i['country_code']) contact_list = frappe.get_all("Contact", fields="*", filters={key: record}) from erpnext.utilities.doctype.address.address import get_address_display if ffww: addr_list = [a.update({"display": get_address_display(a)}) \ for a in frappe.get_all("Address", fields="*", filters={key1: record,'ffww_record':ffww}, order_by="is_primary_address desc, modified desc")] if len(contact_list) > 0: contact_list[0].update({'personal_emailid': personal_emailid}) contact_list[0].update({'personal_mobileno': personal_mobileno}) contact_list[0].update({'personal_code': personal_code}) contact_list[0].update({'official_emailid': official_emailid}) contact_list[0].update({'official_mobileno': official_mobileno}) contact_list[0].update({'official_code': official_code}) args = {'contact_list': contact_list} else: args = {'contact_list': ''} if len(addr_list) > 0: #args = {'address_list':address_list} args['addr_list'] = addr_list else: args['addr_list'] = '' if ffww: args['ffww'] = ffww else: args['ffww'] = '' if args: return args
def fetch_address_details_payments_receipts(party_address): from erpnext.utilities.doctype.address.address import get_address_display return get_address_display(party_address)