Merge branch 'hotfix'

This commit is contained in:
Nabin Hait 2018-01-31 15:39:15 +05:30
commit 8f38a17c14
22 changed files with 125 additions and 92 deletions

View File

@ -1,13 +1,6 @@
language: python
dist: trusty
addons:
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
python:
- "2.7"
@ -29,15 +22,6 @@ install:
- cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/
before_script:
- wget http://chromedriver.storage.googleapis.com/2.33/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- sudo apt-get install libnss3
- sudo apt-get --only-upgrade install google-chrome-stable
- sudo cp chromedriver /usr/local/bin/.
- sudo chmod +x /usr/local/bin/chromedriver
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3
- mysql -u root -ptravis -e 'create database test_frappe'
- echo "USE mysql;\nCREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe';\nFLUSH PRIVILEGES;\n" | mysql -u root -ptravis
- echo "USE mysql;\nGRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost';\n" | mysql -u root -ptravis
@ -58,24 +42,6 @@ jobs:
- set -e
- bench run-tests
env: Server Side Test
- # stage
script:
- bench --verbose run-setup-wizard-ui-test
- bench execute erpnext.setup.utils.enable_all_roles_and_domains
- bench run-ui-tests --app erpnext
env: Client Side Test
- # stage
script:
- bench --verbose run-setup-wizard-ui-test
- bench execute erpnext.setup.utils.enable_all_roles_and_domains
- bench run-ui-tests --app erpnext --test-list erpnext/tests/ui/tests2.txt
env: Client Side Test - 2
- # stage
script:
- bench --verbose run-setup-wizard-ui-test
- bench execute erpnext.setup.utils.enable_all_roles_and_domains
- bench run-ui-tests --app erpnext --test-list erpnext/tests/ui/agriculture.txt
env: Agriculture Client Side Test
- # stage
script:
- wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz

View File

@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides
from frappe.utils import getdate
__version__ = '10.0.17'
__version__ = '10.0.18'
def get_default_company(user=None):
'''Get default company for user'''

View File

@ -224,12 +224,17 @@ class SalesInvoice(SellingController):
from erpnext.selling.doctype.customer.customer import check_credit_limit
validate_against_credit_limit = False
bypass_credit_limit_check_at_sales_order = cint(frappe.db.get_value("Customer", self.customer,
"bypass_credit_limit_check_at_sales_order"))
if bypass_credit_limit_check_at_sales_order:
validate_against_credit_limit = True
for d in self.get("items"):
if not (d.sales_order or d.delivery_note):
validate_against_credit_limit = True
break
if validate_against_credit_limit:
check_credit_limit(self.customer, self.company)
check_credit_limit(self.customer, self.company, bypass_credit_limit_check_at_sales_order)
def set_missing_values(self, for_validate=False):
pos = self.set_pos_fields(for_validate)
@ -242,7 +247,10 @@ class SalesInvoice(SellingController):
super(SalesInvoice, self).set_missing_values(for_validate)
if pos:
return {"print_format": pos.get("print_format_for_online") }
return {
"print_format": pos.get("print_format_for_online"),
"allow_edit_rate": pos.get("allow_user_to_edit_rate")
}
def update_time_sheet(self, sales_invoice):
for d in self.timesheets:

View File

@ -130,8 +130,8 @@ def get_party_details(party, party_type, args=None):
def get_tax_template(posting_date, args):
"""Get matching tax rule"""
args = frappe._dict(args)
conditions = ["""(from_date is null or from_date = '' or from_date <= '{0}')
and (to_date is null or to_date = '' or to_date >= '{0}')""".format(posting_date)]
conditions = ["""(from_date is null or from_date <= '{0}')
and (to_date is null or to_date >= '{0}')""".format(posting_date)]
for key, value in args.iteritems():
if key=="use_for_shopping_cart":

View File

