Merge branch 'develop' into revert-19265-issue_fix
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 686d549..d031bc5 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -5,7 +5,7 @@
from erpnext.hooks import regional_overrides
from frappe.utils import getdate
-__version__ = '12.1.6'
+__version__ = '12.1.8'
def get_default_company(user=None):
'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index 172d537..1e0b1bc 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -308,7 +308,7 @@
() => {
frm.set_party_account_based_on_party = false;
if (r.message.bank_account) {
- frm.set_value("bank_account", r.message.bank_account);
+ frm.set_value("party_bank_account", r.message.bank_account);
}
}
]);
diff --git a/erpnext/config/accounting.py b/erpnext/config/accounts.py
similarity index 100%
rename from erpnext/config/accounting.py
rename to erpnext/config/accounts.py
diff --git a/erpnext/config/desktop.py b/erpnext/config/desktop.py
index 8ce0964..95f6f7c 100644
--- a/erpnext/config/desktop.py
+++ b/erpnext/config/desktop.py
@@ -18,7 +18,7 @@
"onboard_present": 1
},
{
- "module_name": "Accounting",
+ "module_name": "Accounts",
"category": "Modules",
"label": _("Accounting"),
"color": "#3498db",
diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py
index 928bd5f..5db4cc2 100644
--- a/erpnext/config/selling.py
+++ b/erpnext/config/selling.py
@@ -127,7 +127,11 @@
"name": "Shipping Rule",
"description": _("Rules for adding shipping costs."),
},
-
+ {
+ "type": "doctype",
+ "name": "Coupon Code",
+ "description": _("Define coupon codes."),
+ }
]
},
{
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 19dea08..2f6b59f 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -280,22 +280,31 @@
"page_len": page_len
}
+ having_clause = "having sum(sle.actual_qty) > 0"
+ if filters.get("is_return"):
+ having_clause = ""
+
if args.get('warehouse'):
- batch_nos = frappe.db.sql("""select sle.batch_no, round(sum(sle.actual_qty),2), sle.stock_uom, concat('MFG-',batch.manufacturing_date), concat('EXP-',batch.expiry_date)
- from `tabStock Ledger Entry` sle
- INNER JOIN `tabBatch` batch on sle.batch_no = batch.name
- where
- batch.disabled = 0
- and sle.item_code = %(item_code)s
- and sle.warehouse = %(warehouse)s
- and (sle.batch_no like %(txt)s
- or batch.manufacturing_date like %(txt)s)
- and batch.docstatus < 2
- {0}
- {match_conditions}
- group by batch_no having sum(sle.actual_qty) > 0
- order by batch.expiry_date, sle.batch_no desc
- limit %(start)s, %(page_len)s""".format(cond, match_conditions=get_match_cond(doctype)), args)
+ batch_nos = frappe.db.sql("""select sle.batch_no, round(sum(sle.actual_qty),2), sle.stock_uom,
+ concat('MFG-',batch.manufacturing_date), concat('EXP-',batch.expiry_date)
+ from `tabStock Ledger Entry` sle
+ INNER JOIN `tabBatch` batch on sle.batch_no = batch.name
+ where
+ batch.disabled = 0
+ and sle.item_code = %(item_code)s
+ and sle.warehouse = %(warehouse)s
+ and (sle.batch_no like %(txt)s
+ or batch.manufacturing_date like %(txt)s)
+ and batch.docstatus < 2
+ {cond}
+ {match_conditions}
+ group by batch_no {having_clause}
+ order by batch.expiry_date, sle.batch_no desc
+ limit %(start)s, %(page_len)s""".format(
+ cond=cond,
+ match_conditions=get_match_cond(doctype),
+ having_clause = having_clause
+ ), args)
return batch_nos
else:
diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py
index 48dcdbe..a395c7c 100644
--- a/erpnext/demo/setup/setup_data.py
+++ b/erpnext/demo/setup/setup_data.py
@@ -10,13 +10,14 @@
from frappe import _
def setup(domain):
+ frappe.flags.in_demo = 1
complete_setup(domain)
setup_demo_page()
setup_fiscal_year()
setup_holiday_list()
setup_user()
setup_employee()
- setup_user_roles()
+ setup_user_roles(domain)
setup_role_permissions()
setup_custom_field_for_domain()
@@ -183,13 +184,19 @@
return ss
-def setup_user_roles():
+def setup_user_roles(domain):
user = frappe.get_doc('User', 'demo@erpnext.com')
user.add_roles('HR User', 'HR Manager', 'Accounts User', 'Accounts Manager',
'Stock User', 'Stock Manager', 'Sales User', 'Sales Manager', 'Purchase User',
'Purchase Manager', 'Projects User', 'Manufacturing User', 'Manufacturing Manager',
- 'Support Team', 'Academics User', 'Physician', 'Healthcare Administrator', 'Laboratory User',
- 'Nursing User', 'Patient')
+ 'Support Team')
+
+ if domain == "Healthcare":
+ user.add_roles('Physician', 'Healthcare Administrator', 'Laboratory User',
+ 'Nursing User', 'Patient')
+
+ if domain == "Education":
+ user.add_roles('Academics User')
if not frappe.db.get_global('demo_hr_user'):
user = frappe.get_doc('User', 'CaitlinSnow@example.com')
@@ -219,7 +226,7 @@
if not frappe.db.get_global('demo_manufacturing_user'):
user = frappe.get_doc('User', 'NeptuniaAquaria@example.com')
- user.add_roles('Manufacturing User', 'Stock User', 'Purchase User', 'Accounts User')
+ user.add_roles('Manufacturing User', 'Stock Manager', 'Stock User', 'Purchase User', 'Accounts User')
update_employee_department(user.name, 'Production')
frappe.db.set_global('demo_manufacturing_user', user.name)
@@ -241,11 +248,12 @@
update_employee_department(user.name, 'Management')
frappe.db.set_global('demo_projects_user', user.name)
- if not frappe.db.get_global('demo_education_user'):
- user = frappe.get_doc('User', 'ArthurCurry@example.com')
- user.add_roles('Academics User')
- update_employee_department(user.name, 'Management')
- frappe.db.set_global('demo_education_user', user.name)
+ if domain == "Education":
+ if not frappe.db.get_global('demo_education_user'):
+ user = frappe.get_doc('User', 'ArthurCurry@example.com')
+ user.add_roles('Academics User')
+ update_employee_department(user.name, 'Management')
+ frappe.db.set_global('demo_education_user', user.name)
#Add Expense Approver
user = frappe.get_doc('User', 'ClarkKent@example.com')
diff --git a/erpnext/demo/user/accounts.py b/erpnext/demo/user/accounts.py
index 6206dfd..7fab772 100644
--- a/erpnext/demo/user/accounts.py
+++ b/erpnext/demo/user/accounts.py
@@ -73,14 +73,16 @@
make_pos_invoice()
def make_payment_entries(ref_doctype, report):
- outstanding_invoices = list(set([r[3] for r in query_report.run(report, {
- "report_date": frappe.flags.current_date,
- "company": erpnext.get_default_company()
- })["result"] if r[2]==ref_doctype]))
+
+ outstanding_invoices = frappe.get_all(ref_doctype, fields=["name"],
+ filters={
+ "company": erpnext.get_default_company(),
+ "outstanding_amount": (">", 0.0)
+ })
# make Payment Entry
for inv in outstanding_invoices[:random.randint(1, 2)]:
- pe = get_payment_entry(ref_doctype, inv)
+ pe = get_payment_entry(ref_doctype, inv.name)
pe.posting_date = frappe.flags.current_date
pe.reference_no = random_string(6)
pe.reference_date = frappe.flags.current_date
@@ -91,7 +93,7 @@
# make payment via JV
for inv in outstanding_invoices[:1]:
- jv = frappe.get_doc(get_payment_entry_against_invoice(ref_doctype, inv))
+ jv = frappe.get_doc(get_payment_entry_against_invoice(ref_doctype, inv.name))
jv.posting_date = frappe.flags.current_date
jv.cheque_no = random_string(6)
jv.cheque_date = frappe.flags.current_date
diff --git a/erpnext/demo/user/projects.py b/erpnext/demo/user/projects.py
index 36d676f..044e296 100644
--- a/erpnext/demo/user/projects.py
+++ b/erpnext/demo/user/projects.py
@@ -39,61 +39,4 @@
"doctype": "Project",
"project_name": "New Product Development " + current_date.strftime("%Y-%m-%d"),
})
- project.set("tasks", [
- {
- "title": "Review Requirements",
- "start_date": frappe.utils.add_days(current_date, 10),
- "end_date": frappe.utils.add_days(current_date, 11)
- },
- {
- "title": "Design Options",
- "start_date": frappe.utils.add_days(current_date, 11),
- "end_date": frappe.utils.add_days(current_date, 20)
- },
- {
- "title": "Make Prototypes",
- "start_date": frappe.utils.add_days(current_date, 20),
- "end_date": frappe.utils.add_days(current_date, 30)
- },
- {
- "title": "Customer Feedback on Prototypes",
- "start_date": frappe.utils.add_days(current_date, 30),
- "end_date": frappe.utils.add_days(current_date, 40)
- },
- {
- "title": "Freeze Feature Set",
- "start_date": frappe.utils.add_days(current_date, 40),
- "end_date": frappe.utils.add_days(current_date, 45)
- },
- {
- "title": "Testing",
- "start_date": frappe.utils.add_days(current_date, 45),
- "end_date": frappe.utils.add_days(current_date, 60)
- },
- {
- "title": "Product Engineering",
- "start_date": frappe.utils.add_days(current_date, 45),
- "end_date": frappe.utils.add_days(current_date, 55)
- },
- {
- "title": "Supplier Contracts",
- "start_date": frappe.utils.add_days(current_date, 55),
- "end_date": frappe.utils.add_days(current_date, 70)
- },
- {
- "title": "Design and Build Fixtures",
- "start_date": frappe.utils.add_days(current_date, 45),
- "end_date": frappe.utils.add_days(current_date, 65)
- },
- {
- "title": "Test Run",
- "start_date": frappe.utils.add_days(current_date, 70),
- "end_date": frappe.utils.add_days(current_date, 80)
- },
- {
- "title": "Launch",
- "start_date": frappe.utils.add_days(current_date, 80),
- "end_date": frappe.utils.add_days(current_date, 90)
- },
- ])
project.insert()
diff --git a/erpnext/demo/user/sales.py b/erpnext/demo/user/sales.py
index 457e976..8d5ba28 100644
--- a/erpnext/demo/user/sales.py
+++ b/erpnext/demo/user/sales.py
@@ -66,7 +66,7 @@
b = frappe.get_doc({
"doctype": "Opportunity",
"opportunity_from": "Customer",
- "customer": get_random("Customer"),
+ "party_name": frappe.get_value("Customer", get_random("Customer"), 'name'),
"opportunity_type": "Sales",
"with_items": 1,
"transaction_date": frappe.flags.current_date,
diff --git a/erpnext/manufacturing/doctype/blanket_order/blanket_order.js b/erpnext/manufacturing/doctype/blanket_order/blanket_order.js
index 0bbf689..1cd9446 100644
--- a/erpnext/manufacturing/doctype/blanket_order/blanket_order.js
+++ b/erpnext/manufacturing/doctype/blanket_order/blanket_order.js
@@ -12,6 +12,7 @@
},
refresh: function(frm) {
+ erpnext.hide_company();
if (frm.doc.customer && frm.doc.docstatus === 1) {
frm.add_custom_button(__('View Orders'), function() {
frappe.set_route('List', 'Sales Order', {blanket_order: frm.doc.name});
@@ -51,11 +52,19 @@
set_tc_name_filter: function(frm) {
if (frm.doc.blanket_order_type === 'Selling') {
+ frm.set_df_property("customer","reqd", 1);
+ frm.set_df_property("supplier","reqd", 0);
+ frm.set_value("supplier", "");
+
frm.set_query("tc_name", function() {
return { filters: { selling: 1 } };
});
}
if (frm.doc.blanket_order_type === 'Purchasing') {
+ frm.set_df_property("supplier","reqd", 1);
+ frm.set_df_property("customer","reqd", 0);
+ frm.set_value("customer", "");
+
frm.set_query("tc_name", function() {
return { filters: { buying: 1 } };
});
diff --git a/erpnext/manufacturing/doctype/blanket_order/blanket_order.json b/erpnext/manufacturing/doctype/blanket_order/blanket_order.json
index 570d435..260e0b8 100644
--- a/erpnext/manufacturing/doctype/blanket_order/blanket_order.json
+++ b/erpnext/manufacturing/doctype/blanket_order/blanket_order.json
@@ -88,7 +88,8 @@
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
- "options": "Company"
+ "options": "Company",
+ "reqd": 1
},
{
"fieldname": "section_break_12",
@@ -128,7 +129,7 @@
}
],
"is_submittable": 1,
- "modified": "2019-06-19 11:59:09.279607",
+ "modified": "2019-10-16 13:38:32.302316",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Blanket Order",
diff --git a/erpnext/manufacturing/doctype/blanket_order/blanket_order.py b/erpnext/manufacturing/doctype/blanket_order/blanket_order.py
index 822c7fc..faed707 100644
--- a/erpnext/manufacturing/doctype/blanket_order/blanket_order.py
+++ b/erpnext/manufacturing/doctype/blanket_order/blanket_order.py
@@ -4,13 +4,21 @@
from __future__ import unicode_literals
import frappe
-from frappe.utils import flt
+from frappe import _
+from frappe.utils import flt, getdate
from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
from erpnext.stock.doctype.item.item import get_item_defaults
class BlanketOrder(Document):
+ def validate(self):
+ self.validate_dates()
+
+ def validate_dates(self):
+ if getdate(self.from_date) > getdate(self.to_date):
+ frappe.throw(_("From date cannot be greater than To date"))
+
def update_ordered_qty(self):
ref_doctype = "Sales Order" if self.blanket_order_type == "Selling" else "Purchase Order"
item_ordered_qty = frappe._dict(frappe.db.sql("""
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 9f98099..ee6bdff 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -640,3 +640,4 @@
erpnext.patches.v12_0.set_produced_qty_field_in_sales_order_for_work_order
erpnext.patches.v12_0.generate_leave_ledger_entries
erpnext.patches.v12_0.set_default_shopify_app_type
+erpnext.patches.v12_0.replace_accounting_with_accounts_in_home_settings
diff --git a/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py b/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py
index 5c18985..3d1a88e 100644
--- a/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py
+++ b/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py
@@ -4,7 +4,7 @@
def execute():
- frappe.reload_doc('desk', 'doctype', 'auto_repeat')
+ frappe.reload_doc('automation', 'doctype', 'auto_repeat')
doctypes_to_rename = {
'accounts': ['Journal Entry', 'Payment Entry', 'Purchase Invoice', 'Sales Invoice'],
@@ -41,4 +41,4 @@
if field in frappe.db.get_table_columns("Subscription"):
fields_to_drop['Subscription'].append(field)
- frappe.model.delete_fields(fields_to_drop, delete=1)
\ No newline at end of file
+ frappe.model.delete_fields(fields_to_drop, delete=1)
diff --git a/erpnext/patches/v12_0/replace_accounting_with_accounts_in_home_settings.py b/erpnext/patches/v12_0/replace_accounting_with_accounts_in_home_settings.py
new file mode 100644
index 0000000..09fc4c1
--- /dev/null
+++ b/erpnext/patches/v12_0/replace_accounting_with_accounts_in_home_settings.py
@@ -0,0 +1,5 @@
+import frappe
+
+def execute():
+ frappe.db.sql("""UPDATE `tabUser` SET `home_settings` = REPLACE(`home_settings`, 'Accounting', 'Accounts')""")
+ frappe.cache().delete_key('home_settings')
\ No newline at end of file
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 5a2f3bc..ca492ba 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -1653,6 +1653,11 @@
'item_code': item.item_code,
'posting_date': me.frm.doc.posting_date || frappe.datetime.nowdate(),
}
+
+ if (doc.is_return) {
+ filters["is_return"] = 1;
+ }
+
if (item.warehouse) filters["warehouse"] = item.warehouse;
return {
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 9eb3748..e69a6aad 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -204,7 +204,7 @@
})
for default_account in default_accounts:
- if self.is_new() or frappe.flags.in_test:
+ if self.is_new() or frappe.flags.in_test or frappe.flags.in_demo:
self._set_default_account(default_account, default_accounts.get(default_account))
if not self.default_income_account:
diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py
index f850bc1..a4c10cf 100644
--- a/erpnext/shopping_cart/cart.py
+++ b/erpnext/shopping_cart/cart.py
@@ -66,7 +66,7 @@
from erpnext.selling.doctype.quotation.quotation import _make_sales_order
sales_order = frappe.get_doc(_make_sales_order(quotation.name, ignore_permissions=True))
- if not cart_settings.allow_items_not_in_stock:
+ if not cint(cart_settings.allow_items_not_in_stock):
for item in sales_order.get("items"):
item.reserved_warehouse, is_stock_item = frappe.db.get_value("Item",
item.item_code, ["website_warehouse", "is_stock_item"])
diff --git a/erpnext/www/all-products/item_row.html b/erpnext/www/all-products/item_row.html
index 9fa7fa3..9e62826 100644
--- a/erpnext/www/all-products/item_row.html
+++ b/erpnext/www/all-products/item_row.html
@@ -2,7 +2,7 @@
<div class="row no-gutters">
<div class="col-md-3">
<div class="card-body">
- <a class="no-underline" href="{{ item.route }}">
+ <a class="no-underline" href="/{{ item.route }}">
<img class="website-image" src="{{ item.website_image or item.image or 'no-image.jpg' }}" alt="{{ item.item_name }}">
</a>
</div>
@@ -10,14 +10,14 @@
<div class="col-md-9">
<div class="card-body">
<h5 class="card-title">
- <a class="text-dark" href="{{ item.route }}">
+ <a class="text-dark" href="/{{ item.route }}">
{{ item.item_name or item.name }}
</a>
</h5>
<p class="card-text">
{{ item.website_description or item.description or '<i class="text-muted">No description</i>' }}
</p>
- <a href="{{ item.route }}" class="btn btn-sm btn-light">{{ _('More details') }}</a>
+ <a href="/{{ item.route }}" class="btn btn-sm btn-light">{{ _('More details') }}</a>
</div>
</div>
</div>