patch for address template fixes #1749
This commit is contained in:
parent
c22e11d483
commit
eaa2e55d20
@ -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
|
@ -24,8 +24,8 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"default": "{{ 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",
|
||||
"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_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</code></pre>",
|
||||
"default": "{{ 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: {{ 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_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: {{ 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",
|
||||
@ -33,7 +33,7 @@
|
||||
}
|
||||
],
|
||||
"icon": "icon-map-marker",
|
||||
"modified": "2014-06-05 03:28:45.428733",
|
||||
"modified": "2014-06-05 05:12:20.507364",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Utilities",
|
||||
"name": "Address Template",
|
||||
|
@ -4,6 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe import _
|
||||
|
||||
class AddressTemplate(Document):
|
||||
def validate(self):
|
||||
@ -12,8 +13,12 @@ class AddressTemplate(Document):
|
||||
if not self.is_default:
|
||||
if not defaults:
|
||||
self.is_default = 1
|
||||
frappe.msgprint(frappe._("Setting this Address Template as default as there is no other default"))
|
||||
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 Tempalate cannot be deleted"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user