commit
26fcef69c7
@ -30,6 +30,11 @@ def get_data():
|
||||
"name": "Print Heading",
|
||||
"description": _("Titles for print templates e.g. Proforma Invoice.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Address Template",
|
||||
"description": _("Country wise default Address Templates")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Terms and Conditions",
|
||||
|
@ -11,7 +11,7 @@
|
||||
"fieldname": "document_description",
|
||||
"fieldtype": "HTML",
|
||||
"label": "Document Description",
|
||||
"options": "<div class=\"field_description\">You can generate multiple salary slips based on the selected criteria, submit and mail those to the employee directly from here</div>",
|
||||
"options": "<div class=\"alert alert-info\">You can generate multiple salary slips based on the selected criteria, submit and mail those to the employee directly from here</div>",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
@ -144,7 +144,7 @@
|
||||
"icon": "icon-cog",
|
||||
"idx": 1,
|
||||
"issingle": 1,
|
||||
"modified": "2014-05-09 02:16:45.165977",
|
||||
"modified": "2014-06-04 06:46:39.437061",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Salary Manager",
|
||||
|
@ -45,3 +45,4 @@ execute:frappe.delete_doc("Print Format", "SalesInvoice")
|
||||
execute:import frappe.defaults;frappe.defaults.clear_default("price_list_currency")
|
||||
erpnext.patches.v4_0.update_account_root_type
|
||||
execute:frappe.delete_doc("Report", "Purchase In Transit")
|
||||
erpnext.patches.v4_0.new_address_template
|
||||
|
9
erpnext/patches/v4_0/new_address_template.py
Normal file
9
erpnext/patches/v4_0/new_address_template.py
Normal file
@ -0,0 +1,9 @@
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
d = frappe.new_doc("Address Template")
|
||||
d.update({"country":frappe.db.get_default("country")})
|
||||
try:
|
||||
d.insert()
|
||||
except Exception:
|
||||
pass
|
@ -9,44 +9,43 @@ import unittest
|
||||
from frappe.test_runner import make_test_records
|
||||
|
||||
test_ignore = ["Price List"]
|
||||
|
||||
|
||||
test_records = frappe.get_test_records('Customer')
|
||||
|
||||
class TestCustomer(unittest.TestCase):
|
||||
def test_party_details(self):
|
||||
from erpnext.accounts.party import get_party_details
|
||||
|
||||
|
||||
to_check = {
|
||||
'address_display': '_Test Address Line 1\n_Test City\nIndia\nPhone: +91 0000000000',
|
||||
'selling_price_list': None,
|
||||
'customer_group': '_Test Customer Group',
|
||||
'contact_designation': None,
|
||||
'customer_address': '_Test Address-Office',
|
||||
'contact_department': None,
|
||||
'contact_email': 'test_contact_customer@example.com',
|
||||
'contact_mobile': None,
|
||||
'sales_team': [],
|
||||
'contact_display': '_Test Contact For _Test Customer',
|
||||
'contact_person': '_Test Contact For _Test Customer-_Test Customer',
|
||||
'territory': u'_Test Territory',
|
||||
'contact_phone': '+91 0000000000',
|
||||
'selling_price_list': None,
|
||||
'customer_group': '_Test Customer Group',
|
||||
'contact_designation': None,
|
||||
'customer_address': '_Test Address-Office',
|
||||
'contact_department': None,
|
||||
'contact_email': 'test_contact_customer@example.com',
|
||||
'contact_mobile': None,
|
||||
'sales_team': [],
|
||||
'contact_display': '_Test Contact For _Test Customer',
|
||||
'contact_person': '_Test Contact For _Test Customer-_Test Customer',
|
||||
'territory': u'_Test Territory',
|
||||
'contact_phone': '+91 0000000000',
|
||||
'customer_name': '_Test Customer'
|
||||
}
|
||||
|
||||
|
||||
make_test_records("Address")
|
||||
make_test_records("Contact")
|
||||
|
||||
|
||||
details = get_party_details("_Test Customer")
|
||||
|
||||
|
||||
for key, value in to_check.iteritems():
|
||||
self.assertEquals(value, details.get(key))
|
||||
|
||||
|
||||
def test_rename(self):
|
||||
frappe.rename_doc("Customer", "_Test Customer 1", "_Test Customer 1 Renamed")
|
||||
|
||||
self.assertTrue(frappe.db.exists("Customer", "_Test Customer 1 Renamed"))
|
||||
self.assertFalse(frappe.db.exists("Customer", "_Test Customer 1"))
|
||||
|
||||
frappe.rename_doc("Customer", "_Test Customer 1 Renamed", "_Test Customer 1")
|
||||
|
||||
|
||||
frappe.rename_doc("Customer", "_Test Customer 1 Renamed", "_Test Customer 1")
|
||||
|
||||
|
||||
|
@ -10,6 +10,9 @@ from frappe import _
|
||||
def install(country=None):
|
||||
records = [
|
||||
|
||||
# address template
|
||||
{'doctype':"Address Template", "country": country},
|
||||
|
||||
# item group
|
||||
{'doctype': 'Item Group', 'item_group_name': _('All Item Groups'),
|
||||
'is_group': 'Yes', 'parent_item_group': ''},
|
||||
@ -189,7 +192,8 @@ def install(country=None):
|
||||
|
||||
from frappe.modules import scrub
|
||||
for r in records:
|
||||
doc = frappe.get_doc(r)
|
||||
doc = frappe.new_doc(r.get("doctype"))
|
||||
doc.update(r)
|
||||
|
||||
# ignore mandatory for root
|
||||
parent_link_field = ("parent_" + scrub(doc.doctype))
|
||||
|
@ -10,7 +10,6 @@ from frappe.utils import cstr
|
||||
from frappe.model.document import Document
|
||||
|
||||
class Address(Document):
|
||||
|
||||
def autoname(self):
|
||||
if not self.address_title:
|
||||
self.address_title = self.customer \
|
||||
@ -56,22 +55,16 @@ def get_address_display(address_dict):
|
||||
if not isinstance(address_dict, dict):
|
||||
address_dict = frappe.db.get_value("Address", address_dict, "*", as_dict=True) or {}
|
||||
|
||||
meta = frappe.get_meta("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"))
|
||||
template = frappe.db.get_value("Address Template", \
|
||||
{"country": address_dict.get("country")}, "template")
|
||||
if not template:
|
||||
template = frappe.db.get_value("Address Template", \
|
||||
{"is_default": 1}, "template")
|
||||
|
||||
display = ""
|
||||
for separator, fieldname in sequence:
|
||||
if address_dict.get(fieldname):
|
||||
display += separator + address_dict.get(fieldname)
|
||||
if not template:
|
||||
frappe.throw(_("No default Address Template found. Please create a new one"))
|
||||
|
||||
return display.strip()
|
||||
return frappe.render_template(template, address_dict)
|
||||
|
||||
def get_territory_from_address(address):
|
||||
"""Tries to match city, state and country of address to existing territory"""
|
||||
@ -88,3 +81,6 @@ def get_territory_from_address(address):
|
||||
break
|
||||
|
||||
return territory
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,18 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
test_records = frappe.get_test_records('Address')
|
||||
test_records = frappe.get_test_records('Address')
|
||||
|
||||
import unittest
|
||||
import frappe
|
||||
|
||||
from erpnext.utilities.doctype.address.address import get_address_display
|
||||
|
||||
class TestAddress(unittest.TestCase):
|
||||
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)
|
||||
|
@ -0,0 +1,57 @@
|
||||
{
|
||||
"autoname": "field:country",
|
||||
"creation": "2014-06-05 02:22:36.029850",
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "Master",
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "country",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Country",
|
||||
"options": "Country",
|
||||
"permlevel": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"description": "This format is used if country specific format is not found",
|
||||
"fieldname": "is_default",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Is Default",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"default": "{% if address_line2 %}{{ address_line2 }}<br>{% endif -%}\n{{ city }}<br>\n{% if state %}{{ state }}<br>{% endif -%}\n{% if pincode %} PIN: {{ pincode }}<br>{% endif -%}\n{{ country }}<br>\n{% if phone %}Phone: {{ phone }}<br>{% endif -%}\n{% if fax %}Fax: {{ fax }}<br>{% endif -%}\n{% if email_id %}Email: {{ email_id }}<br>{% endif -%}\n",
|
||||
"description": "<h4>Default Template</h4>\n<p>Uses <a href=\"http://jinja.pocoo.org/docs/templates/\">Jinja Templating</a> and all the fields of Address (including Custom Fields if any) will be available</p>\n<pre><code>{{ address_line1 }}<br>\n{% if address_line2 %}{{ address_line2 }}<br>{% endif -%}\n{{ city }}<br>\n{% if state %}{{ state }}<br>{% endif -%}\n{% if pincode %} PIN: {{ pincode }}<br>{% endif -%}\n{{ country }}<br>\n{% if phone %}Phone: {{ phone }}<br>{% endif -%}\n{% if fax %}Fax: {{ fax }}<br>{% endif -%}\n{% if email_id %}Email: {{ email_id }}<br>{% endif -%}\n</code></pre>",
|
||||
"fieldname": "template",
|
||||
"fieldtype": "Code",
|
||||
"label": "Template",
|
||||
"permlevel": 0
|
||||
}
|
||||
],
|
||||
"icon": "icon-map-marker",
|
||||
"modified": "2014-06-05 06:14:13.200689",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Utilities",
|
||||
"name": "Address Template",
|
||||
"name_case": "",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"export": 1,
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"set_user_permissions": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe import _
|
||||
|
||||
class AddressTemplate(Document):
|
||||
def validate(self):
|
||||
defaults = frappe.db.get_values("Address Template",
|
||||
{"is_default":1, "name":("!=", self.name)})
|
||||
if not self.is_default:
|
||||
if not defaults:
|
||||
self.is_default = 1
|
||||
frappe.msgprint(_("Setting this Address Template as default as there is no other default"))
|
||||
else:
|
||||
if defaults:
|
||||
for d in defaults:
|
||||
frappe.db.set_value("Address Template", d, "is_default", 0)
|
||||
|
||||
def on_trash(self):
|
||||
if self.is_default:
|
||||
frappe.throw(_("Default Address Template cannot be deleted"))
|
@ -0,0 +1,22 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
test_records = frappe.get_test_records('Address Template')
|
||||
|
||||
import unittest
|
||||
import frappe
|
||||
|
||||
class TestAddressTemplate(unittest.TestCase):
|
||||
def test_default_is_unset(self):
|
||||
a = frappe.get_doc("Address Template", "India")
|
||||
a.is_default = 1
|
||||
a.save()
|
||||
|
||||
b = frappe.get_doc("Address Template", "Brazil")
|
||||
b.is_default = 1
|
||||
b.save()
|
||||
|
||||
self.assertEqual(frappe.db.get_value("Address Template", "India", "is_default"), 0)
|
13
erpnext/utilities/doctype/address_template/test_records.json
Normal file
13
erpnext/utilities/doctype/address_template/test_records.json
Normal file
@ -0,0 +1,13 @@
|
||||
[
|
||||
{
|
||||
"country": "India",
|
||||
"is_default": 1,
|
||||
"template": "{{ address_title }}<br>\n{{ address_line1 }}<br>\n{% if address_line2 %}{{ address_line2 }}<br>{% endif %}\n{{ city }}<br>\n{% if state %}{{ state }}<br>{% endif %}\n{% if pincode %} PIN / ZIP: {{ pincode }}<br>{% endif %}\n{{ country }}<br>\n{% if phone %}Phone: {{ phone }}<br>{% endif %}\n{% if fax %}Fax: {{ fax }}<br>{% endif %}\n{% if email_id %}Email: {{ email_id }}<br>{% endif %}\n"
|
||||
},
|
||||
{
|
||||
"country": "Brazil",
|
||||
"is_default": 0,
|
||||
"template": "{{ address_title }}<br>\n{{ address_line1 }}<br>\n{% if address_line2 %}{{ address_line2 }}<br>{% endif %}\n{{ city }}<br>\n{% if state %}{{ state }}<br>{% endif %}\n{% if pincode %} PIN / ZIP: {{ pincode }}<br>{% endif %}\n{{ country }}<br>\n{% if phone %}Phone: {{ phone }}<br>{% endif %}\n{% if fax %}Fax: {{ fax }}<br>{% endif %}\n{% if email_id %}Email: {{ email_id }}<br>{% endif %}\n"
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user