Merge branch 'hotfix'

This commit is contained in:
Nabin Hait 2018-05-08 15:26:51 +05:30
commit f717296a87
9 changed files with 92 additions and 9 deletions

View file

@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json
from .exceptions import *
from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template
__version__ = '10.1.29'
__version__ = '10.1.30'
__title__ = "Frappe Framework"
local = Local()

View file

@ -61,10 +61,11 @@ class RolePermissionforPageandReport(Document):
def get_roles(self):
roles = []
for data in self.roles:
roles.append({
'role': data.role,
'parenttype': 'Custom Role'
})
if data.role != "All":
roles.append({
'role': data.role,
'parenttype': 'Custom Role'
})
return roles
def update_status(self):

View file

@ -390,6 +390,8 @@ def bulk_rename(doctype, rows=None, via_console = False):
else:
rename_log.append(msg)
frappe.enqueue('frappe.utils.global_search.rebuild_for_doctype', doctype=doctype)
if not via_console:
return rename_log

View file

@ -200,4 +200,6 @@ frappe.patches.v9_1.resave_domain_settings
frappe.patches.v9_1.revert_domain_settings
frappe.patches.v9_1.move_feed_to_activity_log
execute:frappe.delete_doc('Page', 'data-import-tool', ignore_missing=True)
frappe.patches.v10_0.reload_countries_and_currencies
frappe.patches.v10_0.reload_countries_and_currencies
frappe.patches.v10_0.set_no_copy_to_workflow_state
frappe.patches.v10_0.increase_single_table_column_length

View file

@ -0,0 +1,8 @@
"""
Run this after updating country_info.json and or
"""
import frappe
def execute():
for col in ("field", "doctype"):
frappe.db.sql_ddl("alter table `tabSingles` modify column `{0}` varchar(255)".format(col))

View file

@ -0,0 +1,11 @@
import frappe
def execute():
for dt in frappe.get_all("Workflow", fields=['name', 'document_type', 'workflow_state_field']):
fieldname = frappe.db.get_value("Custom Field", filters={'dt': dt.document_type,
'fieldname': dt.workflow_state_field})
if fieldname:
custom_field = frappe.get_doc("Custom Field", fieldname)
custom_field.no_copy = 1
custom_field.save()

View file

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import unittest
from frappe.utils import evaluate_filters, money_in_words, scrub_urls, get_url
from frappe.utils import ceil, floor
class TestFilters(unittest.TestCase):
def test_simple_dict(self):
@ -84,3 +85,22 @@ class TestDataManipulation(unittest.TestCase):
self.assertTrue('<img src="{0}/assets/frappe/test.jpg">'.format(url) in html)
self.assertTrue('style="background-image: url(\'{0}/assets/frappe/bg.jpg\') !important"'.format(url) in html)
self.assertTrue('<a href="mailto:test@example.com">email</a>' in html)
class TestMathUtils(unittest.TestCase):
def test_floor(self):
from decimal import Decimal
self.assertEqual(floor(2), 2 )
self.assertEqual(floor(12.32904), 12)
self.assertEqual(floor(22.7330), 22)
self.assertEqual(floor('24.7'), 24)
self.assertEqual(floor('26.7'), 26)
self.assertEqual(floor(Decimal(29.45)), 29)
def test_ceil(self):
from decimal import Decimal
self.assertEqual(ceil(2), 2 )
self.assertEqual(ceil(12.32904), 13)
self.assertEqual(ceil(22.7330), 23)
self.assertEqual(ceil('24.7'), 25)
self.assertEqual(ceil('26.7'), 27)
self.assertEqual(ceil(Decimal(29.45)), 30)

View file

@ -24,7 +24,7 @@ DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT
# datetime functions
def getdate(string_date=None):
"""
Coverts string date (yyyy-mm-dd) to datetime.date object
Converts string date (yyyy-mm-dd) to datetime.date object
"""
if not string_date:
@ -208,7 +208,7 @@ def get_user_format():
def formatdate(string_date=None, format_string=None):
"""
Convers the given string date to :data:`user_format`
Converts the given string date to :data:`user_format`
User format specified in defaults
Examples:
@ -282,6 +282,44 @@ def cint(s):
except: num = 0
return num
def floor(s):
"""
A number representing the largest integer less than or equal to the specified number
Parameters
----------
s : int or str or Decimal object
The mathematical value to be floored
Returns
-------
int
number representing the largest integer less than or equal to the specified number
"""
try: num = cint(math.floor(flt(s)))
except: num = 0
return num
def ceil(s):
"""
The smallest integer greater than or equal to the given number
Parameters
----------
s : int or str or Decimal object
The mathematical value to be ceiled
Returns
-------
int
smallest integer greater than or equal to the given number
"""
try: num = cint(math.ceil(flt(s)))
except: num = 0
return num
def cstr(s, encoding='utf-8'):
return frappe.as_unicode(s, encoding)
@ -436,7 +474,7 @@ def get_number_format_info(format):
return number_format_info.get(format) or (".", ",", 2)
#
# convet currency to words
# convert currency to words
#
def money_in_words(number, main_currency = None, fraction_currency=None):
"""

View file

@ -31,6 +31,7 @@ class Workflow(Document):
"label": self.workflow_state_field.replace("_", " ").title(),
"hidden": 1,
"allow_on_submit": 1,
"no_copy": 1,
"fieldtype": "Link",
"options": "Workflow State",
}).save()