Merge branch 'hotfix'

This commit is contained in:
Sahil Khan 2019-03-28 13:22:14 +05:30
commit c2b4d28246
14 changed files with 2015 additions and 1977 deletions

View file

@ -24,7 +24,7 @@ if sys.version[0] == '2':
reload(sys)
sys.setdefaultencoding("utf-8")
__version__ = '11.1.16'
__version__ = '11.1.17'
__title__ = "Frappe Framework"
local = Local()

File diff suppressed because it is too large Load diff

View file

@ -275,14 +275,14 @@ def build_xlsx_data(columns, data, visible_idx):
if i in visible_idx:
row_data = []
if isinstance(row, list):
row_data = row
elif isinstance(row, dict) and row:
if isinstance(row, dict) and row:
for idx in range(len(data.columns)):
label = columns[idx]["label"]
fieldname = columns[idx]["fieldname"]
row_data.append(row.get(fieldname, row.get(label, "")))
else:
row_data = row
result.append(row_data)

View file

@ -2690,8 +2690,11 @@
},
"Yemen": {
"code": "ye",
"currency": "YER",
"currency_fraction": "Fils",
"currency_fraction_units": 100,
"smallest_currency_fraction_value": 0.01,
"currency_name": "Yemeni Rial",
"currency_symbol": "\ufdfc",
"number_format": "#,###.##",
"timezones": [

View file

@ -60,15 +60,24 @@ def set_user_and_static_default_values(doc):
allowed_records = get_allowed_docs_for_doctype(doctype_user_permissions, df.parent)
user_default_value = get_user_default_value(df, defaults, doctype_user_permissions, allowed_records)
if user_default_value is not None:
doc.set(df.fieldname, user_default_value)
if user_default_value != None:
# do not set default if the field on which current field is dependent is not set
if is_dependent_field_set(df.depends_on, doc):
doc.set(df.fieldname, user_default_value)
else:
if df.fieldname != doc.meta.title_field:
static_default_value = get_static_default_value(df, doctype_user_permissions, allowed_records)
if static_default_value is not None:
if static_default_value != None and is_dependent_field_set(df.depends_on, doc):
doc.set(df.fieldname, static_default_value)
def is_dependent_field_set(fieldname, doc):
value_dict = doc.as_dict()
if not fieldname: return True
# to check if fieldname passed is valid
if fieldname not in value_dict: return True
return value_dict[fieldname]
def get_user_default_value(df, defaults, doctype_user_permissions, allowed_records):
# don't set defaults for "User" link field using User Permissions!
if df.fieldtype == "Link" and df.options != "User":

View file

@ -213,12 +213,12 @@ class Document(BaseDocument):
self.set_docstatus()
self.check_if_latest()
self.run_method("before_insert")
self._validate_links()
self.set_new_name()
self.set_parent_in_children()
self.validate_higher_perm_levels()
self.flags.in_insert = True
self._validate_links()
self.run_before_save_methods()
self._validate()
self.set_docstatus()

View file

@ -88,21 +88,21 @@ def set_name_by_naming_series(doc):
def make_autoname(key='', doctype='', doc=''):
"""
Creates an autoname from the given key:
Creates an autoname from the given key:
**Autoname rules:**
**Autoname rules:**
* The key is separated by '.'
* '####' represents a series. The string before this part becomes the prefix:
Example: ABC.#### creates a series ABC0001, ABC0002 etc
* 'MM' represents the current month
* 'YY' and 'YYYY' represent the current year
* The key is separated by '.'
* '####' represents a series. The string before this part becomes the prefix:
Example: ABC.#### creates a series ABC0001, ABC0002 etc
* 'MM' represents the current month
* 'YY' and 'YYYY' represent the current year
*Example:*
* DE/./.YY./.MM./.##### will create a series like
DE/09/01/0001 where 09 is the year, 01 is the month and 0001 is the series
* DE/./.YY./.MM./.##### will create a series like
DE/09/01/0001 where 09 is the year, 01 is the month and 0001 is the series
"""
if key == "hash":
return frappe.generate_hash(doctype, 10)
@ -121,7 +121,6 @@ def parse_naming_series(parts, doctype='', doc=''):
n = ''
if isinstance(parts, string_types):
parts = parts.split('.')
series_set = False
today = now_datetime()
for e in parts:
@ -141,6 +140,9 @@ def parse_naming_series(parts, doctype='', doc=''):
part = today.strftime('%Y')
elif e == 'FY':
part = frappe.defaults.get_user_default("fiscal_year")
elif e.startswith('{') and doc:
e = e.replace('{', '').replace('}', '')
part = doc.get(e)
elif doc and doc.get(e):
part = doc.get(e)
else:

View file

@ -898,7 +898,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
get_checked_items(only_docnames) {
const docnames = Array.from(this.$checks || [])
.map(check => $(check).data().name);
.map(check => cstr($(check).data().name));
if (only_docnames) return docnames;

View file

@ -238,7 +238,7 @@ frappe.ui.Slides = class Slides {
.appendTo(this.container);
this.$body = $(`<div>`).addClass(`slide-container`)
.appendTo(this.container);
this.$footer = $(`<div>`).addClass(`footer`)
this.$footer = $(`<div>`).addClass(`slide-footer`)
.appendTo(this.container);
this.render_progress_dots();

View file

@ -31,9 +31,15 @@
{% var value = col.fieldname ? row[col.fieldname] : row[col.id]; %}
<td>
{{ col.formatter
? col.formatter(row._index, col._index, value, col, row, true)
: (col.docfield ? frappe.format(value, col.docfield) : value) }}
{{
col.formatter
? col.formatter(row._index, col._index, value, col, row, true)
: col.format
? col.format(value, row, col, data)
: col.docfield
? frappe.format(value, col.docfield)
: value
}}
</td>
{% endif %}
{% endfor %}
@ -41,3 +47,4 @@
{% endfor %}
</tbody>
</table>

View file

@ -493,10 +493,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
const type = chart_type.toLowerCase();
const colors = color ? [color] : undefined;
let labels = get_column_values(x_field)
.filter(Boolean)
.map(d => d.trim())
.filter(Boolean);
let labels = get_column_values(x_field);
let dataset_values = get_column_values(y_field).map(d => Number(d));

View file

@ -946,8 +946,8 @@ input[type="checkbox"] {
.btn-primary {
font-weight: bold;
}
.footer {
margin-top: 15px;
.slide-footer {
margin: 15px 0px;
padding: 0px 7px;
.btn:not(:last-child) {

View file

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import frappe, unittest, os
from frappe.utils import cint
from frappe.model.naming import revert_series_if_last, make_autoname, parse_naming_series
from frappe.utils.testutils import add_custom_field, clear_custom_fields
class TestDocument(unittest.TestCase):
def test_get_return_empty_list_for_table_field_if_none(self):
@ -235,3 +236,20 @@ class TestDocument(unittest.TestCase):
new_current = cint(frappe.db.get_value('Series', prefix, "current", order_by="name"))
self.assertEqual(cint(old_current) - 1, new_current)
def test_default_of_dependent_field(self):
add_custom_field('ToDo', 'parent_field', 'Data')
add_custom_field('ToDo', 'dependent_field', 'Data',
default='Some Data', depends_on='parent_field')
add_custom_field('ToDo', 'independent_field', 'Data',
default='Some Data')
doc = frappe.new_doc('ToDo')
self.assertFalse(doc.get('dependent_field'))
self.assertEqual(doc.get('independent_field'), 'Some Data')
clear_custom_fields('ToDo')

View file

@ -4,13 +4,15 @@ from __future__ import unicode_literals
import frappe
def add_custom_field(doctype, fieldname, fieldtype='Data', options=None):
def add_custom_field(doctype, fieldname, fieldtype='Data', options=None, default=None, depends_on=None):
frappe.get_doc({
"doctype": "Custom Field",
"dt": doctype,
"fieldname": fieldname,
"fieldtype": fieldtype,
"options": options
"options": options,
"default": default,
"depends_on": depends_on
}).insert()
def clear_custom_fields(doctype):