Merge branch 'v7.2.0-beta' into develop
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 37e9b20..f91c97a 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe
-__version__ = '7.2.0-beta'
+__version__ = '7.1.28'
def get_default_company(user=None):
'''Get default company for user'''
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index b2b6aea..5290caf 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -297,6 +297,8 @@
this.print_template = r.message.print_template;
this.pos_profile_data = r.message.pos_profile;
this.default_customer = r.message.default_customer || null;
+ this.print_settings = locals[":Print Settings"]["Print Settings"];
+ this.letter_head = frappe.boot.letter_heads[this.pos_profile_data[letter_head]] || {};
},
save_previous_entry : function(){
@@ -327,9 +329,9 @@
frappe.meta.sync(data)
})
- this.print_template_data = frappe.render_template("print_template",
- {content: this.print_template, title:"POS",
- base_url: frappe.urllib.get_base_url(), print_css: frappe.boot.print_css})
+ this.print_template_data = frappe.render_template("print_template", {content: this.print_template,
+ title:"POS", base_url: frappe.urllib.get_base_url(), print_css: frappe.boot.print_css,
+ print_settings: this.print_settings, header: this.letter_head.header, footer: this.letter_head.footer})
},
setup: function(){
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.js b/erpnext/accounts/report/general_ledger/general_ledger.js
index 0fca7dc..dc79d1f 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.js
+++ b/erpnext/accounts/report/general_ledger/general_ledger.js
@@ -80,13 +80,6 @@
"fieldname":"group_by_account",
"label": __("Group by Account"),
"fieldtype": "Check",
- },
- {
- "fieldname":"letter_head",
- "label": __("Letter Head"),
- "fieldtype": "Link",
- "options": "Letter Head",
- "default": frappe.defaults.get_default("letter_head"),
}
]
}
diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py
index ba1d242..66b3dd0 100644
--- a/erpnext/controllers/item_variant.py
+++ b/erpnext/controllers/item_variant.py
@@ -41,30 +41,37 @@
if attribute.lower() in numeric_values:
numeric_attribute = numeric_values[attribute.lower()]
+ validate_is_incremental(numeric_attribute, attribute, value, item.name)
- from_range = numeric_attribute.from_range
- to_range = numeric_attribute.to_range
- increment = numeric_attribute.increment
+ else:
+ attributes_list = attribute_values.get(attribute.lower(), [])
+ validate_item_attribute_value(attributes_list, attribute, value, item.name)
- if increment == 0:
- # defensive validation to prevent ZeroDivisionError
- frappe.throw(_("Increment for Attribute {0} cannot be 0").format(attribute))
+def validate_is_incremental(numeric_attribute, attribute, value, item):
+ from_range = numeric_attribute.from_range
+ to_range = numeric_attribute.to_range
+ increment = numeric_attribute.increment
- is_in_range = from_range <= flt(value) <= to_range
- precision = max(len(cstr(v).split(".")[-1].rstrip("0")) for v in (value, increment))
- #avoid precision error by rounding the remainder
- remainder = flt((flt(value) - from_range) % increment, precision)
+ if increment == 0:
+ # defensive validation to prevent ZeroDivisionError
+ frappe.throw(_("Increment for Attribute {0} cannot be 0").format(attribute))
- is_incremental = remainder==0 or remainder==increment
+ is_in_range = from_range <= flt(value) <= to_range
+ precision = max(len(cstr(v).split(".")[-1].rstrip("0")) for v in (value, increment))
+ #avoid precision error by rounding the remainder
+ remainder = flt((flt(value) - from_range) % increment, precision)
- if not (is_in_range and is_incremental):
- frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3} for Item {4}")\
- .format(attribute, from_range, to_range, increment, item.name),
- InvalidItemAttributeValueError, title=_('Invalid Attribute'))
+ is_incremental = remainder==0 or remainder==increment
- elif value not in attribute_values.get(attribute.lower(), []):
- frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values for Item {2}").format(
- value, attribute, item.name), InvalidItemAttributeValueError, title=_('Invalid Attribute'))
+ if not (is_in_range and is_incremental):
+ frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3} for Item {4}")\
+ .format(attribute, from_range, to_range, increment, item),
+ InvalidItemAttributeValueError, title=_('Invalid Attribute'))
+
+def validate_item_attribute_value(attributes_list, attribute, attribute_value, item):
+ if attribute_value not in attributes_list:
+ frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values for Item {2}").format(
+ attribute_value, attribute, item), InvalidItemAttributeValueError, title=_('Invalid Attribute'))
def get_attribute_values():
if not frappe.flags.attribute_values:
diff --git a/erpnext/patches/v7_0/set_portal_settings.py b/erpnext/patches/v7_0/set_portal_settings.py
index d9b6400..f7ee205 100644
--- a/erpnext/patches/v7_0/set_portal_settings.py
+++ b/erpnext/patches/v7_0/set_portal_settings.py
@@ -7,13 +7,14 @@
from erpnext.setup.setup_wizard import domainify
def execute():
+ frappe.reload_doctype('Role')
for dt in ("assessment", "announcement", "course", "fees"):
frappe.reload_doc("schools", "doctype", dt)
frappe.reload_doc('website', 'doctype', 'portal_menu_item')
frappe.get_doc('Portal Settings').sync_menu()
-
+
if 'schools' in frappe.get_installed_apps():
domainify.setup_domain('Education')
else:
diff --git a/erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py b/erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py
index 5c63c00..d1974d2 100644
--- a/erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py
+++ b/erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py
@@ -3,6 +3,8 @@
from erpnext.stock.stock_balance import repost_stock
def execute():
+ frappe.reload_doc('manufacturing', 'doctype', 'production_order_item')
+
modified_items = frappe.db.sql_list("""
select name from `tabItem`
where is_stock_item=1 and modified >= '2016-10-31'
diff --git a/erpnext/schools/doctype/guardian/guardian.json b/erpnext/schools/doctype/guardian/guardian.json
index 120a884..67ba9d0 100644
--- a/erpnext/schools/doctype/guardian/guardian.json
+++ b/erpnext/schools/doctype/guardian/guardian.json
@@ -1,6 +1,6 @@
{
"allow_copy": 0,
- "allow_import": 0,
+ "allow_import": 1,
"allow_rename": 0,
"autoname": "GARD.####",
"beta": 0,
@@ -10,6 +10,7 @@
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
+ "engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
@@ -23,6 +24,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Guardian Name",
"length": 0,
"no_copy": 0,
@@ -31,6 +33,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
@@ -49,6 +52,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Email Address",
"length": 0,
"no_copy": 0,
@@ -57,6 +61,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -75,6 +80,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Mobile Number",
"length": 0,
"no_copy": 0,
@@ -83,6 +89,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -101,6 +108,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Alternate Number",
"length": 0,
"no_copy": 0,
@@ -109,6 +117,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -127,6 +136,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -134,6 +144,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -152,6 +163,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Date of Birth",
"length": 0,
"no_copy": 0,
@@ -160,6 +172,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -178,6 +191,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Education",
"length": 0,
"no_copy": 0,
@@ -186,6 +200,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -204,6 +219,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Occupation",
"length": 0,
"no_copy": 0,
@@ -212,6 +228,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -230,6 +247,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Designation",
"length": 0,
"no_copy": 0,
@@ -238,6 +256,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -256,6 +275,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Image",
"length": 0,
"no_copy": 0,
@@ -264,6 +284,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -282,6 +303,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -289,6 +311,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -307,6 +330,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Work Address",
"length": 0,
"no_copy": 0,
@@ -315,6 +339,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -333,6 +358,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -340,6 +366,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -358,6 +385,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Interests",
"length": 0,
"no_copy": 0,
@@ -367,6 +395,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -385,7 +414,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-09-01 14:33:26.541873",
+ "modified": "2016-12-20 11:53:22.325958",
"modified_by": "Administrator",
"module": "Schools",
"name": "Guardian",
@@ -402,6 +431,7 @@
"export": 1,
"if_owner": 0,
"import": 0,
+ "is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.py b/erpnext/setup/doctype/sms_settings/sms_settings.py
index d0f4065..681237f 100644
--- a/erpnext/setup/doctype/sms_settings/sms_settings.py
+++ b/erpnext/setup/doctype/sms_settings/sms_settings.py
@@ -69,7 +69,7 @@
def send_via_gateway(arg):
ss = frappe.get_doc('SMS Settings', 'SMS Settings')
- args = {ss.message_parameter : arg.get('message')}
+ args = {ss.message_parameter: arg.get('message')}
for d in ss.get("parameters"):
args[d.parameter] = d.value
@@ -77,7 +77,7 @@
for d in arg.get('receiver_list'):
args[ss.receiver_parameter] = d
status = send_request(ss.sms_gateway_url, args)
- if status == 200:
+ if status > 200 and status < 300:
success_list.append(d)
if len(success_list) > 0:
@@ -85,27 +85,12 @@
create_sms_log(args, success_list)
frappe.msgprint(_("SMS sent to following numbers: {0}").format("\n" + "\n".join(success_list)))
-# Send Request
-# =========================================================
-def send_request(gateway_url, args):
- import httplib, urllib
- server, api_url = scrub_gateway_url(gateway_url)
- conn = httplib.HTTPConnection(server) # open connection
- headers = {}
- headers['Accept'] = "text/plain, text/html, */*"
- conn.request('GET', api_url + urllib.urlencode(args), headers = headers) # send request
- resp = conn.getresponse() # get response
- return resp.status
-# Split gateway url to server and api url
-# =========================================================
-def scrub_gateway_url(url):
- url = url.replace('http://', '').strip().split('/')
- server = url.pop(0)
- api_url = '/' + '/'.join(url)
- if not api_url.endswith('?'):
- api_url += '?'
- return server, api_url
+def send_request(gateway_url, params):
+ import requests
+ response = requests.get(gateway_url, params = params, headers={'Accept': "text/plain, text/html, */*"})
+ response.raise_for_status()
+ return response.status_code
# Create SMS Log
diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py
index 97ef329..6e71769 100644
--- a/erpnext/startup/boot.py
+++ b/erpnext/startup/boot.py
@@ -13,8 +13,6 @@
bootinfo.website_settings = frappe.get_doc('Website Settings')
if frappe.session['user']!='Guest':
- bootinfo.letter_heads = get_letter_heads()
-
update_page_info(bootinfo)
load_country_and_currency(bootinfo)
@@ -42,12 +40,6 @@
number_format, smallest_currency_fraction_value, symbol from tabCurrency
where enabled=1""", as_dict=1, update={"doctype":":Currency"})
-def get_letter_heads():
- import frappe
- ret = frappe.db.sql("""select name, content from `tabLetter Head`
- where disabled=0""")
- return dict(ret)
-
def update_page_info(bootinfo):
bootinfo.page_info.update({
"Chart of Accounts": {
diff --git a/erpnext/stock/doctype/item_attribute/item_attribute.py b/erpnext/stock/doctype/item_attribute/item_attribute.py
index 3220bc5..71b998f 100644
--- a/erpnext/stock/doctype/item_attribute/item_attribute.py
+++ b/erpnext/stock/doctype/item_attribute/item_attribute.py
@@ -6,7 +6,8 @@
from frappe.model.document import Document
from frappe import _
-from erpnext.controllers.item_variant import validate_item_variant_attributes, InvalidItemAttributeValueError
+from erpnext.controllers.item_variant import (validate_is_incremental,
+ validate_item_attribute_value, InvalidItemAttributeValueError)
class ItemAttributeIncrementError(frappe.ValidationError): pass
@@ -25,9 +26,15 @@
def validate_exising_items(self):
'''Validate that if there are existing items with attributes, they are valid'''
- for item in frappe.db.sql('''select distinct i.name from `tabItem Variant Attribute` iva, `tabItem` i
- where iva.attribute = %s and iva.parent = i.name and i.has_variants = 0''', self.name):
- validate_item_variant_attributes(item[0])
+ attributes_list = [d.attribute_value for d in self.item_attribute_values]
+
+ for item in frappe.db.sql('''select i.name, iva.attribute_value as value
+ from `tabItem Variant Attribute` iva, `tabItem` i where iva.attribute = %s
+ and iva.parent = i.name and i.has_variants = 0''', self.name, as_dict=1):
+ if self.numeric_values:
+ validate_is_incremental(self, self.name, item.value, item.name)
+ else:
+ validate_item_attribute_value(attributes_list, self.name, item.value, item.name)
def validate_numeric(self):
if self.numeric_values: