Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauskar committed Aug 31, 2017
2 parents fd6b371 + 2a4328b commit 4f939b8
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 29 deletions.
2 changes: 1 addition & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import frappe
from erpnext.hooks import regional_overrides

__version__ = '8.10.0'
__version__ = '8.10.1'

def get_default_company(user=None):
'''Get default company for user'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def get_chart(chart_template, existing_company=None):
for folder in folders:
path = os.path.join(os.path.dirname(__file__), folder)
for fname in os.listdir(path):
fname = frappe.as_unicode(fname)
if fname.endswith(".json"):
with open(os.path.join(path, fname), "r") as f:
chart = f.read()
Expand Down Expand Up @@ -105,6 +106,7 @@ def _get_chart_name(content):
path = os.path.join(os.path.dirname(__file__), folder)

for fname in os.listdir(path):
fname = frappe.as_unicode(fname)
if (fname.startswith(country_code) or fname.startswith(country)) and fname.endswith(".json"):
with open(os.path.join(path, fname), "r") as f:
_get_chart_name(f.read())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1607,4 +1607,4 @@
"root_type": "Income"
}
}
}
}
29 changes: 19 additions & 10 deletions erpnext/accounts/doctype/sales_invoice/pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,7 @@ def make_invoice(doc_list={}, email_queue_list={}, customers_list={}):
si_doc.set_posting_time = 1
si_doc.customer = get_customer_id(doc)
si_doc.due_date = doc.get('posting_date')
submit_invoice(si_doc, name, doc)
name_list.append(name)
name_list = submit_invoice(si_doc, name, doc, name_list)
else:
name_list.append(name)

Expand Down Expand Up @@ -475,19 +474,29 @@ def validate_item(doc):
frappe.db.commit()


def submit_invoice(si_doc, name, doc):
def submit_invoice(si_doc, name, doc, name_list):
try:
si_doc.insert()
si_doc.submit()
frappe.db.commit()
name_list.append(name)
except Exception as e:
if frappe.message_log: frappe.message_log.pop()
frappe.db.rollback()
save_invoice(e, si_doc, name)
frappe.log_error(frappe.get_traceback())
name_list = save_invoice(e, si_doc, name, name_list)

def save_invoice(e, si_doc, name):
if not frappe.db.exists('Sales Invoice', {'offline_pos_name': name}):
si_doc.docstatus = 0
si_doc.flags.ignore_mandatory = True
si_doc.due_date = si_doc.posting_date
si_doc.insert()
return name_list

def save_invoice(e, si_doc, name, name_list):
try:
if not frappe.db.exists('Sales Invoice', {'offline_pos_name': name}):
si_doc.docstatus = 0
si_doc.flags.ignore_mandatory = True
si_doc.due_date = si_doc.posting_date
si_doc.insert()
name_list.append(name)
except Exception:
frappe.log_error(frappe.get_traceback())

return name_list
30 changes: 16 additions & 14 deletions erpnext/accounts/page/pos/pos.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,16 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
});

this.serach_item.make_input();
this.serach_item.$input.on("keyup", function () {
setTimeout(function () {
me.items = me.get_items();
me.make_item_list();
}, 1000);

this.serach_item.$input.on("keypress", function (event) {

clearTimeout(me.last_search_timeout);
me.last_search_timeout = setTimeout(() => {
if((me.serach_item.$input.val() != "") || (event.which == 13)) {
me.items = me.get_items();
me.make_item_list();
}
}, 400);
});

this.search_item_group = this.wrapper.find('.search-item-group');
Expand Down Expand Up @@ -727,14 +732,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({

input = input.toLowerCase();
item = this.get_item(item.value);
var searchtext =
Object.keys(item)
.filter(key => ['customer_name', 'customer_group', 'value', 'label', 'email_id', 'phone', 'mobile_no'].includes(key))
.map(key => item[key])
.join(" ")
.toLowerCase();

return searchtext.includes(input)
return item.searchtext.includes(input)
},
item: function (item, input) {
var d = this.get_item(item.value);
Expand Down Expand Up @@ -808,7 +806,11 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
territory: c.territory,
phone: contact ? contact["phone"] : '',
mobile_no: contact ? contact["mobile_no"] : '',
email_id: contact ? contact["email_id"] : ''
email_id: contact ? contact["email_id"] : '',
searchtext: ['customer_name', 'customer_group', 'value',
'label', 'email_id', 'phone', 'mobile_no']
.map(key => c[key]).join(' ')
.toLowerCase()
}
});

Expand Down
28 changes: 27 additions & 1 deletion erpnext/public/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,33 @@ $.extend(erpnext.utils, {
}
});
}
}
},

/**
* Checks if the first row of a given child table is empty
* @param child_table - Child table Doctype
* @return {Boolean}
**/
first_row_is_empty: function(child_table){
if($.isArray(child_table) && child_table.length > 0) {
return !child_table[0].item_code;
}
return false;
},

/**
* Removes the first row of a child table if it is empty
* @param {_Frm} frm - The current form
* @param {String} child_table_name - The child table field name
* @return {Boolean}
**/
remove_empty_first_row: function(frm, child_table_name){
const rows = frm['doc'][child_table_name];
if (this.first_row_is_empty(rows)){
frm['doc'][child_table_name] = rows.splice(1);
}
return rows;
},
});

erpnext.utils.map_current_doc = function(opts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ def test_exchnage_rate(self):

# Exchange rate as on 15th Dec, 2015, should be fetched from fixer.io
exchange_rate = get_exchange_rate("USD", "INR", "2015-12-15")
self.assertFalse(exchange_rate==60)
self.assertFalse(exchange_rate == 60)
self.assertEqual(exchange_rate, 66.894)
3 changes: 2 additions & 1 deletion erpnext/setup/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None):

if not value:
import requests
response = requests.get("http://api.fixer.io/latest", params={
api_url = "http://api.fixer.io/{0}".format(transaction_date)
response = requests.get(api_url, params={
"base": from_currency,
"symbols": to_currency
})
Expand Down
2 changes: 2 additions & 0 deletions erpnext/stock/doctype/material_request/material_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
if(!r.message) {
frappe.throw(__("BOM does not contain any stock item"))
} else {
erpnext.utils.remove_empty_first_row(cur_frm, "items");
$.each(r.message, function(i, item) {
var d = frappe.model.add_child(cur_frm.doc, "Material Request Item", "items");
d.item_code = item.item_code;
d.item_name = item.item_name;
d.description = item.description;
d.warehouse = values.warehouse;
d.uom = item.stock_uom;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
QUnit.module('manufacturing');

QUnit.test("test material request get items from BOM", function(assert) {
assert.expect(4);
let done = assert.async();
frappe.run_serially([
() => frappe.set_route('Form', 'BOM'),
() => frappe.timeout(3),
() => frappe.click_button('Get Items from BOM'),
() => frappe.timeout(3),
() => {
assert.ok(cur_dialog, 'dialog appeared');
},
() => cur_dialog.set_value('bom', 'Laptop'),
() => cur_dialog.set_value('warehouse', 'Laptop Scrap Warehouse'),
() => frappe.click_button('Get Items from BOM'),
() => frappe.timeout(3),
() => {
assert.ok(cur_frm.doc.items[0].item_code, "First row is not empty");
assert.ok(cur_frm.doc.items[0].item_name, "Item name is not empty");
assert.equal(cur_frm.doc.items[0].item_name, "Laptop", cur_frm.doc.items[0].item_name);
},
() => cur_frm.doc.items[0].schedule_date = '2017-12-12',
() => cur_frm.save(),
() => done()
]);
});

0 comments on commit 4f939b8

Please sign in to comment.