diff --git a/erpnext/__init__.py b/erpnext/__init__.py index c66621856f..ccb7e8f936 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '10.1.15' +__version__ = '10.1.18' def get_default_company(user=None): '''Get default company for user''' diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html index 10f326242b..3d8aedcdcc 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html @@ -4,12 +4,21 @@ .print-format { padding: 8mm; margin:4mm; - font-size:10px; + font-size: 10.0pt !important; font-family: Tahoma, sans-serif; } } {% } %} + +
+
+* To make item alternative, goto module Stock > Items and Pricing > Item Alternative
+
+
+The user can enable Two-Way between an item and their alternative item if both can be used as an alternative to each other
+
+
+### Item Alternative for work order
+
+To allow to use alternative items in the manufacturing process user can configure allow an alternative item in the BOM/Work Order
+
+##### Provision to allow alternative item in the bom
+
+
+##### Provision to allow alternative item in the work order
+User can also enable/disable allow alternative item in the work order
+
+
+##### How it works for work order
+
+
+### Item Alternative for subcontract
+In subcontract, the user has to transfer raw materials to the subcontracted supplier to get finished good from them. If the raw material is not available in the stock, with this feature, the user can transfer the alternate item of the subcontracted raw material to the supplier.
+
+##### How it works for subcontract
+
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom/bom.json b/erpnext/manufacturing/doctype/bom/bom.json
index 30b9683638..b2f7bb3524 100644
--- a/erpnext/manufacturing/doctype/bom/bom.json
+++ b/erpnext/manufacturing/doctype/bom/bom.json
@@ -42,6 +42,7 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -73,6 +74,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -106,6 +108,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -136,6 +139,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -168,6 +172,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -196,6 +201,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -228,6 +234,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -260,6 +267,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -290,6 +298,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -320,6 +329,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -351,6 +361,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -382,6 +393,38 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "allow_alternative_item",
+ "fieldtype": "Check",
+ "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": "Allow Alternative Item",
+ "length": 0,
+ "no_copy": 0,
+ "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,
+ "translatable": 0,
"unique": 0
},
{
@@ -412,6 +455,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -443,6 +487,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -472,6 +517,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -503,6 +549,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -533,6 +580,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -565,6 +613,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -597,6 +646,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -627,6 +677,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -659,6 +710,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -689,6 +741,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -720,6 +773,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -750,6 +804,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -780,6 +835,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -810,6 +866,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -841,6 +898,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -869,6 +927,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -900,6 +959,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -931,6 +991,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -962,6 +1023,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -991,6 +1053,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1021,6 +1084,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1050,6 +1114,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1081,6 +1146,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1110,6 +1176,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1142,6 +1209,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1172,6 +1240,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1200,6 +1269,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1230,6 +1300,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1259,6 +1330,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1288,6 +1360,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1317,6 +1390,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1347,6 +1421,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1378,6 +1453,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1408,6 +1484,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1440,6 +1517,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1471,6 +1549,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1502,6 +1581,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1532,6 +1612,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1564,6 +1645,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1594,6 +1676,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1626,6 +1709,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1657,6 +1741,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1688,6 +1773,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1719,6 +1805,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
}
],
@@ -1733,7 +1820,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-02-16 13:43:55.485813",
+ "modified": "2018-02-26 22:51:40.232456",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "BOM",
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index ea33f4ed02..007299a798 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -543,6 +543,7 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite
item.description,
item.image,
item.stock_uom,
+ item.allow_alternative_item,
item.default_warehouse,
item.expense_account as expense_account,
item.buying_cost_center as cost_center
@@ -606,6 +607,9 @@ def validate_bom_no(item, bom_no):
for d in bom.items:
if (d.item_code.lower() == item.lower()):
rm_item_exists = True
+ for d in bom.scrap_items:
+ if (d.item_code.lower() == item.lower()):
+ rm_item_exists = True
if bom.item.lower() == item.lower() or \
bom.item.lower() == cstr(frappe.db.get_value("Item", item, "variant_of")).lower():
rm_item_exists = True
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.js b/erpnext/manufacturing/doctype/work_order/work_order.js
index 7d50416d20..a1ebca05ce 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.js
+++ b/erpnext/manufacturing/doctype/work_order/work_order.js
@@ -171,7 +171,7 @@ frappe.ui.form.on("Work Order", {
frm.set_value('sales_order', "");
frm.trigger('set_sales_order');
erpnext.in_production_item_onchange = true;
- $.each(["description", "stock_uom", "project", "bom_no"], function(i, field) {
+ $.each(["description", "stock_uom", "project", "bom_no", "allow_alternative_item"], function(i, field) {
frm.set_value(field, r.message[field]);
});
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.json b/erpnext/manufacturing/doctype/work_order/work_order.json
index 6f6c4e42fb..e6bdc26a78 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.json
+++ b/erpnext/manufacturing/doctype/work_order/work_order.json
@@ -40,6 +40,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -71,6 +72,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 1,
+ "translatable": 0,
"unique": 0
},
{
@@ -105,6 +107,7 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -137,6 +140,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -171,6 +175,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -202,6 +207,38 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "allow_alternative_item",
+ "fieldtype": "Check",
+ "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": "Allow Alternative Item",
+ "length": 0,
+ "no_copy": 0,
+ "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,
+ "translatable": 0,
"unique": 0
},
{
@@ -231,6 +268,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0,
"width": "50%"
},
@@ -264,6 +302,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -297,6 +336,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -331,6 +371,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -362,6 +403,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -394,6 +436,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -425,6 +468,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -455,6 +499,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -485,6 +530,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -517,6 +563,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -545,6 +592,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -576,6 +624,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -606,6 +655,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -637,6 +687,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -668,6 +719,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -699,6 +751,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -729,6 +782,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -758,6 +812,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -788,6 +843,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -818,6 +874,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -848,6 +905,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -880,6 +938,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -912,6 +971,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -944,6 +1004,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -975,6 +1036,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1006,6 +1068,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1037,6 +1100,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1066,6 +1130,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1097,6 +1162,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1127,6 +1193,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1156,6 +1223,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1189,6 +1257,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1221,6 +1290,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1249,6 +1319,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0,
"width": "50%"
},
@@ -1282,6 +1353,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1312,6 +1384,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1342,6 +1415,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1373,6 +1447,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1403,6 +1478,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1435,6 +1511,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
}
],
@@ -1449,7 +1526,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-02-13 02:58:11.328693",
+ "modified": "2018-03-05 12:43:10.442928",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Work Order",
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py
index 6c632a5a03..bb773ab01a 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/work_order.py
@@ -489,6 +489,7 @@ class WorkOrder(Document):
'item_code': item.item_code,
'item_name': item.item_name,
'description': item.description,
+ 'allow_alternative_item': item.allow_alternative_item,
'required_qty': item.qty,
'source_warehouse': item.source_warehouse or item.default_warehouse
})
@@ -503,15 +504,17 @@ class WorkOrder(Document):
transferred_qty = frappe.db.sql('''select sum(qty)
from `tabStock Entry` entry, `tabStock Entry Detail` detail
where
- entry.work_order = %s
+ entry.work_order = %(name)s
and entry.purpose = "Material Transfer for Manufacture"
and entry.docstatus = 1
and detail.parent = entry.name
- and detail.item_code = %s''', (self.name, d.item_code))[0][0]
+ and (detail.item_code = %(item)s or detail.original_item = %(item)s)''', {
+ 'name': self.name,
+ 'item': d.item_code
+ })[0][0]
d.db_set('transferred_qty', flt(transferred_qty), update_modified = False)
-
@frappe.whitelist()
def get_item_details(item, project = None):
res = frappe.db.sql("""
@@ -548,6 +551,7 @@ def get_item_details(item, project = None):
frappe.throw(_("Default BOM for {0} not found").format(item))
res['project'] = project or frappe.db.get_value('BOM', res['bom_no'], 'project')
+ res['allow_alternative_item'] = frappe.db.get_value('BOM', res['bom_no'], 'allow_alternative_item')
res.update(check_if_scrap_warehouse_mandatory(res["bom_no"]))
return res
diff --git a/erpnext/manufacturing/doctype/work_order_item/work_order_item.json b/erpnext/manufacturing/doctype/work_order_item/work_order_item.json
index 1ac6b66047..2f89a3ded2 100644
--- a/erpnext/manufacturing/doctype/work_order_item/work_order_item.json
+++ b/erpnext/manufacturing/doctype/work_order_item/work_order_item.json
@@ -41,6 +41,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -72,6 +73,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -101,6 +103,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -131,6 +134,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -161,6 +165,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -191,6 +196,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -221,6 +227,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -252,6 +259,38 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "allow_alternative_item",
+ "fieldtype": "Check",
+ "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": "Allow Alternative Item",
+ "length": 0,
+ "no_copy": 0,
+ "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,
+ "translatable": 0,
"unique": 0
},
{
@@ -281,6 +320,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -311,6 +351,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -341,6 +382,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
}
],
@@ -354,7 +396,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2018-02-13 02:58:11.328693",
+ "modified": "2018-03-05 13:07:07.530725",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Work Order Item",
diff --git a/erpnext/patches/v10_0/fix_reserved_qty_for_sub_contract.py b/erpnext/patches/v10_0/fix_reserved_qty_for_sub_contract.py
index c49752213c..c0a9e5eb5b 100644
--- a/erpnext/patches/v10_0/fix_reserved_qty_for_sub_contract.py
+++ b/erpnext/patches/v10_0/fix_reserved_qty_for_sub_contract.py
@@ -6,6 +6,8 @@ import frappe
from erpnext.stock.utils import get_bin
def execute():
+ frappe.reload_doc("stock", "doctype", "bin")
+ frappe.reload_doc("buying", "doctype", "purchase_order_item_supplied")
for d in frappe.db.sql("""
select distinct rm_item_code, reserve_warehouse
from `tabPurchase Order Item Supplied`
@@ -26,4 +28,4 @@ def execute():
bin_doc = get_bin(d[0], d[1])
bin_doc.update_reserved_qty_for_production()
except:
- pass
\ No newline at end of file
+ pass
diff --git a/erpnext/projects/doctype/project/project.json b/erpnext/projects/doctype/project/project.json
index 8b41adc3ce..43cee681c6 100644
--- a/erpnext/projects/doctype/project/project.json
+++ b/erpnext/projects/doctype/project/project.json
@@ -42,6 +42,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -59,7 +60,7 @@
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
- "in_standard_filter": 0,
+ "in_standard_filter": 1,
"label": "Status",
"length": 0,
"no_copy": 1,
@@ -75,6 +76,7 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -91,7 +93,7 @@
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
- "in_standard_filter": 0,
+ "in_standard_filter": 1,
"label": "Project Type",
"length": 0,
"no_copy": 0,
@@ -107,6 +109,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -139,6 +142,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -171,6 +175,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -200,6 +205,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -216,7 +222,7 @@
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
- "in_standard_filter": 0,
+ "in_standard_filter": 1,
"label": "Priority",
"length": 0,
"no_copy": 0,
@@ -232,6 +238,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -263,6 +270,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -294,6 +302,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -323,6 +332,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -354,6 +364,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -386,6 +397,7 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -415,6 +427,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -446,6 +459,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -476,6 +490,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -508,6 +523,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -539,6 +555,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -570,6 +587,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -600,6 +618,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -631,6 +650,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -662,6 +682,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -692,6 +713,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -722,6 +744,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -752,6 +775,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -781,6 +805,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -812,6 +837,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -843,6 +869,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -875,6 +902,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -906,6 +934,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -937,6 +966,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -967,6 +997,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -997,6 +1028,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1026,6 +1058,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1056,6 +1089,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1087,6 +1121,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1117,6 +1152,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1147,6 +1183,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1177,6 +1214,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1207,6 +1245,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0,
"width": "50%"
},
@@ -1240,6 +1279,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1269,6 +1309,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1301,6 +1342,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1332,6 +1374,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1363,6 +1406,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1395,6 +1439,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1424,6 +1469,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1455,6 +1501,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1486,6 +1533,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1517,6 +1565,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1548,6 +1597,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1579,6 +1629,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1611,6 +1662,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -1642,6 +1694,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
}
],
@@ -1656,7 +1709,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 4,
- "modified": "2018-03-22 11:44:38.723507",
+ "modified": "2018-03-28 10:19:32.743900",
"modified_by": "Administrator",
"module": "Projects",
"name": "Project",
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 37291d7500..0e6017987a 100644
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -184,6 +184,142 @@ $.extend(erpnext.utils, {
},
});
+erpnext.utils.select_alternate_items = function(opts) {
+ const frm = opts.frm;
+ const warehouse_field = opts.warehouse_field || 'warehouse';
+ const item_field = opts.item_field || 'item_code';
+
+ this.data = [];
+ const dialog = new frappe.ui.Dialog({
+ title: __("Select Alternate Item"),
+ fields: [
+ {fieldtype:'Section Break', label: __('Items')},
+ {
+ fieldname: "alternative_items", fieldtype: "Table", cannot_add_rows: true,
+ in_place_edit: true, data: this.data,
+ get_data: () => {
+ return this.data;
+ },
+ fields: [{
+ fieldtype:'Data',
+ fieldname:"docname",
+ hidden: 1
+ }, {
+ fieldtype:'Link',
+ fieldname:"item_code",
+ options: 'Item',
+ in_list_view: 1,
+ read_only: 1,
+ label: __('Item Code')
+ }, {
+ fieldtype:'Link',
+ fieldname:"alternate_item",
+ options: 'Item',
+ default: "",
+ in_list_view: 1,
+ label: __('Alternate Item'),
+ onchange: function() {
+ const item_code = this.get_value();
+ const warehouse = this.grid_row.on_grid_fields_dict.warehouse.get_value();
+ if (item_code && warehouse) {
+ frappe.call({
+ method: "erpnext.stock.utils.get_latest_stock_qty",
+ args: {
+ item_code: item_code,
+ warehouse: warehouse
+ },
+ callback: (r) => {
+ this.grid_row.on_grid_fields_dict
+ .actual_qty.set_value(r.message || 0);
+ }
+ })
+ }
+ },
+ get_query: (e) => {
+ return {
+ query: "erpnext.stock.doctype.item_alternative.item_alternative.get_alternative_items",
+ filters: {
+ item_code: e.item_code
+ }
+ };
+ }
+ }, {
+ fieldtype:'Link',
+ fieldname:"warehouse",
+ options: 'Warehouse',
+ default: "",
+ in_list_view: 1,
+ label: __('Warehouse'),
+ onchange: function() {
+ const warehouse = this.get_value();
+ const item_code = this.grid_row.on_grid_fields_dict.item_code.get_value();
+ if (item_code && warehouse) {
+ frappe.call({
+ method: "erpnext.stock.utils.get_latest_stock_qty",
+ args: {
+ item_code: item_code,
+ warehouse: warehouse
+ },
+ callback: (r) => {
+ this.grid_row.on_grid_fields_dict
+ .actual_qty.set_value(r.message || 0);
+ }
+ })
+ }
+ },
+ }, {
+ fieldtype:'Float',
+ fieldname:"actual_qty",
+ default: 0,
+ read_only: 1,
+ in_list_view: 1,
+ label: __('Available Qty')
+ }]
+ },
+ ],
+ primary_action: function() {
+ const args = this.get_values()["alternative_items"];
+ const alternative_items = args.filter(d => {
+ if (d.alternate_item && d.item_code != d.alternate_item) {
+ return true;
+ }
+ });
+
+ alternative_items.forEach(d => {
+ let row = frappe.get_doc(opts.child_doctype, d.docname);
+ let qty = row.qty;
+ row[item_field] = d.alternate_item;
+
+ frm.script_manager.trigger(item_field, row.doctype, row.name)
+ .then(() => {
+ frappe.model.set_value(row.doctype, row.name, 'qty', qty);
+ frappe.model.set_value(row.doctype, row.name,
+ opts.original_item_field, d.item_code);
+ });
+ });
+
+ refresh_field(opts.child_docname);
+ this.hide();
+ },
+ primary_action_label: __('Update')
+ });
+
+ frm.doc[opts.child_docname].forEach(d => {
+ if (!opts.condition || opts.condition(d)) {
+ dialog.fields_dict.alternative_items.df.data.push({
+ "docname": d.name,
+ "item_code": d[item_field],
+ "warehouse": d[warehouse_field],
+ "actual_qty": d.actual_qty
+ });
+ }
+ })
+
+ this.data = dialog.fields_dict.alternative_items.df.data;
+ dialog.fields_dict.alternative_items.grid.refresh();
+ dialog.show();
+}
+
erpnext.utils.map_current_doc = function(opts) {
if(opts.get_query_filters) {
opts.get_query = function() {
diff --git a/erpnext/public/js/utils/item_quick_entry.js b/erpnext/public/js/utils/item_quick_entry.js
index ebb92dac8f..b2e0b85556 100644
--- a/erpnext/public/js/utils/item_quick_entry.js
+++ b/erpnext/public/js/utils/item_quick_entry.js
@@ -319,7 +319,8 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({
["parent", "=", $(e.target).attr("data-fieldname")],
["attribute_value", "like", e.target.value + "%"]
],
- fields: ["attribute_value"]
+ fields: ["attribute_value"],
+ parent: "Item"
},
callback: function(r) {
if (r.message) {
diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js
index 0fb87300bb..78def269df 100644
--- a/erpnext/public/js/utils/serial_no_batch_selector.js
+++ b/erpnext/public/js/utils/serial_no_batch_selector.js
@@ -85,8 +85,6 @@ erpnext.SerialNoBatchSelector = Class.extend({
fields: fields
});
- this.bind_qty();
-
this.dialog.set_primary_action(__('Insert'), function() {
me.values = me.dialog.get_values();
if(me.validate()) {
@@ -102,17 +100,24 @@ erpnext.SerialNoBatchSelector = Class.extend({
}
if (d.batch_no) {
- this.dialog.fields_dict.batches.df.data.push({
- 'batch_no': d.batch_no,
- 'actual_qty': d.actual_qty,
- 'selected_qty': d.qty,
- 'available_qty': d.actual_batch_qty
+ this.frm.doc.items.forEach(data => {
+ if(data.item_code == d.item_code) {
+ this.dialog.fields_dict.batches.df.data.push({
+ 'batch_no': data.batch_no,
+ 'actual_qty': data.actual_qty,
+ 'selected_qty': data.qty,
+ 'available_qty': data.actual_batch_qty
+ });
+ }
});
-
this.dialog.fields_dict.batches.grid.refresh();
}
}
+ if (this.has_batch) {
+ this.update_total_qty();
+ }
+
this.dialog.show();
},
@@ -161,18 +166,44 @@ erpnext.SerialNoBatchSelector = Class.extend({
var me = this;
if(this.has_batch) {
this.values.batches.map((batch, i) => {
- let item_code_field = {};
- let row = (i !== 0) ? this.frm.add_child("items", this.item) : this.item;
+ let batch_no = batch.batch_no;
+ let row = '';
+
+ if (i !== 0 && !this.batch_exists(batch_no)) {
+ row = this.frm.add_child("items", {
+ 'item_code': this.item.item_code,
+ 'item_name': this.item.item_name,
+ 'price_list_rate': this.item.price_list_rate,
+ 'rate': this.item.rate,
+ 'qty': batch.selected_qty,
+ 'batch_no': batch_no,
+ 'actual_qty': this.item.actual_qty,
+ 'discount_percentage': this.item.discount_percentage
+ });
+ } else {
+ row = this.frm.doc.items.find(i => i.batch_no === batch_no);
+ }
+
+ if (!row) {
+ row = this.item;
+ }
+
this.map_row_values(row, batch, 'batch_no',
'selected_qty', this.values.warehouse);
});
} else {
this.map_row_values(this.item, this.values, 'serial_no', 'qty');
}
+
refresh_field("items");
this.callback && this.callback(this.item);
},
+ batch_exists: function(batch) {
+ const batches = this.frm.doc.items.map(data => data.batch_no);
+ return (batches && in_list(batches, batch)) ? true : false;
+ },
+
map_row_values: function(row, values, number, qty_field, warehouse) {
row.qty = values[qty_field];
row[number] = values[number];
@@ -185,20 +216,15 @@ erpnext.SerialNoBatchSelector = Class.extend({
}
},
- bind_qty: function() {
- let batches_field = this.dialog.fields_dict.batches;
+ update_total_qty: function() {
let qty_field = this.dialog.fields_dict.qty;
- if(batches_field) {
- batches_field.grid.wrapper.on('change', function() {
- let total_qty = 0;
- batches_field.grid.wrapper.find(
- 'input[data-fieldname="selected_qty"]').each(function() {
+ let total_qty = 0;
- total_qty += Number($(this).val());
- });
- qty_field.set_input(total_qty);
- });
- }
+ this.dialog.fields_dict.batches.df.data.forEach(data => {
+ total_qty += flt(data.selected_qty);
+ });
+
+ qty_field.set_input(total_qty);
},
get_batch_fields: function() {
@@ -230,7 +256,10 @@ erpnext.SerialNoBatchSelector = Class.extend({
if(row === this.grid_row) {
return "";
}
- return row.on_grid_fields_dict.batch_no.get_value();
+
+ if (row.on_grid_fields_dict.batch_no) {
+ return row.on_grid_fields_dict.batch_no.get_value();
+ }
});
if(selected_batches.includes(val)) {
this.set_value("");
@@ -293,6 +322,8 @@ erpnext.SerialNoBatchSelector = Class.extend({
} else {
this.grid.refresh();
}
+
+ me.update_total_qty();
}
},
],
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js
index a027a98656..6d8d1b74c4 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.js
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.js
@@ -9,7 +9,7 @@ frappe.pages['point-of-sale'].on_page_load = function(wrapper) {
});
frappe.db.get_value('POS Settings', {name: 'POS Settings'}, 'is_online', (r) => {
- if (r && r.use_pos_in_offline_mode && !cint(r.use_pos_in_offline_mode)) {
+ if (r && !cint(r.use_pos_in_offline_mode)) {
// online
wrapper.pos = new erpnext.pos.PointOfSale(wrapper);
window.cur_pos = wrapper.pos;
@@ -23,7 +23,7 @@ frappe.pages['point-of-sale'].on_page_load = function(wrapper) {
frappe.pages['point-of-sale'].refresh = function(wrapper) {
if (wrapper.pos) {
- cur_frm = wrapper.pos.frm;
+ wrapper.pos.make_new_invoice();
}
if (frappe.flags.is_offline) {
@@ -96,8 +96,8 @@ erpnext.pos.PointOfSale = class PointOfSale {
wrapper: this.wrapper.find('.cart-container'),
events: {
on_customer_change: (customer) => this.frm.set_value('customer', customer),
- on_field_change: (item_code, field, value) => {
- this.update_item_in_cart(item_code, field, value);
+ on_field_change: (item_code, field, value, batch_no) => {
+ this.update_item_in_cart(item_code, field, value, batch_no);
},
on_numpad: (value) => {
if (value == 'Pay') {
@@ -158,10 +158,12 @@ erpnext.pos.PointOfSale = class PointOfSale {
});
}
- update_item_in_cart(item_code, field='qty', value=1) {
+ update_item_in_cart(item_code, field='qty', value=1, batch_no) {
frappe.dom.freeze();
- if(this.cart.exists(item_code)) {
- const item = this.frm.doc.items.find(i => i.item_code === item_code);
+ if(this.cart.exists(item_code, batch_no)) {
+ const search_field = batch_no ? 'batch_no' : 'item_code';
+ const search_value = batch_no || item_code;
+ const item = this.frm.doc.items.find(i => i[search_field] === search_value);
frappe.flags.hide_serial_batch_dialog = false;
if (typeof value === 'string' && !in_list(['serial_no', 'batch_no'], field)) {
@@ -219,29 +221,31 @@ erpnext.pos.PointOfSale = class PointOfSale {
]);
}
- select_batch_and_serial_no(item) {
+ select_batch_and_serial_no(row) {
frappe.dom.unfreeze();
- erpnext.show_serial_batch_selector(this.frm, item, () => {
- this.update_item_in_frm(item, 'qty', item.qty)
- .then(() => {
- // update cart
- frappe.run_serially([
- () => {
- if (item.qty === 0) {
- frappe.model.clear_doc(item.doctype, item.name);
- }
- },
- () => this.update_cart_data(item)
- ]);
- });
+ erpnext.show_serial_batch_selector(this.frm, row, () => {
+ this.frm.doc.items.forEach(item => {
+ this.update_item_in_frm(item, 'qty', item.qty)
+ .then(() => {
+ // update cart
+ frappe.run_serially([
+ () => {
+ if (item.qty === 0) {
+ frappe.model.clear_doc(item.doctype, item.name);
+ }
+ },
+ () => this.update_cart_data(item)
+ ]);
+ });
+ })
}, () => {
- this.on_close(item);
+ this.on_close(row);
}, true);
}
on_close(item) {
- if (!this.cart.exists(item.item_code) && item.qty) {
+ if (!this.cart.exists(item.item_code, item.batch_no) && item.qty) {
frappe.model.clear_doc(item.doctype, item.name);
}
}
@@ -492,6 +496,11 @@ erpnext.pos.PointOfSale = class PointOfSale {
//
// }).addClass('visible-xs');
+ this.page.add_menu_item(__("Form View"), function () {
+ frappe.model.sync(me.frm.doc);
+ frappe.set_route("Form", me.frm.doc.doctype, me.frm.doc.name);
+ });
+
this.page.add_menu_item(__("POS Profile"), function () {
frappe.set_route('List', 'POS Profile');
});
@@ -602,11 +611,15 @@ class POSCart {
this.customer_field.set_value("");
this.frm.msgbox = "";
+ let total_item_qty = 0.0;
+ this.frm.set_value("pos_total_qty",total_item_qty);
+
this.$discount_amount.find('input:text').val('');
this.wrapper.find('.grand-total-value').text(
format_currency(this.frm.doc.grand_total, this.frm.currency));
this.wrapper.find('.rounded-total-value').text(
format_currency(this.frm.doc.rounded_total, this.frm.currency));
+ this.$qty_total.find(".quantity-total").text(total_item_qty);
const customer = this.frm.doc.customer;
this.customer_field.set_value(customer);
@@ -721,7 +734,7 @@ class POSCart {
total_item_qty += d.qty;
}
});
- this.$qty_total.find('.quantity-total').text(total_item_qty)
+ this.$qty_total.find('.quantity-total').text(total_item_qty);
this.frm.set_value("pos_total_qty",total_item_qty);
}
@@ -804,10 +817,11 @@ class POSCart {
this.numpad.reset_value();
} else {
const item_code = this.selected_item.attr('data-item-code');
+ const batch_no = this.selected_item.attr('data-batch-no');
const field = this.selected_item.active_field;
const value = this.numpad.get_value();
- this.events.on_field_change(item_code, field, value);
+ this.events.on_field_change(item_code, field, value, batch_no);
}
}
@@ -835,7 +849,7 @@ class POSCart {
add_item(item) {
this.$empty_state.hide();
- if (this.exists(item.item_code)) {
+ if (this.exists(item.item_code, item.batch_no)) {
// update quantity
this.update_item(item);
} else if (flt(item.qty) > 0.0) {
@@ -848,7 +862,10 @@ class POSCart {
}
update_item(item) {
- const $item = this.$cart_items.find(`[data-item-code="${item.item_code}"]`);
+ const item_selector = item.batch_no ?
+ `[data-batch-no="${item.batch_no}"]` : `[data-item-code="${item.item_code}"]`;
+
+ const $item = this.$cart_items.find(item_selector);
if(item.qty > 0) {
const is_stock_item = this.get_item_details(item.item_code).is_stock_item;
@@ -870,7 +887,8 @@ class POSCart {
const rate = format_currency(item.rate, this.frm.doc.currency);
const indicator_class = (!is_stock_item || item.actual_qty >= item.qty) ? 'green' : 'red';
return `
-