mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-12 17:51:20 +00:00
[webshop] [addresses] address selector, my addresses list
This commit is contained in:
@@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes import msgprint
|
||||
from webnotes.utils import cstr
|
||||
from webnotes.utils import cstr, cint
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@@ -63,4 +63,26 @@ class DocType:
|
||||
if self.doc.fields.get(fieldname):
|
||||
webnotes.conn.sql("""update `tabAddress` set `%s`=0 where `%s`=%s and name!=%s""" %
|
||||
(is_address_type, fieldname, "%s", "%s"), (self.doc.fields[fieldname], self.doc.name))
|
||||
break
|
||||
break
|
||||
|
||||
def get_website_args():
|
||||
def _get_fields(fieldnames):
|
||||
return [webnotes._dict(zip(["label", "fieldname", "fieldtype", "options"],
|
||||
[df.label, df.fieldname, df.fieldtype, df.options]))
|
||||
for df in webnotes.get_doctype("Address", processed=True).get({"fieldname": ["in", fieldnames]})]
|
||||
|
||||
bean = None
|
||||
if webnotes.form_dict.name:
|
||||
bean = webnotes.bean("Address", webnotes.form_dict.name)
|
||||
|
||||
return {
|
||||
"doc": bean.doc if bean else None,
|
||||
"meta": webnotes._dict({
|
||||
"left_fields": _get_fields(["address_title", "address_type", "address_line1", "address_line2",
|
||||
"city", "state", "pincode", "country"]),
|
||||
"right_fields": _get_fields(["email_id", "phone", "fax", "is_primary_address",
|
||||
"is_shipping_address"])
|
||||
}),
|
||||
"cint": cint
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-01-10 16:34:32",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-28 17:06:32",
|
||||
"modified": "2013-07-01 17:24:17",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -40,10 +40,12 @@
|
||||
"name": "Address"
|
||||
},
|
||||
{
|
||||
"description": "Name of person or organization that this address belongs to.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "address_details",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Address Details"
|
||||
"fieldname": "address_title",
|
||||
"fieldtype": "Data",
|
||||
"label": "Address Title",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -53,26 +55,18 @@
|
||||
"options": "Billing\nShipping\nOffice\nPersonal\nPlant\nPostal\nShop\nSubsidiary\nWarehouse\nOther",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"description": "Name of person or organization that this address belongs to.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "address_title",
|
||||
"fieldtype": "Data",
|
||||
"label": "Address Title",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "address_line1",
|
||||
"fieldtype": "Data",
|
||||
"label": "Address Line1",
|
||||
"label": "Address Line 1",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "address_line2",
|
||||
"fieldtype": "Data",
|
||||
"label": "Address Line2"
|
||||
"label": "Address Line 2"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -84,6 +78,15 @@
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "state",
|
||||
"fieldtype": "Data",
|
||||
"in_filter": 1,
|
||||
"label": "State",
|
||||
"options": "Suggest",
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "pincode",
|
||||
@@ -103,15 +106,6 @@
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "state",
|
||||
"fieldtype": "Data",
|
||||
"in_filter": 1,
|
||||
"label": "State",
|
||||
"options": "Suggest",
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break0",
|
||||
@@ -119,6 +113,12 @@
|
||||
"print_hide": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "email_id",
|
||||
"fieldtype": "Data",
|
||||
"label": "Email Id"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "phone",
|
||||
@@ -126,12 +126,6 @@
|
||||
"label": "Phone",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "email_id",
|
||||
"fieldtype": "Data",
|
||||
"label": "Email Id"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "fax",
|
||||
@@ -181,7 +175,7 @@
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.customer && !doc.sales_partner",
|
||||
"depends_on": "eval:!doc.customer && !doc.sales_partner && !doc.lead",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "supplier",
|
||||
"fieldtype": "Link",
|
||||
@@ -189,7 +183,7 @@
|
||||
"options": "Supplier"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.customer && !doc.sales_partner",
|
||||
"depends_on": "eval:!doc.customer && !doc.sales_partner && !doc.lead",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "supplier_name",
|
||||
"fieldtype": "Data",
|
||||
@@ -200,7 +194,7 @@
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.customer && !doc.supplier",
|
||||
"depends_on": "eval:!doc.customer && !doc.supplier && !doc.lead",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sales_partner",
|
||||
"fieldtype": "Link",
|
||||
|
||||
@@ -312,6 +312,20 @@ class TransactionBase(StatusUpdater):
|
||||
})
|
||||
|
||||
webnotes.bean(event_doclist).insert()
|
||||
|
||||
|
||||
def get_address_display(address_dict):
|
||||
meta = webnotes.get_doctype("Address")
|
||||
address_sequence = (("", "address_line1"), ("\n", "address_line2"), ("\n", "city"),
|
||||
("\n", "state"), ("\n" + meta.get_label("pincode") + ": ", "pincode"), ("\n", "country"),
|
||||
("\n" + meta.get_label("phone") + ": ", "phone"), ("\n" + meta.get_label("fax") + ": ", "fax"))
|
||||
|
||||
address_display = ""
|
||||
for separator, fieldname in address_sequence:
|
||||
if address_dict.get(fieldname):
|
||||
address_display += separator + address_dict.get(fieldname)
|
||||
|
||||
return address_display
|
||||
|
||||
def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company):
|
||||
"""common validation for currency and price list currency"""
|
||||
|
||||
Reference in New Issue
Block a user