blob: 9918e5f12820e3f1fce586911f2371fa50d902e0 [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Anand Doshi330dae92013-09-10 13:46:15 +05302# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5import webnotes
6from webnotes.utils import cint
7
Anand Doshib0d996f2013-09-10 18:29:39 +05308no_cache = True
9
Anand Doshi330dae92013-09-10 13:46:15 +053010def get_context():
11 def _get_fields(fieldnames):
12 return [webnotes._dict(zip(["label", "fieldname", "fieldtype", "options"],
13 [df.label, df.fieldname, df.fieldtype, df.options]))
14 for df in webnotes.get_doctype("Address", processed=True).get({"fieldname": ["in", fieldnames]})]
15
16 bean = None
17 if webnotes.form_dict.name:
18 bean = webnotes.bean("Address", webnotes.form_dict.name)
19
20 return {
21 "doc": bean.doc if bean else None,
22 "meta": webnotes._dict({
23 "left_fields": _get_fields(["address_title", "address_type", "address_line1", "address_line2",
24 "city", "state", "pincode", "country"]),
25 "right_fields": _get_fields(["email_id", "phone", "fax", "is_primary_address",
26 "is_shipping_address"])
27 }),
28 "cint": cint
29 }
30