Merge branch 'develop'
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 0bf65d2..d102c9e 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe
-__version__ = '8.0.21'
+__version__ = '8.0.22'
def get_default_company(user=None):
'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index 11f376d..998fee9 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -189,8 +189,8 @@
if account_balance != stock_balance:
frappe.throw(_('Account balance ({0}) and stock value ({1}) must be same')\
- .format(fmt_money(account_balance, self.account_currency),
- fmt_money(stock_balance, self.account_currency)))
+ .format(fmt_money(account_balance, currency=self.account_currency),
+ fmt_money(stock_balance, currency=self.account_currency)))
elif self.warehouse:
self.warehouse = None
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index f1f997a..a899cde 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -325,8 +325,10 @@
if not frappe.db.exists('Customer', name):
name = add_customer(name)
data = json.loads(data)
+ make_contact(data, name)
make_address(data, name)
customer_list.append(name)
+ frappe.db.commit()
return customer_list
def add_customer(name):
@@ -340,6 +342,29 @@
frappe.db.commit()
return customer_doc.name
+def make_contact(args,customer):
+ if args.get('email_id') or args.get('phone'):
+ name = frappe.db.get_value('Dynamic Link',
+ {'link_doctype': 'Customer', 'link_name': customer, 'parenttype': 'Contact'}, 'parent')
+
+ args = {
+ 'email_id': args.get('email_id'),
+ 'phone': args.get('phone')
+ }
+
+ doc = frappe.new_doc('Contact')
+ if name:
+ doc = frappe.get_doc('Contact', name)
+
+ doc.update(args)
+ if not name:
+ doc.first_name = customer
+ doc.append('links',{
+ 'link_doctype': 'Customer',
+ 'link_name': customer
+ })
+ doc.save(ignore_permissions=True)
+
def make_address(args, customer):
if not args.get('address_line1'): return
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index 7006761..c632e45 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -327,6 +327,7 @@
this.name = null;
this.load_data(true);
this.setup();
+ this.set_default_customer()
},
load_data: function (load_doc) {
@@ -360,6 +361,16 @@
}
},
+ set_default_customer: function() {
+ if (this.default_customer && !this.frm.doc.customer) {
+ this.party_field.$input.val(this.default_customer);
+ this.frm.doc.customer = this.default_customer;
+ this.numeric_keypad.show();
+ this.toggle_list_customer(false)
+ this.toggle_item_cart(true)
+ }
+ },
+
set_transaction_defaults: function (party) {
var me = this;
this.party = party;
@@ -675,11 +686,6 @@
me.toggle_delete_button();
}
- if (this.default_customer && !this.frm.doc.customer) {
- this.party_field.$input.val(this.default_customer);
- this.frm.doc.customer = this.default_customer;
- }
-
this.party_field.awesomeplete =
new Awesomplete(this.party_field.$input.get(0), {
minChars: 0,
@@ -860,6 +866,7 @@
this.customer_doc.set_primary_action(__("Save"), function () {
me.make_offline_customer(new_customer);
me.pos_bill.show();
+ me.list_customers.hide();
});
},
diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.js b/erpnext/accounts/report/balance_sheet/balance_sheet.js
index 9cd92d4..760fa64 100644
--- a/erpnext/accounts/report/balance_sheet/balance_sheet.js
+++ b/erpnext/accounts/report/balance_sheet/balance_sheet.js
@@ -7,7 +7,8 @@
frappe.query_reports["Balance Sheet"]["filters"].push({
"fieldname": "accumulated_values",
"label": __("Accumulated Values"),
- "fieldtype": "Check"
+ "fieldtype": "Check",
+ "default": 1
});
});
diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py
index 9095d86..2db4ef8 100644
--- a/erpnext/accounts/report/balance_sheet/balance_sheet.py
+++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py
@@ -9,22 +9,19 @@
def execute(filters=None):
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
- filters.periodicity, filters.accumulated_values, filters.company)
+ filters.periodicity, company=filters.company)
asset = get_data(filters.company, "Asset", "Debit", period_list,
only_current_fiscal_year=False, filters=filters,
- accumulated_values=filters.accumulated_values,
- ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
+ accumulated_values=filters.accumulated_values)
liability = get_data(filters.company, "Liability", "Credit", period_list,
only_current_fiscal_year=False, filters=filters,
- accumulated_values=filters.accumulated_values,
- ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
+ accumulated_values=filters.accumulated_values)
equity = get_data(filters.company, "Equity", "Credit", period_list,
only_current_fiscal_year=False, filters=filters,
- accumulated_values=filters.accumulated_values,
- ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
+ accumulated_values=filters.accumulated_values)
provisional_profit_loss, total_credit = get_provisional_profit_loss(asset, liability, equity,
period_list, filters.company)
@@ -114,7 +111,8 @@
opening_balance -= flt(liability[0].get("opening_balance", 0), float_precision)
if equity:
opening_balance -= flt(equity[0].get("opening_balance", 0), float_precision)
-
+
+ opening_balance = flt(opening_balance, float_precision)
if opening_balance:
return _("Previous Financial Year is not closed"),opening_balance
return None,None
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index 9ba7711..41d0e48 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -6,8 +6,11 @@
from frappe import _
from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff,
add_months, add_days, formatdate, cint)
+from erpnext.accounts.utils import get_fiscal_year
-def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False, company=None):
+
+def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False,
+ company=None, reset_period_on_fy_change=True):
"""Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label}
Periodicity can be (Yearly, Quarterly, Monthly)"""
@@ -49,7 +52,8 @@
# if a fiscal year ends before a 12 month period
period.to_date = year_end_date
- period.to_date_fiscal_year = get_date_fiscal_year(period.to_date, company)
+ period.to_date_fiscal_year = get_fiscal_year(period.to_date, company=company)[0]
+ period.from_date_fiscal_year_start_date = get_fiscal_year(period.from_date, company=company)[1]
period_list.append(period)
@@ -65,7 +69,10 @@
if not accumulated_values:
label = get_label(periodicity, opts["from_date"], opts["to_date"])
else:
- label = get_label(periodicity, period_list[0]["from_date"], opts["to_date"])
+ if reset_period_on_fy_change:
+ label = get_label(periodicity, opts.from_date_fiscal_year_start_date, opts["to_date"])
+ else:
+ label = get_label(periodicity, period_list[0].from_date, opts["to_date"])
opts.update({
"key": key.replace(" ", "_").replace("-", "_"),
@@ -150,10 +157,6 @@
if entry.posting_date < period_list[0].year_start_date:
d["opening_balance"] = d.get("opening_balance", 0.0) + flt(entry.debit) - flt(entry.credit)
-def get_date_fiscal_year(date, company):
- from erpnext.accounts.utils import get_fiscal_year
- return get_fiscal_year(date, company=company)[0]
-
def accumulate_values_into_parents(accounts, accounts_by_name, period_list, accumulated_values):
"""accumulate children's values in parent accounts"""
for d in reversed(accounts):
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 2c1448c..1721fa9 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -11,7 +11,6 @@
# imported to enable erpnext.accounts.utils.get_account_currency
from erpnext.accounts.doctype.account.account import get_account_currency
-from erpnext.accounts.report.financial_statements import sort_root_accounts
class FiscalYearError(frappe.ValidationError): pass
@@ -652,6 +651,8 @@
@frappe.whitelist()
def get_children():
+ from erpnext.accounts.report.financial_statements import sort_root_accounts
+
args = frappe.local.form_dict
doctype, company = args['doctype'], args['company']
fieldname = frappe.db.escape(doctype.lower().replace(' ','_'))
diff --git a/erpnext/buying/utils.py b/erpnext/buying/utils.py
index 28c7579..9146c58 100644
--- a/erpnext/buying/utils.py
+++ b/erpnext/buying/utils.py
@@ -5,6 +5,7 @@
import frappe
from frappe.utils import flt, cstr, cint
from frappe import _
+import json
from erpnext.stock.doctype.item.item import get_last_purchase_details
from erpnext.stock.doctype.item.item import validate_end_of_life
@@ -78,3 +79,25 @@
if status == "Closed":
frappe.throw(_("{0} {1} status is {2}").format(doctype, docname, status), frappe.InvalidStatusError)
+@frappe.whitelist()
+def get_linked_material_requests(items):
+ items = json.loads(items)
+ mr_list = []
+ for item in items:
+ material_request = frappe.db.sql("""SELECT distinct mr.name AS mr_name,
+ (mr_item.qty - mr_item.ordered_qty) AS qty,
+ mr_item.item_code AS item_code,
+ mr_item.name AS mr_item
+ FROM `tabMaterial Request` mr, `tabMaterial Request Item` mr_item
+ WHERE mr.name = mr_item.parent
+ AND mr_item.item_code = %(item)s
+ AND mr.material_request_type = 'Purchase'
+ AND mr.per_ordered < 99.99
+ AND mr.docstatus = 1
+ AND mr.status != 'Stopped'
+ ORDER BY mr_item.item_code ASC""",{"item": item}, as_dict=1)
+ if material_request:
+ mr_list.append(material_request)
+
+ return mr_list
+
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 5b4e687..af4dd3b 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -12,7 +12,7 @@
app_license = "GNU General Public License (v3)"
source_link = "https://github.com/frappe/erpnext"
-develop_version = '8.0.0-beta'
+develop_version = '8.x.x-beta'
error_report_email = "support@erpnext.com"
diff --git a/erpnext/hr/doctype/employee_loan/employee_loan.js b/erpnext/hr/doctype/employee_loan/employee_loan.js
index 2f87acf..71b6356 100644
--- a/erpnext/hr/doctype/employee_loan/employee_loan.js
+++ b/erpnext/hr/doctype/employee_loan/employee_loan.js
@@ -79,7 +79,7 @@
},
employee_loan_application: function(frm) {
- return frm.call({
+ return frappe.call({
method: "erpnext.hr.doctype.employee_loan.employee_loan.get_employee_loan_application",
args: {
"employee_loan_application": frm.doc.employee_loan_application
diff --git a/erpnext/hr/doctype/employee_loan/employee_loan.json b/erpnext/hr/doctype/employee_loan/employee_loan.json
index 7606e92..35c735a 100644
--- a/erpnext/hr/doctype/employee_loan/employee_loan.json
+++ b/erpnext/hr/doctype/employee_loan/employee_loan.json
@@ -14,6 +14,7 @@
"engine": "InnoDB",
"fields": [
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -44,6 +45,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -74,6 +76,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -104,6 +107,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -134,6 +138,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -162,6 +167,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -192,6 +198,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -222,10 +229,12 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "default": "Sanctioned",
"fieldname": "status",
"fieldtype": "Select",
"hidden": 0,
@@ -237,7 +246,7 @@
"in_standard_filter": 0,
"label": "Status",
"length": 0,
- "no_copy": 0,
+ "no_copy": 1,
"options": "Sanctioned\nPartially Disbursed\nFully Disbursed\nRepaid/Closed",
"permlevel": 0,
"precision": "",
@@ -252,6 +261,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -281,6 +291,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -310,6 +321,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -340,6 +352,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -371,6 +384,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -400,6 +414,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -428,6 +443,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -459,6 +475,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -490,6 +507,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -522,6 +540,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -551,6 +570,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -581,6 +601,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -611,6 +632,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -639,6 +661,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -669,6 +692,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -699,6 +723,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -728,6 +753,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -758,6 +784,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -787,6 +814,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -818,6 +846,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -846,6 +875,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -877,6 +907,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -916,7 +947,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2017-03-30 12:59:40.650035",
+ "modified": "2017-05-02 13:52:30.884154",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Loan",
diff --git a/erpnext/hr/doctype/employee_loan/employee_loan.py b/erpnext/hr/doctype/employee_loan/employee_loan.py
index 7e16ec1..dadd769 100644
--- a/erpnext/hr/doctype/employee_loan/employee_loan.py
+++ b/erpnext/hr/doctype/employee_loan/employee_loan.py
@@ -132,7 +132,7 @@
def get_employee_loan_application(employee_loan_application):
employee_loan = frappe.get_doc("Employee Loan Application", employee_loan_application)
if employee_loan:
- return employee_loan
+ return employee_loan.as_dict()
@frappe.whitelist()
def make_jv_entry(employee_loan, company, employee_loan_account, employee, loan_amount, payment_account):
diff --git a/erpnext/hr/doctype/employee_loan_application/employee_loan_application.py b/erpnext/hr/doctype/employee_loan_application/employee_loan_application.py
index 357571e..0c29e0d 100644
--- a/erpnext/hr/doctype/employee_loan_application/employee_loan_application.py
+++ b/erpnext/hr/doctype/employee_loan_application/employee_loan_application.py
@@ -5,7 +5,7 @@
from __future__ import unicode_literals
import frappe, math
from frappe import _
-from frappe.utils import flt
+from frappe.utils import flt, rounded
from frappe.model.mapper import get_mapped_doc
from frappe.model.document import Document
@@ -35,9 +35,21 @@
else:
self.repayment_periods = self.loan_amount / self.repayment_amount
- self.total_payable_amount = self.repayment_amount * self.repayment_periods
- self.total_payable_interest = self.total_payable_amount - self.loan_amount
+ self.calculate_payable_amount()
+
+ def calculate_payable_amount(self):
+ balance_amount = self.loan_amount
+ self.total_payable_amount = 0
+ self.total_payable_interest = 0
+ while(balance_amount > 0):
+ interest_amount = rounded(balance_amount * flt(self.rate_of_interest) / (12*100))
+ balance_amount = rounded(balance_amount + interest_amount - self.repayment_amount)
+
+ self.total_payable_interest += interest_amount
+
+ self.total_payable_amount = self.loan_amount + self.total_payable_interest
+
@frappe.whitelist()
def make_employee_loan(source_name, target_doc = None):
doclist = get_mapped_doc("Employee Loan Application", source_name, {
diff --git a/erpnext/hr/doctype/employee_loan_application/test_employee_loan_application.py b/erpnext/hr/doctype/employee_loan_application/test_employee_loan_application.py
index 1d157d6..789b5d4 100644
--- a/erpnext/hr/doctype/employee_loan_application/test_employee_loan_application.py
+++ b/erpnext/hr/doctype/employee_loan_application/test_employee_loan_application.py
@@ -39,13 +39,13 @@
def test_loan_totals(self):
loan_application = frappe.get_doc("Employee Loan Application", {"employee":self.employee})
self.assertEquals(loan_application.repayment_amount, 11445)
- self.assertEquals(loan_application.total_payable_interest, 24680)
- self.assertEquals(loan_application.total_payable_amount, 274680)
+ self.assertEquals(loan_application.total_payable_interest, 24657)
+ self.assertEquals(loan_application.total_payable_amount, 274657)
loan_application.repayment_method = "Repay Fixed Amount per Period"
loan_application.repayment_amount = 15000
loan_application.save()
self.assertEquals(loan_application.repayment_periods, 18)
- self.assertEquals(loan_application.total_payable_interest, 20000)
- self.assertEquals(loan_application.total_payable_amount, 270000)
\ No newline at end of file
+ self.assertEquals(loan_application.total_payable_interest, 18506)
+ self.assertEquals(loan_application.total_payable_amount, 268506)
\ No newline at end of file
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py
index 12f8335..da69bcc 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.py
@@ -33,7 +33,7 @@
for employee in self.get('employees'):
joining_date, relieving_date = frappe.db.get_value("Employee", employee.employee,
["date_of_joining", "relieving_date"])
- if employee.from_date and getdate(employee.from_date) < joining_date:
+ if employee.from_date and joining_date and getdate(employee.from_date) < joining_date:
frappe.throw(_("From Date {0} for Employee {1} cannot be before employee's joining Date {2}")
.format(employee.from_date, employee.employee, joining_date))
diff --git a/erpnext/patches/v7_1/update_portal_roles.py b/erpnext/patches/v7_1/update_portal_roles.py
index 506adb9..72e9434 100644
--- a/erpnext/patches/v7_1/update_portal_roles.py
+++ b/erpnext/patches/v7_1/update_portal_roles.py
@@ -13,7 +13,6 @@
# set customer, supplier roles
for c in frappe.get_all('Contact', fields=['user'], filters={'ifnull(user, "")': ('!=', '')}):
user = frappe.get_doc('User', c.user)
- user.set_default_roles()
user.flags.ignore_validate = True
user.flags.ignore_mandatory = True
user.save()
diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js
index 108aac1..a8c80fe 100644
--- a/erpnext/public/js/controllers/buying.js
+++ b/erpnext/public/js/controllers/buying.js
@@ -220,7 +220,7 @@
}
}
frappe.call({
- method: "erpnext.buying.doctype.purchase_common.purchase_common.get_linked_material_requests",
+ method: "erpnext.buying.utils.get_linked_material_requests",
args:{
items: my_items
},
diff --git a/erpnext/public/js/sms_manager.js b/erpnext/public/js/sms_manager.js
index a06c43c..d6293ea 100644
--- a/erpnext/public/js/sms_manager.js
+++ b/erpnext/public/js/sms_manager.js
@@ -21,9 +21,9 @@
}
if (in_list(['Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice'], doc.doctype))
- this.show(doc.contact_person, 'customer', doc.customer, '', default_msg[doc.doctype]);
+ this.show(doc.contact_person, 'Customer', doc.customer, '', default_msg[doc.doctype]);
else if (in_list(['Purchase Order', 'Purchase Receipt'], doc.doctype))
- this.show(doc.contact_person, 'supplier', doc.supplier, '', default_msg[doc.doctype]);
+ this.show(doc.contact_person, 'Supplier', doc.supplier, '', default_msg[doc.doctype]);
else if (doc.doctype == 'Lead')
this.show('', '', '', doc.mobile_no, default_msg[doc.doctype]);
else if (doc.doctype == 'Opportunity')
@@ -33,13 +33,13 @@
};
- this.get_contact_number = function(contact, key, value) {
+ this.get_contact_number = function(contact, ref_doctype, ref_name) {
frappe.call({
method: "erpnext.setup.doctype.sms_settings.sms_settings.get_contact_number",
args: {
- contact_name:contact,
- value:value,
- key:key
+ contact_name: contact,
+ ref_doctype: ref_doctype,
+ ref_name: ref_name
},
callback: function(r) {
if(r.exc) { msgprint(r.exc); return; }
@@ -49,13 +49,13 @@
});
};
- this.show = function(contact, key, value, mobile_nos, message) {
+ this.show = function(contact, ref_doctype, ref_name, mobile_nos, message) {
this.message = message;
if (mobile_nos) {
me.number = mobile_nos;
me.show_dialog();
} else if (contact){
- this.get_contact_number(contact, key, value)
+ this.get_contact_number(contact, ref_doctype, ref_name)
} else {
me.show_dialog();
}
diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.py b/erpnext/setup/doctype/sms_settings/sms_settings.py
index 2888942..a8b59be 100644
--- a/erpnext/setup/doctype/sms_settings/sms_settings.py
+++ b/erpnext/setup/doctype/sms_settings/sms_settings.py
@@ -40,10 +40,15 @@
return sender_name
@frappe.whitelist()
-def get_contact_number(contact_name, value, key):
+def get_contact_number(contact_name, ref_doctype, ref_name):
"returns mobile number of the contact"
- number = frappe.db.sql("""select mobile_no, phone from tabContact where name=%s and %s=%s""" %
- ('%s', frappe.db.escape(key), '%s'), (contact_name, value))
+ number = frappe.db.sql("""select mobile_no, phone from tabContact
+ where name=%s
+ and exists(
+ select name from `tabDynamic Link` where link_doctype=%s and link_name=%s
+ )
+ """, (contact_name, ref_doctype, ref_name))
+
return number and (number[0][0] or number[0][1]) or ''
@frappe.whitelist()
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 6a34ae6..d42e60d 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -16,6 +16,7 @@
"engine": "InnoDB",
"fields": [
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -46,6 +47,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -75,6 +77,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
@@ -106,6 +109,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -138,6 +142,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
@@ -168,6 +173,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -196,6 +202,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -228,6 +235,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -260,6 +268,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -287,6 +296,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -316,6 +326,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -349,6 +360,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
@@ -379,6 +391,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -409,6 +422,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
@@ -438,6 +452,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -467,6 +482,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -498,6 +514,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -528,6 +545,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -557,6 +575,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -588,6 +607,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -618,6 +638,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -650,6 +671,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -683,6 +705,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -715,6 +738,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -746,6 +770,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -776,6 +801,7 @@
"width": "50%"
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -808,6 +834,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -838,6 +865,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -869,6 +897,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -899,6 +928,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -929,6 +959,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -960,6 +991,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -991,6 +1023,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -1021,6 +1054,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1054,6 +1088,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -1085,6 +1120,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1118,6 +1154,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1149,6 +1186,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1177,6 +1215,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1211,6 +1250,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1241,6 +1281,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -1272,6 +1313,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1305,6 +1347,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1337,6 +1380,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1368,6 +1412,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -1398,6 +1443,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1428,6 +1474,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1461,6 +1508,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1490,6 +1538,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1522,6 +1571,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1555,6 +1605,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1588,6 +1639,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1619,6 +1671,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -1649,6 +1702,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1679,6 +1733,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1708,6 +1763,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1738,6 +1794,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1767,6 +1824,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1798,6 +1856,7 @@
"width": "50%"
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1828,6 +1887,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -1857,6 +1917,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1887,6 +1948,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1915,6 +1977,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -1945,6 +2008,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -1975,6 +2039,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2005,6 +2070,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2036,6 +2102,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2066,6 +2133,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2096,6 +2164,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2126,6 +2195,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2157,6 +2227,7 @@
"width": "50%"
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2188,6 +2259,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2219,6 +2291,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -2249,6 +2322,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2281,6 +2355,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -2311,6 +2386,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2343,6 +2419,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2372,6 +2449,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2405,6 +2483,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -2436,6 +2515,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2468,6 +2548,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2501,6 +2582,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2529,6 +2611,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2557,6 +2640,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -2586,6 +2670,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2615,6 +2700,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2645,11 +2731,12 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "show_in_website",
+ "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website",
"fieldname": "route",
"fieldtype": "Small Text",
"hidden": 0,
@@ -2675,11 +2762,12 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "show_in_website",
+ "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website",
"description": "Items with higher weightage will be shown higher",
"fieldname": "weightage",
"fieldtype": "Int",
@@ -2705,11 +2793,12 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "show_in_website",
+ "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website",
"description": "Show a slideshow at the top of the page",
"fieldname": "slideshow",
"fieldtype": "Link",
@@ -2736,11 +2825,12 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "show_in_website",
+ "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website",
"description": "Item Image (if not slideshow)",
"fieldname": "website_image",
"fieldtype": "Attach",
@@ -2767,6 +2857,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2796,6 +2887,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -2823,11 +2915,12 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "show_in_website",
+ "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website",
"description": "Show \"In Stock\" or \"Not in Stock\" based on stock available in this warehouse.",
"fieldname": "website_warehouse",
"fieldtype": "Link",
@@ -2854,11 +2947,12 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "show_in_website",
+ "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website",
"description": "List this Item in multiple groups on the website.",
"fieldname": "website_item_groups",
"fieldtype": "Table",
@@ -2885,12 +2979,13 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
"collapsible_depends_on": "website_specifications",
"columns": 0,
- "depends_on": "show_in_website",
+ "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website",
"fieldname": "sb72",
"fieldtype": "Section Break",
"hidden": 0,
@@ -2915,11 +3010,12 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "show_in_website",
+ "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website",
"fieldname": "copy_from_item_group",
"fieldtype": "Button",
"hidden": 0,
@@ -2944,11 +3040,12 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "show_in_website",
+ "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website",
"fieldname": "website_specifications",
"fieldtype": "Table",
"hidden": 0,
@@ -2974,11 +3071,12 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "show_in_website",
+ "depends_on": "eval: doc.show_in_website || doc.show_variant_in_website",
"fieldname": "web_long_description",
"fieldtype": "Text Editor",
"hidden": 0,
@@ -3003,6 +3101,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -3044,7 +3143,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 1,
- "modified": "2017-04-25 08:14:26.785497",
+ "modified": "2017-05-03 09:55:11.624283",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 66ab6ac..35760fd 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -74,7 +74,10 @@
out.update(get_pricing_rule_for_item(args))
- if args.get("doctype") in ("Sales Invoice", "Delivery Note") and out.stock_qty > 0:
+ if (args.get("doctype") == "Delivery Note" or
+ (args.get("doctype") == "Sales Invoice" and args.get('update_stock'))) \
+ and out.warehouse and out.stock_qty > 0:
+
if out.has_serial_no:
out.serial_no = get_serial_no(out)