Merge branch 'develop' into develop-customer-item-price-report
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 3e013f5..e2f99d6 100755
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -451,6 +451,10 @@
def add_customer(data):
+ customer = data.get('full_name') or data.get('customer')
+ if frappe.db.exists("Customer", customer.strip()):
+ return customer.strip()
+
customer_doc = frappe.new_doc('Customer')
customer_doc.customer_name = data.get('full_name') or data.get('customer')
customer_doc.customer_pos_id = data.get('customer_pos_id')
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index e41c74c..8f1dfbc 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -730,7 +730,6 @@
parent_fieldname = 'parent_' + doctype.lower().replace(' ', '_')
fields = [
'name as value',
- 'root_type',
'is_group as expandable'
]
filters = [['docstatus', '<', 2]]
@@ -738,11 +737,11 @@
filters.append(['ifnull(`{0}`,"")'.format(parent_fieldname), '=', '' if is_root else parent])
if is_root:
- fields += ['report_type', 'account_currency'] if doctype == 'Account' else []
+ fields += ['root_type', 'report_type', 'account_currency'] if doctype == 'Account' else []
filters.append(['company', '=', company])
else:
- fields += ['account_currency'] if doctype == 'Account' else []
+ fields += ['root_type', 'account_currency'] if doctype == 'Account' else []
fields += [parent_fieldname + ' as parent']
acc = frappe.get_list(doctype, fields=fields, filters=filters)
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 8e1510a..8d24e7a 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -323,7 +323,7 @@
self._set_in_company_currency(self.doc, ["total_taxes_and_charges", "rounding_adjustment"])
if self.doc.doctype in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
- self.doc.base_grand_total = flt(self.doc.grand_total * self.doc.conversion_rate) \
+ self.doc.base_grand_total = flt(self.doc.grand_total * self.doc.conversion_rate, self.doc.precision("base_grand_total")) \
if self.doc.total_taxes_and_charges else self.doc.base_net_total
else:
self.doc.taxes_and_charges_added = self.doc.taxes_and_charges_deducted = 0.0
diff --git a/erpnext/stock/dashboard/item_dashboard.js b/erpnext/stock/dashboard/item_dashboard.js
index 157dbfe..1bfa2cf 100644
--- a/erpnext/stock/dashboard/item_dashboard.js
+++ b/erpnext/stock/dashboard/item_dashboard.js
@@ -16,18 +16,47 @@
this.content = $(frappe.render_template('item_dashboard')).appendTo(this.parent);
this.result = this.content.find('.result');
- // move
this.content.on('click', '.btn-move', function() {
- erpnext.stock.move_item(unescape($(this).attr('data-item')), $(this).attr('data-warehouse'),
- null, $(this).attr('data-actual_qty'), null, function() { me.refresh(); });
+ handle_move_add($(this), "Move")
});
this.content.on('click', '.btn-add', function() {
- erpnext.stock.move_item(unescape($(this).attr('data-item')), null, $(this).attr('data-warehouse'),
- $(this).attr('data-actual_qty'), $(this).attr('data-rate'),
- function() { me.refresh(); });
+ handle_move_add($(this), "Add")
});
+ function handle_move_add(element, action) {
+ let item = unescape(element.attr('data-item'));
+ let warehouse = unescape(element.attr('data-warehouse'));
+ let actual_qty = unescape(element.attr('data-actual_qty'));
+ let disable_quick_entry = Number(unescape(element.attr('data-disable_quick_entry')));
+ let entry_type = action === "Move" ? "Material Transfer": null;
+
+ if (disable_quick_entry) {
+ open_stock_entry(item, warehouse, entry_type);
+ } else {
+ if (action === "Add") {
+ let rate = unescape($(this).attr('data-rate'));
+ erpnext.stock.move_item(item, null, warehouse, actual_qty, rate, function() { me.refresh(); });
+ }
+ else {
+ erpnext.stock.move_item(item, warehouse, null, actual_qty, null, function() { me.refresh(); });
+ }
+ }
+ }
+
+ function open_stock_entry(item, warehouse, entry_type) {
+ frappe.model.with_doctype('Stock Entry', function() {
+ var doc = frappe.model.get_new_doc('Stock Entry');
+ if (entry_type) doc.stock_entry_type = entry_type;
+
+ var row = frappe.model.add_child(doc, 'items');
+ row.item_code = item;
+ row.s_warehouse = warehouse;
+
+ frappe.set_route('Form', doc.doctype, doc.name);
+ })
+ }
+
// more
this.content.find('.btn-more').on('click', function() {
me.start += 20;
@@ -196,4 +225,4 @@
frappe.set_route('Form', doc.doctype, doc.name);
})
});
-}
\ No newline at end of file
+}
diff --git a/erpnext/stock/dashboard/item_dashboard.py b/erpnext/stock/dashboard/item_dashboard.py
index 487c765..cafb5c3 100644
--- a/erpnext/stock/dashboard/item_dashboard.py
+++ b/erpnext/stock/dashboard/item_dashboard.py
@@ -44,7 +44,9 @@
for item in items:
item.update({
- 'item_name': frappe.get_cached_value("Item", item.item_code, 'item_name')
+ 'item_name': frappe.get_cached_value("Item", item.item_code, 'item_name'),
+ 'disable_quick_entry': frappe.get_cached_value("Item", item.item_code, 'has_batch_no')
+ or frappe.get_cached_value("Item", item.item_code, 'has_serial_no'),
})
return items
diff --git a/erpnext/stock/dashboard/item_dashboard_list.html b/erpnext/stock/dashboard/item_dashboard_list.html
index 5a3fa2e..e1914ed 100644
--- a/erpnext/stock/dashboard/item_dashboard_list.html
+++ b/erpnext/stock/dashboard/item_dashboard_list.html
@@ -43,11 +43,13 @@
<div class="col-sm-2 text-right" style="margin-top: 8px;">
{% if d.actual_qty %}
<button class="btn btn-default btn-xs btn-move"
+ data-disable_quick_entry="{{ d.disable_quick_entry }}"
data-warehouse="{{ d.warehouse }}"
data-actual_qty="{{ d.actual_qty }}"
data-item="{{ escape(d.item_code) }}">{{ __("Move") }}</a>
{% endif %}
<button style="margin-left: 7px;" class="btn btn-default btn-xs btn-add"
+ data-disable_quick_entry="{{ d.disable_quick_entry }}"
data-warehouse="{{ d.warehouse }}"
data-actual_qty="{{ d.actual_qty }}"
data-item="{{ escape(d.item_code) }}"