@ -8,7 +8,7 @@
{
"doctype": "Supplier",
"supplier_name": "_Test Supplier P",
"supplier_type": "_Test Supplier Type",
"supplier_type": "_Test Supplier Type"
},
{
"doctype": "Supplier",

View File

@ -257,7 +257,7 @@ def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len,
def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
cond = ""
if filters.get("posting_date"):
cond = "and (ifnull(batch.expiry_date, '')='' or batch.expiry_date >= %(posting_date)s)"
cond = "and (batch.expiry_date is null or batch.expiry_date >= %(posting_date)s)"
batch_nos = None
args = {

View File

@ -592,7 +592,7 @@ def validate_bom_no(item, bom_no):
@frappe.whitelist()
def get_children(doctype, parent=None, is_root=False, **filters):
if not parent:
if not parent or parent=="BOM":
frappe.msgprint(_('Please select a BOM'))
return

View File

@ -11,7 +11,8 @@ frappe.treeview_settings["BOM"] = {
title: "BOM",
breadcrumb: "Manufacturing",
disable_add_node: true,
root_label: "All Bill of Materials", //fieldname from filters
root_label: "BOM", //fieldname from filters
get_tree_root: false,
get_label: function(node) {
if(node.data.qty) {
return node.data.qty + " x " + node.data.item_code;
@ -19,6 +20,23 @@ frappe.treeview_settings["BOM"] = {
return node.data.item_code || node.data.value;
}
},
onload: function(me) {
var label = frappe.get_route()[0] + "/" + frappe.get_route()[1];
if(frappe.pages[label]) {
delete frappe.pages[label];
}
var filter = me.opts.filters[0];
if(frappe.route_options && frappe.route_options[filter.fieldname]) {
var val = frappe.route_options[filter.fieldname];
delete frappe.route_options[filter.fieldname];
filter.default = "";
me.args[filter.fieldname] = val;
me.root_label = val;
me.page.set_title(val);
}
me.make_tree();
},
toolbar: [
{ toggle_btn: true },
{

View File

@ -490,7 +490,7 @@ class ProductionOrder(Document):
and detail.parent = entry.name
and detail.item_code = %s''', (self.name, d.item_code))[0][0]
d.db_set('transferred_qty', transferred_qty, update_modified = False)
d.db_set('transferred_qty', flt(transferred_qty), update_modified = False)
@frappe.whitelist()

View File

@ -345,7 +345,7 @@ erpnext.patches.v7_0.repost_bin_qty_and_item_projected_qty
erpnext.patches.v7_1.set_prefered_contact_email
execute:frappe.reload_doc('accounts', 'doctype', 'accounts_settings')
execute:frappe.db.set_value("Accounts Settings", "Accounts Settings", "unlink_payment_on_cancellation_of_invoice", 0)
execute:frappe.db.sql("update `tabStock Entry` set total_amount = null where purpose in('Repack', 'Manufacture')")
execute:frappe.db.sql("update `tabStock Entry` set total_amount = 0 where purpose in('Repack', 'Manufacture')")
erpnext.patches.v7_1.save_stock_settings
erpnext.patches.v7_0.repost_gle_for_pi_with_update_stock #2016-11-01
erpnext.patches.v7_1.add_account_user_role_for_timesheet

View File

@ -20,7 +20,10 @@ def update_po_per_received_per_billed():
where parent = `tabPurchase Order`.name), 2),
`tabPurchase Order`.per_billed = ifnull(round((select sum( if(amount > ifnull(billed_amt, 0),
ifnull(billed_amt, 0), amount)) / sum(amount) *100 from `tabPurchase Order Item`
where parent = `tabPurchase Order`.name), 2), 0)""")
where parent = `tabPurchase Order`.name), 2), 0)
where
net_total > 0
""")
def update_so_per_delivered_per_billed():
frappe.db.sql("""
@ -32,7 +35,10 @@ def update_so_per_delivered_per_billed():
where parent = `tabSales Order`.name), 2),
`tabSales Order`.per_billed = ifnull(round((select sum( if(amount > ifnull(billed_amt, 0),
ifnull(billed_amt, 0), amount)) / sum(amount) *100 from `tabSales Order Item`
where parent = `tabSales Order`.name), 2), 0)""")
where parent = `tabSales Order`.name), 2), 0)
where
net_total > 0
""")
def update_status():
frappe.db.sql("""

View File

@ -5,5 +5,5 @@ def execute():
frappe.db.sql("""
update `tabCurrency Exchange`
set `date` = '2010-01-01'
where date is null or date = '' or date = '0000-00-00'
where date is null or date = '0000-00-00'
""")

View File

@ -7,7 +7,7 @@ def execute():
frappe.reload_doc("hr", "doctype", "attendance")
frappe.db.sql("""update `tabAttendance`
set attendance_date = att_date
where attendance_date is null or attendance_date = '' or attendance_date = '0000-00-00'""")
where attendance_date is null or attendance_date = '0000-00-00'""")
update_reports("Attendance", "att_date", "attendance_date")
update_users_report_view_settings("Attendance", "att_date", "attendance_date")

View File

@ -9,8 +9,7 @@ def execute():
salary_slips = frappe.db.sql("""select month, name, fiscal_year from `tabSalary Slip`
where (month is not null and month != '') and
(start_date is null or start_date = '') and
(end_date is null or end_date = '') and docstatus != 2""", as_dict=True)
start_date is null and end_date is null and docstatus != 2""", as_dict=True)
for salary_slip in salary_slips:
if not cint(salary_slip.month):

View File

@ -8,7 +8,7 @@ def execute():
frappe.db.sql("""
update `tabSales Order`
set delivery_date = final_delivery_date
where (delivery_date is null or delivery_date = '' or delivery_date = '0000-00-00')
where (delivery_date is null or delivery_date = '0000-00-00')
and order_type = 'Sales'""")
frappe.db.sql("""
@ -16,8 +16,6 @@ def execute():
set so_item.delivery_date = so.delivery_date
where so.name = so_item.parent
and so.order_type = 'Sales'
and (so_item.delivery_date is null or so_item.delivery_date = ''
or so_item.delivery_date = '0000-00-00')
and (so.delivery_date is not null and so.delivery_date != ''
and so.delivery_date != '0000-00-00')
""")
and (so_item.delivery_date is null or so_item.delivery_date = '0000-00-00')
and (so.delivery_date is not null and so.delivery_date != '0000-00-00')
""")

View File

@ -1002,9 +1002,9 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fieldname": "payment_terms",
"fieldtype": "Link",
"default": "0",
"fieldname": "bypass_credit_limit_check_at_sales_order",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@ -1012,10 +1012,9 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Payment Terms Template",
"label": "Bypass credit limit check at Sales Order",
"length": 0,
"no_copy": 0,
"options": "Payment Terms Template",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -1034,9 +1033,8 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "0",
"fieldname": "bypass_credit_limit_check_at_sales_order",
"fieldtype": "Check",
"fieldname": "column_break_34",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@ -1044,7 +1042,6 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Bypass credit limit check at Sales Order",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -1059,6 +1056,38 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fieldname": "payment_terms",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Payment Terms Template",
"length": 0,
"no_copy": 0,
"options": "Payment Terms Template",
"permlevel": 0,
"precision": "",
"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,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -1354,7 +1383,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-12-13 18:17:19.894331",
"modified": "2018-01-30 11:52:05.497363",
"modified_by": "Administrator",
"module": "Selling",
"name": "Customer",

View File

@ -185,12 +185,14 @@ def get_customer_list(doctype, txt, searchfield, start, page_len, filters):
("%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, start, page_len))
def check_credit_limit(customer, company):
customer_outstanding = get_customer_outstanding(customer, company)
def check_credit_limit(customer, company, ignore_outstanding_sales_order=False, extra_amount=0):
customer_outstanding = get_customer_outstanding(customer, company, ignore_outstanding_sales_order)
if extra_amount > 0:
customer_outstanding += flt(extra_amount)
credit_limit = get_credit_limit(customer, company)
if credit_limit > 0 and flt(customer_outstanding) > credit_limit:
msgprint(_("Credit limit has been crossed for customer {0} {1}/{2}")
msgprint(_("Credit limit has been crossed for customer {0} ({1}/{2})")
.format(customer, customer_outstanding, credit_limit))
# If not authorized person raise exception
@ -231,7 +233,8 @@ def get_customer_outstanding(customer, company, ignore_outstanding_sales_order=F
and dn.customer=%s and dn.company=%s
and dn.docstatus = 1 and dn.status not in ('Closed', 'Stopped')
and ifnull(dn_item.against_sales_order, '') = ''
and ifnull(dn_item.against_sales_invoice, '') = ''""", (customer, company), as_dict=True)
and ifnull(dn_item.against_sales_invoice, '') = ''
""", (customer, company), as_dict=True)
outstanding_based_on_dn = 0.0

View File

@ -484,11 +484,6 @@ def make_delivery_note(source_name, target_doc=None):
else:
target.po_no = source.po_no
# Since the credit limit check is bypassed at sales order level,
# we need to check it at delivery note
if cint(frappe.db.get_value("Customer", source.customer, "bypass_credit_limit_check_at_sales_order")):
check_credit_limit(source.customer, source.company)
target.ignore_pricing_rule = 1
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
@ -553,10 +548,6 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
# Since the credit limit check is bypassed at sales order level, we need to check it at sales invoice
if cint(frappe.db.get_value("Customer", source.customer, "bypass_credit_limit_check_at_sales_order")):
check_credit_limit(source.customer, source.company)
# set company address
target.update(get_company_address(target.company))
if target.company_address:

View File

@ -463,6 +463,7 @@ erpnext.pos.PointOfSale = class PointOfSale {
if (r.message) {
this.frm.meta.default_print_format = r.message.print_format || 'POS Invoice';
this.frm.allow_edit_rate = r.message.allow_edit_rate;
}
}
@ -727,6 +728,7 @@ class POSCart {
disable_highlight: ['Qty', 'Disc', 'Rate', 'Pay'],
reset_btns: ['Qty', 'Disc', 'Rate', 'Pay'],
del_btn: 'Del',
disable_btns: !this.frm.allow_edit_rate ? ['Rate']: [],
wrapper: this.wrapper.find('.number-pad-container'),
onclick: (btn_value) => {
// on click
@ -1257,7 +1259,7 @@ class NumberPad {
constructor({
wrapper, onclick, button_array,
add_class={}, disable_highlight=[],
reset_btns=[], del_btn='',
reset_btns=[], del_btn='', disable_btns
}) {
this.wrapper = wrapper;
this.onclick = onclick;
@ -1266,6 +1268,7 @@ class NumberPad {
this.disable_highlight = disable_highlight;
this.reset_btns = reset_btns;
this.del_btn = del_btn;
this.disable_btns = disable_btns;
this.make_dom();
this.bind_events();
this.value = '';
@ -1296,6 +1299,14 @@ class NumberPad {
}
this.set_class();
this.disable_btns.forEach((btn) => {
const $btn = this.get_btn(btn);
$btn.prop("disabled", true)
$btn.hover(() => {
$btn.css('cursor','not-allowed');
})
})
}
set_class() {

View File

@ -116,7 +116,7 @@ def set_batch_nos(doc, warehouse_field, throw = False):
else:
batch_qty = get_batch_qty(batch_no=d.batch_no, warehouse=warehouse)
if flt(batch_qty, d.precision("qty")) < flt(qty, d.precision("qty")):
frappe.throw(_("Row #{0}: The batch {1} has only {2} qty. Please select another batch which has {3} qty available or split the row into multiple rows, to deliver/issue from multiple batches").format(d.idx, d.batch_no, batch_qty, d.stock_qty))
frappe.throw(_("Row #{0}: The batch {1} has only {2} qty. Please select another batch which has {3} qty available or split the row into multiple rows, to deliver/issue from multiple batches").format(d.idx, d.batch_no, batch_qty, qty))
@frappe.whitelist()
def get_batch_no(item_code, warehouse, qty=1, throw=False):

View File

@ -235,13 +235,22 @@ class DeliveryNote(SellingController):
def check_credit_limit(self):
from erpnext.selling.doctype.customer.customer import check_credit_limit
extra_amount = 0
validate_against_credit_limit = False
for d in self.get("items"):
if not (d.against_sales_order or d.against_sales_invoice):
validate_against_credit_limit = True
break
bypass_credit_limit_check_at_sales_order = cint(frappe.db.get_value("Customer", self.customer,
"bypass_credit_limit_check_at_sales_order"))
if bypass_credit_limit_check_at_sales_order:
validate_against_credit_limit = True
extra_amount = self.base_grand_total
else:
for d in self.get("items"):
if not (d.against_sales_order or d.against_sales_invoice):
validate_against_credit_limit = True
break
if validate_against_credit_limit:
check_credit_limit(self.customer, self.company)
check_credit_limit(self.customer, self.company,
bypass_credit_limit_check_at_sales_order, extra_amount)
def validate_packed_qty(self):
"""

View File

@ -317,11 +317,6 @@ $.extend(erpnext.item, {
show_multiple_variants_dialog: function(frm) {
var me = this;
if(me.multiple_variant_dialog) {
me.multiple_variant_dialog.show();
return;
}
let promises = [];
let attr_val_fields = {};