Merge branch 'master' of git://github.com/akhileshdarjee/erpnext into akhileshdarjee-master
Conflicts:
accounts/doctype/pos_setting/pos_setting.txt
patches/patch_list.py
diff --git a/accounts/doctype/period_closing_voucher/period_closing_voucher.txt b/accounts/doctype/period_closing_voucher/period_closing_voucher.txt
index 1f2d35e..6c3fadd 100644
--- a/accounts/doctype/period_closing_voucher/period_closing_voucher.txt
+++ b/accounts/doctype/period_closing_voucher/period_closing_voucher.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:07",
"docstatus": 0,
- "modified": "2013-07-22 15:31:33",
+ "modified": "2013-08-12 17:13:23",
"modified_by": "Administrator",
"owner": "jai@webnotestech.com"
},
@@ -35,7 +35,6 @@
"permlevel": 0,
"read": 1,
"report": 1,
- "role": "Accounts Manager",
"submit": 1,
"write": 1
},
@@ -104,6 +103,7 @@
"oldfieldtype": "Column Break"
},
{
+ "description": "The account head under Liability, in which Profit/Loss will be booked",
"doctype": "DocField",
"fieldname": "closing_account_head",
"fieldtype": "Link",
@@ -131,6 +131,11 @@
"reqd": 1
},
{
- "doctype": "DocPerm"
+ "doctype": "DocPerm",
+ "role": "System Manager"
+ },
+ {
+ "doctype": "DocPerm",
+ "role": "Accounts Manager"
}
]
\ No newline at end of file
diff --git a/accounts/doctype/pos_setting/pos_setting.js b/accounts/doctype/pos_setting/pos_setting.js
index f472d3a..18f555b 100755
--- a/accounts/doctype/pos_setting/pos_setting.js
+++ b/accounts/doctype/pos_setting/pos_setting.js
@@ -6,7 +6,7 @@
if(r.message) set_field_options('naming_series', r.message);
});
- cur_frm.set_query("price_list_name", function() {
+ cur_frm.set_query("selling_price_list", function() {
return { filters: { buying_or_selling: "Selling" } };
});
}
diff --git a/accounts/doctype/pos_setting/pos_setting.txt b/accounts/doctype/pos_setting/pos_setting.txt
index a1c74cb..73b9246 100755
--- a/accounts/doctype/pos_setting/pos_setting.txt
+++ b/accounts/doctype/pos_setting/pos_setting.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 12:15:51",
"docstatus": 0,
- "modified": "2013-08-09 12:35:03",
+ "modified": "2013-08-09 16:35:03",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -92,7 +92,7 @@
},
{
"doctype": "DocField",
- "fieldname": "price_list_name",
+ "fieldname": "selling_price_list",
"fieldtype": "Link",
"label": "Price List",
"oldfieldname": "price_list_name",
diff --git a/accounts/doctype/pos_setting/test_pos_setting.py b/accounts/doctype/pos_setting/test_pos_setting.py
index 13106c2..579a75e 100644
--- a/accounts/doctype/pos_setting/test_pos_setting.py
+++ b/accounts/doctype/pos_setting/test_pos_setting.py
@@ -7,7 +7,7 @@
"name": "_Test POS Setting",
"currency": "INR",
"conversion_rate": 1.0,
- "price_list_name": "_Test Price List",
+ "selling_price_list": "_Test Price List",
"company": "_Test Company",
"warehouse": "_Test Warehouse - _TC",
"territory": "_Test Territory",
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.txt b/accounts/doctype/purchase_invoice/purchase_invoice.txt
index b5e23cc..f5bdd93 100755
--- a/accounts/doctype/purchase_invoice/purchase_invoice.txt
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
- "modified": "2013-08-08 14:21:58",
+ "modified": "2013-08-09 14:45:35",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -242,7 +242,7 @@
{
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
"doctype": "DocField",
- "fieldname": "price_list_name",
+ "fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
@@ -250,7 +250,7 @@
"read_only": 0
},
{
- "depends_on": "price_list_name",
+ "depends_on": "buying_price_list",
"doctype": "DocField",
"fieldname": "price_list_currency",
"fieldtype": "Link",
@@ -260,7 +260,7 @@
"read_only": 1
},
{
- "depends_on": "price_list_name",
+ "depends_on": "buying_price_list",
"doctype": "DocField",
"fieldname": "plc_conversion_rate",
"fieldtype": "Float",
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index 5a2ad4d..6979f1f 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -210,7 +210,7 @@
}, "master_name")
for fieldname in ('territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name',
- 'price_list_name', 'company', 'select_print_heading', 'cash_bank_account'):
+ 'selling_price_list', 'company', 'select_print_heading', 'cash_bank_account'):
if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)):
self.doc.fields[fieldname] = pos.get(fieldname)
diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt
index bd4d940..dbdf42f 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.txt
+++ b/accounts/doctype/sales_invoice/sales_invoice.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:05",
"docstatus": 0,
- "modified": "2013-08-08 14:22:01",
+ "modified": "2013-08-09 14:45:42",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -246,7 +246,7 @@
},
{
"doctype": "DocField",
- "fieldname": "price_list_name",
+ "fieldname": "selling_price_list",
"fieldtype": "Link",
"label": "Price List",
"oldfieldname": "price_list_name",
diff --git a/accounts/doctype/sales_invoice/test_sales_invoice.py b/accounts/doctype/sales_invoice/test_sales_invoice.py
index 95bbf67..05e4d92 100644
--- a/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -666,7 +666,7 @@
"plc_conversion_rate": 1.0,
"posting_date": "2013-01-23",
"price_list_currency": "INR",
- "price_list_name": "_Test Price List",
+ "selling_price_list": "_Test Price List",
"territory": "_Test Territory"
},
{
@@ -729,7 +729,7 @@
"plc_conversion_rate": 1.0,
"posting_date": "2013-03-07",
"price_list_currency": "INR",
- "price_list_name": "_Test Price List",
+ "selling_price_list": "_Test Price List",
"territory": "_Test Territory"
},
{
@@ -780,7 +780,7 @@
"plc_conversion_rate": 1.0,
"posting_date": "2013-01-23",
"price_list_currency": "INR",
- "price_list_name": "_Test Price List",
+ "selling_price_list": "_Test Price List",
"territory": "_Test Territory",
},
# items
@@ -905,7 +905,7 @@
"plc_conversion_rate": 1.0,
"posting_date": "2013-01-23",
"price_list_currency": "INR",
- "price_list_name": "_Test Price List",
+ "selling_price_list": "_Test Price List",
"territory": "_Test Territory",
},
# items
diff --git a/accounts/report/budget_variance_report/budget_variance_report.py b/accounts/report/budget_variance_report/budget_variance_report.py
index 158ff3a..015e2c0 100644
--- a/accounts/report/budget_variance_report/budget_variance_report.py
+++ b/accounts/report/budget_variance_report/budget_variance_report.py
@@ -47,18 +47,20 @@
msgprint(_("Please specify") + ": " + label,
raise_exception=True)
- columns = ["Cost Center:Link/Cost Center:100", "Account:Link/Account:100"]
+ columns = ["Cost Center:Link/Cost Center:120", "Account:Link/Account:120"]
group_months = False if filters["period"] == "Monthly" else True
for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]):
for label in ["Target (%s)", "Actual (%s)", "Variance (%s)"]:
if group_months:
- columns.append(label % (from_date.strftime("%b") + " - " + to_date.strftime("%b")))
+ label = label % (from_date.strftime("%b") + " - " + to_date.strftime("%b"))
else:
- columns.append(label % from_date.strftime("%b"))
+ label = label % from_date.strftime("%b")
+
+ columns.append(label+":Float:120")
- return columns + ["Total Target::80", "Total Actual::80", "Total Variance::80"]
+ return columns + ["Total Target::120", "Total Actual::120", "Total Variance::120"]
#Get cost center & target details
def get_costcenter_target_details(filters):
@@ -66,19 +68,17 @@
cc.parent_cost_center, bd.account, bd.budget_allocated
from `tabCost Center` cc, `tabBudget Detail` bd
where bd.parent=cc.name and bd.fiscal_year=%s and
- cc.company=%s and ifnull(cc.distribution_id, '')!=''
- order by cc.name""" % ('%s', '%s'),
+ cc.company=%s order by cc.name""" % ('%s', '%s'),
(filters.get("fiscal_year"), filters.get("company")), as_dict=1)
#Get target distribution details of accounts of cost center
def get_target_distribution_details(filters):
target_details = {}
- for d in webnotes.conn.sql("""select bdd.month, bdd.percentage_allocation \
- from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd, \
- `tabCost Center` cc where bdd.parent=bd.name and cc.distribution_id=bd.name and \
- bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
- target_details.setdefault(d.month, d)
+ for d in webnotes.conn.sql("""select bd.name, bdd.month, bdd.percentage_allocation \
+ from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
+ where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
+ target_details.setdefault(d.name, {}).setdefault(d.month, d.percentage_allocation)
return target_details
@@ -99,15 +99,19 @@
cam_map = {}
for ccd in costcenter_target_details:
- for month in tdd:
+ for month_id in range(1, 13):
+ month = datetime.date(2013, month_id, 1).strftime('%B')
+
cam_map.setdefault(ccd.name, {}).setdefault(ccd.account, {})\
- .setdefault(month, webnotes._dict({
- "target": 0.0, "actual": 0.0
- }))
+ .setdefault(month, webnotes._dict({
+ "target": 0.0, "actual": 0.0
+ }))
tav_dict = cam_map[ccd.name][ccd.account][month]
- tav_dict.target = flt(ccd.budget_allocated) * \
- (tdd[month]["percentage_allocation"]/100)
+ month_percentage = ccd.distribution_id and \
+ tdd.get(ccd.distribution_id, {}).get(month, 0) or 100.0/12
+
+ tav_dict.target = flt(flt(ccd.budget_allocated) * month_percentage /100)
for ad in actual_details:
if ad.month_name == month and ad.account == ccd.account \
diff --git a/buying/doctype/buying_settings/buying_settings.py b/buying/doctype/buying_settings/buying_settings.py
index 36d236f..3f4f96d 100644
--- a/buying/doctype/buying_settings/buying_settings.py
+++ b/buying/doctype/buying_settings/buying_settings.py
@@ -11,6 +11,6 @@
self.doc, self.doclist = d, dl
def validate(self):
- for key in ["supplier_type", "supp_master_name", "maintain_same_rate"]:
+ for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]:
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
\ No newline at end of file
diff --git a/buying/doctype/buying_settings/buying_settings.txt b/buying/doctype/buying_settings/buying_settings.txt
index eec7260..2b0c6ad 100644
--- a/buying/doctype/buying_settings/buying_settings.txt
+++ b/buying/doctype/buying_settings/buying_settings.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-06-25 11:04:03",
"docstatus": 0,
- "modified": "2013-07-05 14:29:41",
+ "modified": "2013-08-09 14:38:46",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -55,6 +55,13 @@
},
{
"doctype": "DocField",
+ "fieldname": "buying_price_list",
+ "fieldtype": "Link",
+ "label": "Default Buying Price List",
+ "options": "Price List"
+ },
+ {
+ "doctype": "DocField",
"fieldname": "column_break_3",
"fieldtype": "Column Break"
},
diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js
index 5a473a8..67ba33c 100644
--- a/buying/doctype/purchase_common/purchase_common.js
+++ b/buying/doctype/purchase_common/purchase_common.js
@@ -18,8 +18,8 @@
setup_queries: function() {
var me = this;
- if(this.frm.fields_dict.price_list_name) {
- this.frm.set_query("price_list_name", function() {
+ if(this.frm.fields_dict.buying_price_list) {
+ this.frm.set_query("buying_price_list", function() {
return{
filters: { 'buying_or_selling': "Buying" }
}
@@ -29,7 +29,7 @@
return{
query: "controllers.queries.get_price_list_currency",
filters: {
- 'price_list_name': me.frm.doc.price_list_name,
+ 'price_list': me.frm.doc.buying_price_list,
'buying_or_selling': "Buying"
}
}
@@ -77,7 +77,7 @@
msgprint(wn._("Please specify Company"));
} else {
var me = this;
- var price_list_name = this.frm.doc.price_list_name;
+ var buying_price_list = this.frm.doc.buying_price_list;
return this.frm.call({
doc: this.frm.doc,
@@ -85,7 +85,7 @@
freeze: true,
callback: function(r) {
if(!r.exc) {
- if(me.frm.doc.price_list_name !== price_list_name) me.price_list_name();
+ if(me.frm.doc.buying_price_list !== buying_price_list) me.buying_price_list();
}
}
});
@@ -132,7 +132,7 @@
docname: me.frm.doc.name,
supplier: me.frm.doc.supplier,
conversion_rate: me.frm.doc.conversion_rate,
- price_list_name: me.frm.doc.price_list_name,
+ buying_price_list: me.frm.doc.buying_price_list,
price_list_currency: me.frm.doc.price_list_currency,
plc_conversion_rate: me.frm.doc.plc_conversion_rate,
is_subcontracted: me.frm.doc.is_subcontracted,
@@ -151,8 +151,8 @@
}
},
- price_list_name: function() {
- this._super("buying");
+ buying_price_list: function() {
+ this.get_price_list_currency("buying");
},
import_ref_rate: function(doc, cdt, cdn) {
diff --git a/buying/doctype/purchase_order/purchase_order.txt b/buying/doctype/purchase_order/purchase_order.txt
index 8106f53..1134d95 100644
--- a/buying/doctype/purchase_order/purchase_order.txt
+++ b/buying/doctype/purchase_order/purchase_order.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
- "modified": "2013-08-08 14:22:03",
+ "modified": "2013-08-09 14:45:51",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -211,14 +211,14 @@
{
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
"doctype": "DocField",
- "fieldname": "price_list_name",
+ "fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
"print_hide": 1
},
{
- "depends_on": "price_list_name",
+ "depends_on": "buying_price_list",
"doctype": "DocField",
"fieldname": "price_list_currency",
"fieldtype": "Link",
@@ -228,7 +228,7 @@
"read_only": 1
},
{
- "depends_on": "price_list_name",
+ "depends_on": "buying_price_list",
"doctype": "DocField",
"fieldname": "plc_conversion_rate",
"fieldtype": "Float",
diff --git a/buying/doctype/supplier_quotation/supplier_quotation.py b/buying/doctype/supplier_quotation/supplier_quotation.py
index 8ba0045..c3d2f78 100644
--- a/buying/doctype/supplier_quotation/supplier_quotation.py
+++ b/buying/doctype/supplier_quotation/supplier_quotation.py
@@ -10,7 +10,7 @@
def __init__(self, doc, doclist=None):
self.doc, self.doclist = doc, doclist or []
self.tname, self.fname = "Supplier Quotation Item", "quotation_items"
-
+
def validate(self):
super(DocType, self).validate()
diff --git a/buying/doctype/supplier_quotation/supplier_quotation.txt b/buying/doctype/supplier_quotation/supplier_quotation.txt
index b474f7c..36747d3 100644
--- a/buying/doctype/supplier_quotation/supplier_quotation.txt
+++ b/buying/doctype/supplier_quotation/supplier_quotation.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-21 16:16:45",
"docstatus": 0,
- "modified": "2013-08-08 14:22:08",
+ "modified": "2013-08-09 14:45:58",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -208,14 +208,14 @@
{
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
"doctype": "DocField",
- "fieldname": "price_list_name",
+ "fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
"print_hide": 1
},
{
- "depends_on": "price_list_name",
+ "depends_on": "buying_price_list",
"doctype": "DocField",
"fieldname": "price_list_currency",
"fieldtype": "Link",
@@ -225,7 +225,7 @@
"read_only": 1
},
{
- "depends_on": "price_list_name",
+ "depends_on": "buying_price_list",
"doctype": "DocField",
"fieldname": "plc_conversion_rate",
"fieldtype": "Float",
diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js
index 4a3e044..939ff79 100644
--- a/buying/page/buying_home/buying_home.js
+++ b/buying/page/buying_home/buying_home.js
@@ -111,9 +111,14 @@
icon: "icon-list",
items: [
{
- "label":wn._("Item-wise Purchase History"),
- route: "query-report/Item-wise Purchase History",
- doctype: "Item"
+ "label":wn._("Requested Items To Be Ordered"),
+ route: "query-report/Requested Items To Be Ordered",
+ doctype: "Material Request"
+ },
+ {
+ "label":wn._("Material Requests for which Supplier Quotations are not created"),
+ route: "query-report/Material Requests for which Supplier Quotations are not created",
+ doctype: "Material Request"
},
{
"label":wn._("Purchase In Transit"),
@@ -121,20 +126,20 @@
doctype: "Purchase Order"
},
{
- "label":wn._("Requested Items To Be Ordered"),
- route: "query-report/Requested Items To Be Ordered",
- doctype: "Material Request"
+ "label":wn._("Item-wise Purchase History"),
+ route: "query-report/Item-wise Purchase History",
+ doctype: "Item"
+ },
+ {
+ "label":wn._("Item-wise Last Purchase Rate"),
+ route: "query-report/Item-wise Last Purchase Rate",
+ doctype: "Item"
},
{
"label":wn._("Purchase Order Trends"),
route: "query-report/Purchase Order Trends",
doctype: "Purchase Order"
},
- {
- "label":wn._("Item-wise Last Purchase Rate"),
- route: "query-report/Item-wise Last Purchase Rate",
- doctype: "Item"
- }
]
}
]
diff --git a/buying/utils.py b/buying/utils.py
index 29beb29..33326d9 100644
--- a/buying/utils.py
+++ b/buying/utils.py
@@ -18,7 +18,7 @@
"supplier": None,
"transaction_date": None,
"conversion_rate": 1.0,
- "price_list_name": None,
+ "buying_price_list": None,
"price_list_currency": None,
"plc_conversion_rate": 1.0,
"is_subcontracted": "Yes" / "No"
@@ -88,10 +88,10 @@
out = webnotes._dict()
# try fetching from price list
- if args.price_list_name and args.price_list_currency:
+ if args.buying_price_list and args.price_list_currency:
price_list_rate = item_bean.doclist.get({
"parentfield": "ref_rate_details",
- "price_list_name": args.price_list_name,
+ "price_list": args.buying_price_list,
"ref_currency": args.price_list_currency,
"buying_or_selling": "Buying"})
if price_list_rate:
diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py
index 3676510..d6bf392 100644
--- a/controllers/accounts_controller.py
+++ b/controllers/accounts_controller.py
@@ -55,10 +55,11 @@
def set_price_list_currency(self, buying_or_selling):
company_currency = get_company_currency(self.doc.company)
+ fieldname = buying_or_selling.lower() + "_price_list"
# TODO - change this, since price list now has only one currency allowed
- if self.meta.get_field("price_list_name") and self.doc.price_list_name and \
+ if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname) and \
not self.doc.price_list_currency:
- self.doc.fields.update(get_price_list_currency(self.doc.price_list_name))
+ self.doc.fields.update(get_price_list_currency(self.doc.fields.get(fieldname)))
if self.doc.price_list_currency:
if not self.doc.plc_conversion_rate:
@@ -73,11 +74,14 @@
self.doc.currency = self.doc.price_list_currency
self.doc.conversion_rate = self.doc.plc_conversion_rate
- if self.meta.get_field("currency") and self.doc.currency != company_currency and \
- not self.doc.conversion_rate:
- exchange = self.doc.currency + "-" + company_currency
- self.doc.conversion_rate = flt(webnotes.conn.get_value("Currency Exchange",
- exchange, "exchange_rate"))
+ if self.meta.get_field("currency"):
+ if self.doc.currency != company_currency:
+ if not self.doc.conversion_rate:
+ exchange = self.doc.currency + "-" + company_currency
+ self.doc.conversion_rate = flt(webnotes.conn.get_value("Currency Exchange",
+ exchange, "exchange_rate"))
+ else:
+ self.doc.conversion_rate = 1
def set_missing_item_details(self, get_item_details):
"""set missing item values"""
@@ -261,7 +265,7 @@
tax.grand_total_for_current_item = \
flt(self.tax_doclist[i-1].grand_total_for_current_item +
current_tax_amount, self.precision("total", tax))
-
+
# in tax.total, accumulate grand total of each item
tax.total += tax.grand_total_for_current_item
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index 4006b37..63070a5 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -30,6 +30,7 @@
def set_missing_values(self, for_validate=False):
super(BuyingController, self).set_missing_values(for_validate)
+ self.set_supplier_from_item_default()
self.set_price_list_currency("Buying")
# set contact and address details for supplier, if they are not mentioned
@@ -40,6 +41,14 @@
self.set_missing_item_details(get_item_details)
+ def set_supplier_from_item_default(self):
+ if self.meta.get_field("supplier") and not self.doc.supplier:
+ for d in self.doclist.get({"doctype": self.tname}):
+ supplier = webnotes.conn.get_value("Item", d.item_code, "default_supplier")
+ if supplier:
+ self.doc.supplier = supplier
+ break
+
def get_purchase_tax_details(self):
self.doclist = self.doc.clear_table(self.doclist, "purchase_tax_details")
self.set_taxes("purchase_tax_details", "purchase_other_charges")
diff --git a/controllers/queries.py b/controllers/queries.py
index df7b7c5..381d2c8 100644
--- a/controllers/queries.py
+++ b/controllers/queries.py
@@ -187,10 +187,10 @@
def get_price_list_currency(doctype, txt, searchfield, start, page_len, filters):
return webnotes.conn.sql("""select ref_currency from `tabItem Price`
- where price_list_name = %s and buying_or_selling = %s
+ where price_list = %s and buying_or_selling = %s
and `%s` like %s order by ref_currency asc limit %s, %s""" %
("%s", "%s", searchfield, "%s", "%s", "%s"),
- (filters["price_list_name"], filters['buying_or_selling'], "%%%s%%" % txt,
+ (filters["price_list"], filters['buying_or_selling'], "%%%s%%" % txt,
start, page_len))
def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters):
diff --git a/docs/docs.dev.api.md b/docs/docs.dev.api.md
index 4a61183..0f694b5 100644
--- a/docs/docs.dev.api.md
+++ b/docs/docs.dev.api.md
@@ -122,7 +122,7 @@
"plc_conversion_rate": 1.0,
"posting_date": "2013-01-23",
"price_list_currency": "INR",
- "price_list_name": "_Test Price List",
+ "selling_price_list": "_Test Price List",
"territory": "_Test Territory"
},
diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py
index 14c8b1f..8a2df1e 100755
--- a/hr/doctype/leave_application/leave_application.py
+++ b/hr/doctype/leave_application/leave_application.py
@@ -115,7 +115,8 @@
self.doc.leave_balance = get_leave_balance(self.doc.employee,
self.doc.leave_type, self.doc.fiscal_year)["leave_balance"]
- if self.doc.leave_balance - self.doc.total_leave_days < 0:
+ if self.doc.status != "Rejected" \
+ and self.doc.leave_balance - self.doc.total_leave_days < 0:
#check if this leave type allow the remaining balance to be in negative. If yes then warn the user and continue to save else warn the user and don't save.
msgprint("There is not enough leave balance for Leave Type: %s" % \
(self.doc.leave_type,),
diff --git a/install_erpnext.py b/install_erpnext.py
index 341d4c5..1a802ae 100644
--- a/install_erpnext.py
+++ b/install_erpnext.py
@@ -309,6 +309,8 @@
print
print "-"*80
+ print "To change url domain, run: lib/wnf.py --domain example.com"
+ print "-"*80
print "Installation complete"
print "Open your browser and go to http://localhost:8080"
print "Login using username = Administrator and password = admin"
diff --git a/manufacturing/doctype/bom/bom.py b/manufacturing/doctype/bom/bom.py
index 3780ae8..cb4b8c5 100644
--- a/manufacturing/doctype/bom/bom.py
+++ b/manufacturing/doctype/bom/bom.py
@@ -119,9 +119,9 @@
elif self.doc.rm_cost_as_per == 'Last Purchase Rate':
rate = arg['last_purchase_rate']
elif self.doc.rm_cost_as_per == "Price List":
- if not self.doc.price_list:
+ if not self.doc.buying_price_list:
webnotes.throw(_("Please select Price List"))
- rate = webnotes.conn.get_value("Item Price", {"price_list_name": self.doc.price_list,
+ rate = webnotes.conn.get_value("Item Price", {"price_list": self.doc.buying_price_list,
"parent": arg["item_code"]}, "ref_rate") or 0
elif self.doc.rm_cost_as_per == 'Standard Rate':
rate = arg['standard_rate']
@@ -255,7 +255,7 @@
(bom_no, item), as_dict =1)
if not bom:
msgprint("""Incorrect BOM No: %s against item: %s at row no: %s.
- It may be inactive or cancelled or for some other item.""" %
+ It may be inactive or not submitted or does not belong to this item.""" %
(bom_no, item, idx), raise_exception = 1)
def check_if_item_repeated(self, item, op, check_list):
diff --git a/manufacturing/doctype/bom/bom.txt b/manufacturing/doctype/bom/bom.txt
index 1793e6b..425e9ac 100644
--- a/manufacturing/doctype/bom/bom.txt
+++ b/manufacturing/doctype/bom/bom.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-22 15:11:38",
"docstatus": 0,
- "modified": "2013-08-07 17:09:46",
+ "modified": "2013-08-09 14:47:25",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -115,7 +115,7 @@
"depends_on": "eval:doc.rm_cost_as_per===\"Price List\"",
"description": "Price List for Costing",
"doctype": "DocField",
- "fieldname": "price_list",
+ "fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List"
diff --git a/manufacturing/doctype/production_order/production_order.js b/manufacturing/doctype/production_order/production_order.js
index 012c279..f680776 100644
--- a/manufacturing/doctype/production_order/production_order.js
+++ b/manufacturing/doctype/production_order/production_order.js
@@ -61,30 +61,25 @@
}
cur_frm.cscript['Transfer Raw Materials'] = function() {
- var doc = cur_frm.doc;
- cur_frm.cscript.make_se(doc, 'Material Transfer');
+ cur_frm.cscript.make_se('Material Transfer');
}
cur_frm.cscript['Update Finished Goods'] = function() {
- var doc = cur_frm.doc;
- cur_frm.cscript.make_se(doc, 'Manufacture/Repack');
+ cur_frm.cscript.make_se('Manufacture/Repack');
}
-cur_frm.cscript.make_se = function(doc, purpose) {
- var se = wn.model.get_new_doc("Stock Entry");
- se.purpose = purpose;
- se.production_order = doc.name;
- if(purpose==="Material Transfer") {
- se.to_warehouse = doc.wip_warehouse;
- } else {
- se.from_warehouse = doc.wip_warehouse;
- se.to_warehouse = doc.fg_warehouse;
- }
- se.company = doc.company;
- se.fg_completed_qty = doc.qty - doc.produced_qty;
- se.bom_no = doc.bom_no;
- se.use_multi_level_bom = doc.use_multi_level_bom;
- loaddoc('Stock Entry', se.name);
+cur_frm.cscript.make_se = function(purpose) {
+ wn.call({
+ method:"manufacturing.doctype.production_order.production_order.make_stock_entry",
+ args: {
+ "production_order_id": cur_frm.doc.name,
+ "purpose": purpose
+ },
+ callback: function(r) {
+ var doclist = wn.model.sync(r.message);
+ wn.set_route("Form", doclist[0].doctype, doclist[0].name);
+ }
+ })
}
cur_frm.fields_dict['production_item'].get_query = function(doc) {
diff --git a/manufacturing/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py
index 2f31180..90a74e9 100644
--- a/manufacturing/doctype/production_order/production_order.py
+++ b/manufacturing/doctype/production_order/production_order.py
@@ -137,4 +137,23 @@
if bom:
res.bom_no = bom[0][0]
- return res
\ No newline at end of file
+ return res
+
+@webnotes.whitelist()
+def make_stock_entry(production_order_id, purpose):
+ production_order = webnotes.bean("Production Order", production_order_id)
+
+ stock_entry = webnotes.new_bean("Stock Entry")
+ stock_entry.doc.purpose = purpose
+ stock_entry.doc.production_order = production_order_id
+ stock_entry.doc.company = production_order.doc.company
+ stock_entry.doc.bom_no = production_order.doc.bom_no
+ stock_entry.doc.fg_completed_qty = flt(production_order.doc.qty) - flt(production_order.doc.produced_qty)
+
+ if purpose=="Material Transfer":
+ stock_entry.doc.to_warehouse = production_order.doc.wip_warehouse
+ else:
+ stock_entry.doc.from_warehouse = production_order.doc.wip_warehouse
+ stock_entry.doc.to_warehouse = production_order.doc.fg_warehouse
+
+ return [d.fields for d in stock_entry.doclist]
diff --git a/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/manufacturing/doctype/production_planning_tool/production_planning_tool.py
index ad3eff1..766f2ac 100644
--- a/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -105,7 +105,8 @@
def get_items(self):
so_list = filter(None, [d.sales_order for d in getlist(self.doclist, 'pp_so_details')])
if not so_list:
- msgprint("Please enter sales order in the above table", raise_exception=1)
+ msgprint("Please enter sales order in the above table")
+ return []
items = sql("""select distinct parent, item_code, reserved_warehouse,
(qty - ifnull(delivered_qty, 0)) as pending_qty
@@ -294,8 +295,12 @@
webnotes.msgprint("Please enter Warehouse for which Material Request will be raised",
raise_exception=1)
- bom_dict = self.get_distinct_items_and_boms()[0]
+ bom_dict = self.get_distinct_items_and_boms()[0]
self.get_raw_materials(bom_dict)
+
+ if not self.item_dict:
+ return
+
item_projected_qty = self.get_projected_qty()
from accounts.utils import get_fiscal_year
@@ -315,7 +320,6 @@
def get_projected_qty(self):
items = self.item_dict.keys()
-
item_projected_qty = webnotes.conn.sql("""select item_code, sum(projected_qty)
from `tabBin` where item_code in (%s) group by item_code""" %
(", ".join(["%s"]*len(items)),), tuple(items))
diff --git a/manufacturing/page/manufacturing_home/manufacturing_home.js b/manufacturing/page/manufacturing_home/manufacturing_home.js
index b29bbbb..a2a4eaa 100644
--- a/manufacturing/page/manufacturing_home/manufacturing_home.js
+++ b/manufacturing/page/manufacturing_home/manufacturing_home.js
@@ -65,10 +65,25 @@
icon: "icon-list",
items: [
{
+ "label":wn._("Open Production Orders"),
+ route: "query-report/Open Production Orders",
+ doctype:"Production Order"
+ },
+ {
+ "label":wn._("Production Orders in Progress"),
+ route: "query-report/Production Orders in Progress",
+ doctype:"Production Order"
+ },
+ {
"label":wn._("Issued Items Against Production Order"),
route: "query-report/Issued Items Against Production Order",
doctype:"Production Order"
},
+ {
+ "label":wn._("Completed Production Orders"),
+ route: "query-report/Completed Production Orders",
+ doctype:"Production Order"
+ },
]
}
]
diff --git a/manufacturing/report/completed_production_orders/__init__.py b/manufacturing/report/completed_production_orders/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/manufacturing/report/completed_production_orders/__init__.py
diff --git a/manufacturing/report/completed_production_orders/completed_production_orders.txt b/manufacturing/report/completed_production_orders/completed_production_orders.txt
new file mode 100644
index 0000000..facda7e
--- /dev/null
+++ b/manufacturing/report/completed_production_orders/completed_production_orders.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-08-12 12:44:27",
+ "docstatus": 0,
+ "modified": "2013-08-12 12:44:27",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "query": "SELECT\n `tabProduction Order`.name as \"Production Order:Link/Production Order:200\",\n `tabProduction Order`.creation as \"Date:Date:120\",\n `tabProduction Order`.production_item as \"Item:Link/Item:150\",\n `tabProduction Order`.qty as \"To Produce:Int:100\",\n `tabProduction Order`.produced_qty as \"Produced:Int:100\"\nFROM\n `tabProduction Order`\nWHERE\n `tabProduction Order`.docstatus=1\n AND ifnull(`tabProduction Order`.produced_qty,0) = `tabProduction Order`.qty",
+ "ref_doctype": "Production Order",
+ "report_name": "Completed Production Orders",
+ "report_type": "Query Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Completed Production Orders"
+ }
+]
\ No newline at end of file
diff --git a/manufacturing/report/open_production_orders/__init__.py b/manufacturing/report/open_production_orders/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/manufacturing/report/open_production_orders/__init__.py
diff --git a/manufacturing/report/open_production_orders/open_production_orders.txt b/manufacturing/report/open_production_orders/open_production_orders.txt
new file mode 100644
index 0000000..f92bdd3
--- /dev/null
+++ b/manufacturing/report/open_production_orders/open_production_orders.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-08-12 12:32:30",
+ "docstatus": 0,
+ "modified": "2013-08-12 12:42:29",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "query": "SELECT\n `tabProduction Order`.name as \"Production Order:Link/Production Order:200\",\n `tabProduction Order`.creation as \"Date:Date:120\",\n `tabProduction Order`.production_item as \"Item:Link/Item:150\",\n `tabProduction Order`.qty as \"To Produce:Int:100\",\n `tabProduction Order`.produced_qty as \"Produced:Int:100\"\nFROM\n `tabProduction Order`\nWHERE\n `tabProduction Order`.docstatus=1\n AND ifnull(`tabProduction Order`.produced_qty,0) < `tabProduction Order`.qty\n AND NOT EXISTS (SELECT name from `tabStock Entry` where production_order =`tabProduction Order`.name) ",
+ "ref_doctype": "Production Order",
+ "report_name": "Open Production Orders",
+ "report_type": "Query Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Open Production Orders"
+ }
+]
\ No newline at end of file
diff --git a/manufacturing/report/production_orders_in_progress/__init__.py b/manufacturing/report/production_orders_in_progress/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/manufacturing/report/production_orders_in_progress/__init__.py
diff --git a/manufacturing/report/production_orders_in_progress/production_orders_in_progress.txt b/manufacturing/report/production_orders_in_progress/production_orders_in_progress.txt
new file mode 100644
index 0000000..3d3493f
--- /dev/null
+++ b/manufacturing/report/production_orders_in_progress/production_orders_in_progress.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-08-12 12:43:47",
+ "docstatus": 0,
+ "modified": "2013-08-12 12:43:47",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "query": "SELECT\n `tabProduction Order`.name as \"Production Order:Link/Production Order:200\",\n `tabProduction Order`.creation as \"Date:Date:120\",\n `tabProduction Order`.production_item as \"Item:Link/Item:150\",\n `tabProduction Order`.qty as \"To Produce:Int:100\",\n `tabProduction Order`.produced_qty as \"Produced:Int:100\"\nFROM\n `tabProduction Order`\nWHERE\n `tabProduction Order`.docstatus=1\n AND ifnull(`tabProduction Order`.produced_qty,0) < `tabProduction Order`.qty\n AND EXISTS (SELECT name from `tabStock Entry` where production_order =`tabProduction Order`.name) ",
+ "ref_doctype": "Production Order",
+ "report_name": "Production Orders in Progress",
+ "report_type": "Query Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Production Orders in Progress"
+ }
+]
\ No newline at end of file
diff --git a/patches/august_2013/p02_pos_setting_replace_customer account_with_customer.py b/patches/august_2013/p02_pos_setting_replace_customer account_with_customer.py
deleted file mode 100644
index 4076f58..0000000
--- a/patches/august_2013/p02_pos_setting_replace_customer account_with_customer.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import webnotes
-
-def execute():
- webnotes.reload_doc("accounts", "doctype", "pos_setting")
- customer_account = webnotes.conn.sql("""select customer_account, name from `tabPOS Setting`
- where ifnull(customer_account, '')!=''""")
-
- for cust_acc, pos_name in customer_account:
- customer = webnotes.conn.sql("""select master_name, account_name from `tabAccount`
- where name=%s""", (cust_acc), as_dict=1)
-
- if not customer[0].master_name:
- customer_name = webnotes.conn.get_value('Customer', customer[0].account_name, 'name')
- else:
- customer_name = customer[0].master_name
-
- webnotes.conn.set_value('POS Setting', pos_name, 'customer', customer_name)
\ No newline at end of file
diff --git a/patches/august_2013/p02_rename_price_list.py b/patches/august_2013/p02_rename_price_list.py
new file mode 100644
index 0000000..cea7c79
--- /dev/null
+++ b/patches/august_2013/p02_rename_price_list.py
@@ -0,0 +1,34 @@
+import webnotes
+
+def execute():
+ for t in [
+ ("Supplier Quotation", "price_list_name", "buying_price_list"),
+ ("Purchase Order", "price_list_name", "buying_price_list"),
+ ("Purchase Invoice", "price_list_name", "buying_price_list"),
+ ("Purchase Receipt", "price_list_name", "buying_price_list"),
+ ("Quotation", "price_list_name", "selling_price_list"),
+ ("Sales Order", "price_list_name", "selling_price_list"),
+ ("Delivery Note", "price_list_name", "selling_price_list"),
+ ("Sales Invoice", "price_list_name", "selling_price_list"),
+ ("POS Setting", "price_list_name", "selling_price_list"),
+ ("Shopping Cart Price List", "price_list", "selling_price_list"),
+ ("Item Price", "price_list_name", "price_list"),
+ ("BOM", "price_list", "buying_price_list"),
+ ]:
+ table_columns = webnotes.conn.get_table_columns(t[0])
+ if t[2] in table_columns and t[1] in table_columns:
+ # already reloaded, so copy into new column and drop old column
+ webnotes.conn.sql("""update `tab%s` set `%s`=`%s`""" % (t[0], t[2], t[1]))
+ webnotes.conn.sql("""alter table `tab%s` drop column `%s`""" % (t[0], t[1]))
+ elif t[1] in table_columns:
+ webnotes.conn.sql_ddl("alter table `tab%s` change `%s` `%s` varchar(180)" % t)
+
+ webnotes.reload_doc(webnotes.conn.get_value("DocType", t[0], "module"), "DocType", t[0])
+
+ webnotes.conn.sql("""update tabSingles set field='selling_price_list'
+ where field='price_list_name' and doctype='Selling Settings'""")
+
+ webnotes.reload_doc("Selling", "DocType", "Selling Settings")
+ webnotes.bean("Selling Settings").save()
+
+
diff --git a/patches/august_2013/p03_pos_setting_replace_customer_account.py b/patches/august_2013/p03_pos_setting_replace_customer_account.py
new file mode 100644
index 0000000..c3a21e4
--- /dev/null
+++ b/patches/august_2013/p03_pos_setting_replace_customer_account.py
@@ -0,0 +1,24 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+def execute():
+ webnotes.reload_doc("accounts", "doctype", "pos_setting")
+ if "customer_account" in webnotes.conn.get_table_columns("POS Setting"):
+ customer_account = webnotes.conn.sql("""select customer_account, name from `tabPOS Setting`
+ where ifnull(customer_account, '')!=''""")
+
+ for cust_acc, pos_name in customer_account:
+ customer = webnotes.conn.sql("""select master_name, account_name from `tabAccount`
+ where name=%s""", (cust_acc), as_dict=1)
+
+ if not customer[0].master_name:
+ customer_name = webnotes.conn.get_value('Customer', customer[0].account_name, 'name')
+ else:
+ customer_name = customer[0].master_name
+
+ webnotes.conn.set_value('POS Setting', pos_name, 'customer', customer_name)
+
+ webnotes.conn.sql_ddl("""alter table `tabPOS Setting` drop column `customer_account`""")
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 56bd57a..bd6b9a3 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -252,5 +252,6 @@
"patches.july_2013.p11_update_price_list_currency",
"execute:webnotes.bean('Selling Settings').save() #2013-07-29",
"patches.august_2013.p01_hr_settings",
- "patches.august_2013.p02_pos_setting_replace_customer account_with_customer",
+ "patches.august_2013.p02_rename_price_list",
+ "patches.august_2013.p03_pos_setting_replace_customer_account",
]
\ No newline at end of file
diff --git a/public/js/account_tree_grid.js b/public/js/account_tree_grid.js
index 02ea389..c779cfa 100644
--- a/public/js/account_tree_grid.js
+++ b/public/js/account_tree_grid.js
@@ -138,7 +138,7 @@
$.each(gl, function(i, v) {
var posting_date = dateutil.str_to_obj(v.posting_date);
var account = me.item_by_name[v.account];
- me.update_balances(account, posting_date, v)
+ me.update_balances(account, posting_date, v);
});
this.update_groups();
diff --git a/public/js/startup.css b/public/js/startup.css
index d15b7a4..ab70ee4 100644
--- a/public/js/startup.css
+++ b/public/js/startup.css
@@ -19,15 +19,6 @@
text-align: center;
}
-.expiry-info {
- margin-top: -20px;
- margin-bottom: 20px;
- text-align: center;
- background-color: rgb(255, 255, 204);
- padding: 7px;
- z-index: 1;
-}
-
.show-all-reports {
margin-top: 5px;
font-size: 11px;
diff --git a/public/js/startup.js b/public/js/startup.js
index 6654ca7..eee8a05 100644
--- a/public/js/startup.js
+++ b/public/js/startup.js
@@ -26,26 +26,30 @@
"</p>", wn._("Welcome"));
}
} else if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) {
- var today = dateutil.str_to_obj(wn.boot.server_date);
- var expires_on = dateutil.str_to_obj(wn.boot.expires_on);
- var diff = dateutil.get_diff(expires_on, today);
- var payment_link = "<a href=\"https://erpnext.com/modes-of-payment.html\" target=\"_blank\">See Payment Options.</a>";
- if (0 <= diff && diff <= 15) {
- var expiry_string = diff==0 ? "today" : repl("in %(diff)s day(s)", { diff: diff });
- $('header').append(repl('<div class="expiry-info"> \
- Your ERPNext subscription will <b>expire %(expiry_string)s</b>. \
- Please renew your subscription to continue using ERPNext \
- (and remove this annoying banner). %(payment_link)s\
- </div>', { expiry_string: expiry_string, payment_link: payment_link }));
- } else if (diff < 0) {
- $('header').append(repl('<div class="expiry-info"> \
- This ERPNext subscription <b>has expired</b>. %(payment_link)s\
- </div>', { expiry_string: expiry_string, payment_link: payment_link }));
- }
+ erpnext.startup.show_expiry_banner();
}
}
}
+erpnext.startup.show_expiry_banner = function() {
+ var today = dateutil.str_to_obj(wn.boot.server_date);
+ var expires_on = dateutil.str_to_obj(wn.boot.expires_on);
+ var diff = dateutil.get_diff(expires_on, today);
+ var payment_link = "<a href=\"https://erpnext.com/modes-of-payment.html\" target=\"_blank\">\
+ Click here to buy subscription.</a>";
+
+ var msg = "";
+ if (0 <= diff && diff <= 10) {
+ var expiry_string = diff==0 ? "today" : repl("in %(diff)s day(s)", { diff: diff });
+ msg = repl('Your ERPNext subscription will <b>expire %(expiry_string)s</b>. %(payment_link)s',
+ { expiry_string: expiry_string, payment_link: payment_link });
+ } else if (diff < 0) {
+ msg = repl('This ERPNext subscription <b>has expired</b>. %(payment_link)s', {payment_link: payment_link});
+ }
+
+ if(msg) wn.ui.toolbar.show_banner(msg);
+}
+
// start
$(document).bind('startup', function() {
erpnext.startup.start();
diff --git a/public/js/stock_analytics.js b/public/js/stock_analytics.js
index a349b6e..5b58113 100644
--- a/public/js/stock_analytics.js
+++ b/public/js/stock_analytics.js
@@ -149,8 +149,6 @@
} else {
break;
}
-
- me.round_item_values(item);
}
}
},
diff --git a/public/js/transaction.js b/public/js/transaction.js
index c4601dd..118594c 100644
--- a/public/js/transaction.js
+++ b/public/js/transaction.js
@@ -114,13 +114,14 @@
this.calculate_taxes_and_totals();
},
- price_list_name: function(buying_or_selling) {
+ get_price_list_currency: function(buying_or_selling) {
var me = this;
- if(this.frm.doc.price_list_name) {
+ var fieldname = buying_or_selling.toLowerCase() + "_price_list";
+ if(this.frm.doc[fieldname]) {
return this.frm.call({
method: "setup.utils.get_price_list_currency",
args: {
- price_list_name: this.frm.doc.price_list_name,
+ price_list: this.frm.doc[fieldname],
},
callback: function(r) {
if(!r.exc) {
@@ -311,7 +312,8 @@
if(!item_tax[item_code]) item_tax[item_code] = {};
if($.isArray(tax_data)) {
var tax_rate = tax_data[0] == null ? "" : (flt(tax_data[0], tax_rate_precision) + "%"),
- tax_amount = format_currency(flt(tax_data[1], tax_amount_precision), company_currency);
+ tax_amount = format_currency(flt(tax_data[1], tax_amount_precision), company_currency,
+ tax_amount_precision);
item_tax[item_code][tax.name] = [tax_rate, tax_amount];
} else {
diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt
index f276a16..c3b2434 100644
--- a/selling/doctype/quotation/quotation.txt
+++ b/selling/doctype/quotation/quotation.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:08",
"docstatus": 0,
- "modified": "2013-08-08 14:22:16",
+ "modified": "2013-08-09 14:46:11",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -280,7 +280,7 @@
{
"description": "Select the price list as entered in \"Price List\" master. This will pull the reference rates of items against this price list as specified in \"Item\" master.",
"doctype": "DocField",
- "fieldname": "price_list_name",
+ "fieldname": "selling_price_list",
"fieldtype": "Link",
"in_filter": 1,
"label": "Price List",
diff --git a/selling/doctype/quotation/test_quotation.py b/selling/doctype/quotation/test_quotation.py
index 41d50e7..cf3881d 100644
--- a/selling/doctype/quotation/test_quotation.py
+++ b/selling/doctype/quotation/test_quotation.py
@@ -44,7 +44,7 @@
"order_type": "Sales",
"plc_conversion_rate": 1.0,
"price_list_currency": "INR",
- "price_list_name": "_Test Price List",
+ "selling_price_list": "_Test Price List",
"territory": "_Test Territory",
"transaction_date": "2013-02-21",
"grand_total": 1000.0,
diff --git a/selling/doctype/sales_bom/sales_bom.py b/selling/doctype/sales_bom/sales_bom.py
index a6b123a..8bcac17 100644
--- a/selling/doctype/sales_bom/sales_bom.py
+++ b/selling/doctype/sales_bom/sales_bom.py
@@ -32,7 +32,7 @@
det = webnotes.conn.sql("""select description, stock_uom from `tabItem`
where name = %s""", name)
rate = webnotes.conn.sql("""select ref_rate from `tabItem Price`
- where price_list_name = %s and parent = %s
+ where price_list = %s and parent = %s
and ref_currency = %s""", (self.doc.price_list, name, self.doc.currency))
return {
'description' : det and det[0][0] or '',
diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js
index 80b1d95..fe90b5b 100644
--- a/selling/doctype/sales_common/sales_common.js
+++ b/selling/doctype/sales_common/sales_common.js
@@ -45,8 +45,8 @@
});
}
- if(this.frm.fields_dict.price_list_name) {
- this.frm.set_query("price_list_name", function() {
+ if(this.frm.fields_dict.selling_price_list) {
+ this.frm.set_query("selling_price_list", function() {
return { filters: { buying_or_selling: "Selling" } };
});
@@ -54,7 +54,7 @@
return {
query: "controllers.queries.get_price_list_currency",
filters: {
- price_list_name: me.frm.doc.price_list_name,
+ price_list: me.frm.doc.selling_price_list,
buying_or_selling: "Selling"
}
};
@@ -126,15 +126,15 @@
this.frm.set_value("customer", null);
msgprint(wn._("Please specify Company"));
} else {
- var price_list_name = this.frm.doc.price_list_name;
+ var selling_price_list = this.frm.doc.selling_price_list;
return this.frm.call({
doc: this.frm.doc,
method: "set_customer_defaults",
freeze: true,
callback: function(r) {
if(!r.exc) {
- (me.frm.doc.price_list_name !== price_list_name) ?
- me.price_list_name() :
+ (me.frm.doc.selling_price_list !== selling_price_list) ?
+ me.selling_price_list() :
me.price_list_currency();
}
}
@@ -188,7 +188,7 @@
customer: me.frm.doc.customer,
currency: me.frm.doc.currency,
conversion_rate: me.frm.doc.conversion_rate,
- price_list_name: me.frm.doc.price_list_name,
+ selling_price_list: me.frm.doc.selling_price_list,
price_list_currency: me.frm.doc.price_list_currency,
plc_conversion_rate: me.frm.doc.plc_conversion_rate,
company: me.frm.doc.company,
@@ -206,8 +206,8 @@
}
},
- price_list_name: function() {
- this._super("Selling");
+ selling_price_list: function() {
+ this.get_price_list_currency("Selling");
},
ref_rate: function(doc, cdt, cdn) {
diff --git a/selling/doctype/sales_order/sales_order.txt b/selling/doctype/sales_order/sales_order.txt
index 75a4aff..94e6388 100644
--- a/selling/doctype/sales_order/sales_order.txt
+++ b/selling/doctype/sales_order/sales_order.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-06-18 12:39:59",
"docstatus": 0,
- "modified": "2013-08-08 14:22:17",
+ "modified": "2013-08-09 14:46:17",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -293,7 +293,7 @@
{
"description": "Select the price list as entered in \"Price List\" master. This will pull the reference rates of items against this price list as specified in \"Item\" master.",
"doctype": "DocField",
- "fieldname": "price_list_name",
+ "fieldname": "selling_price_list",
"fieldtype": "Link",
"label": "Price List",
"oldfieldname": "price_list_name",
diff --git a/selling/doctype/sales_order/test_sales_order.py b/selling/doctype/sales_order/test_sales_order.py
index aa632a3..9fd16e8 100644
--- a/selling/doctype/sales_order/test_sales_order.py
+++ b/selling/doctype/sales_order/test_sales_order.py
@@ -289,7 +289,7 @@
"delivery_date": "2013-02-23",
"plc_conversion_rate": 1.0,
"price_list_currency": "INR",
- "price_list_name": "_Test Price List",
+ "selling_price_list": "_Test Price List",
"territory": "_Test Territory",
"transaction_date": "2013-02-21",
"grand_total": 1000.0,
diff --git a/selling/doctype/selling_settings/selling_settings.py b/selling/doctype/selling_settings/selling_settings.py
index 225c221..9386652 100644
--- a/selling/doctype/selling_settings/selling_settings.py
+++ b/selling/doctype/selling_settings/selling_settings.py
@@ -12,5 +12,5 @@
def validate(self):
for key in ["cust_master_name", "customer_group", "territory", "maintain_same_sales_rate",
- "editable_price_list_rate"]:
+ "editable_price_list_rate", "selling_price_list"]:
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
diff --git a/selling/doctype/selling_settings/selling_settings.txt b/selling/doctype/selling_settings/selling_settings.txt
index 97a339a..fed3627 100644
--- a/selling/doctype/selling_settings/selling_settings.txt
+++ b/selling/doctype/selling_settings/selling_settings.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-06-25 10:25:16",
"docstatus": 0,
- "modified": "2013-08-02 12:09:20",
+ "modified": "2013-08-09 14:46:24",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -64,7 +64,7 @@
},
{
"doctype": "DocField",
- "fieldname": "price_list_name",
+ "fieldname": "selling_price_list",
"fieldtype": "Link",
"label": "Default Price List",
"options": "Price List"
diff --git a/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
index 96c147f..6fdafe0 100644
--- a/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
+++ b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
@@ -8,6 +8,7 @@
import time
from accounts.utils import get_fiscal_year
from controllers.trends import get_period_date_ranges, get_period_month_ranges
+from webnotes.model.meta import get_field_precision
def execute(filters=None):
if not filters: filters = {}
@@ -16,10 +17,7 @@
period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
sim_map = get_salesperson_item_month_map(filters)
- precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2
-
data = []
-
for salesperson, salesperson_items in sim_map.items():
for item_group, monthwise_data in salesperson_items.items():
row = [salesperson, item_group]
@@ -29,7 +27,7 @@
for month in relevant_months:
month_data = monthwise_data.get(month, {})
for i, fieldname in enumerate(["target", "achieved", "variance"]):
- value = flt(month_data.get(fieldname), precision)
+ value = flt(month_data.get(fieldname))
period_data[i] += value
totals[i] += value
period_data[2] = period_data[0] - period_data[1]
@@ -47,37 +45,37 @@
msgprint(_("Please specify") + ": " + label,
raise_exception=True)
- columns = ["Sales Person:Link/Sales Person:80", "Item Group:Link/Item Group:80"]
+ columns = ["Sales Person:Link/Sales Person:120", "Item Group:Link/Item Group:120"]
group_months = False if filters["period"] == "Monthly" else True
for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]):
for label in ["Target (%s)", "Achieved (%s)", "Variance (%s)"]:
if group_months:
- columns.append(label % (from_date.strftime("%b") + " - " + to_date.strftime("%b")))
+ label = label % (from_date.strftime("%b") + " - " + to_date.strftime("%b"))
else:
- columns.append(label % from_date.strftime("%b"))
+ label = label % from_date.strftime("%b")
+
+ columns.append(label+":Float:120")
- return columns + ["Total Target::80", "Total Achieved::80", "Total Variance::80"]
+ return columns + ["Total Target::120", "Total Achieved::120", "Total Variance::120"]
#Get sales person & item group details
def get_salesperson_details(filters):
return webnotes.conn.sql("""select sp.name, td.item_group, td.target_qty,
td.target_amount, sp.distribution_id
from `tabSales Person` sp, `tabTarget Detail` td
- where td.parent=sp.name and td.fiscal_year=%s and
- ifnull(sp.distribution_id, '')!='' order by sp.name""",
+ where td.parent=sp.name and td.fiscal_year=%s order by sp.name""",
(filters["fiscal_year"]), as_dict=1)
#Get target distribution details of item group
def get_target_distribution_details(filters):
target_details = {}
- for d in webnotes.conn.sql("""select bdd.month, bdd.percentage_allocation \
- from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd, \
- `tabTerritory` t where bdd.parent=bd.name and t.distribution_id=bd.name and \
- bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
- target_details.setdefault(d.month, d)
+ for d in webnotes.conn.sql("""select bd.name, bdd.month, bdd.percentage_allocation
+ from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
+ where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
+ target_details.setdefault(d.name, {}).setdefault(d.month, d.percentage_allocation)
return target_details
@@ -94,32 +92,33 @@
(start_date, end_date), as_dict=1)
def get_salesperson_item_month_map(filters):
+ import datetime
salesperson_details = get_salesperson_details(filters)
tdd = get_target_distribution_details(filters)
achieved_details = get_achieved_details(filters)
sim_map = {}
-
for sd in salesperson_details:
- for month in tdd:
+ for month_id in range(1, 13):
+ month = datetime.date(2013, month_id, 1).strftime('%B')
sim_map.setdefault(sd.name, {}).setdefault(sd.item_group, {})\
- .setdefault(month, webnotes._dict({
- "target": 0.0, "achieved": 0.0
- }))
+ .setdefault(month, webnotes._dict({
+ "target": 0.0, "achieved": 0.0
+ }))
tav_dict = sim_map[sd.name][sd.item_group][month]
-
+ month_percentage = sd.distribution_id and \
+ tdd.get(sd.distribution_id, {}).get(month, 0) or 100.0/12
+
for ad in achieved_details:
if (filters["target_on"] == "Quantity"):
- tav_dict.target = flt(sd.target_qty) * \
- (tdd[month]["percentage_allocation"]/100)
+ tav_dict.target = flt(flt(sd.target_qty) * month_percentage/100, 2)
if ad.month_name == month and get_item_group(ad.item_code) == sd.item_group \
and ad.sales_person == sd.name:
tav_dict.achieved += ad.qty
if (filters["target_on"] == "Amount"):
- tav_dict.target = flt(sd.target_amount) * \
- (tdd[month]["percentage_allocation"]/100)
+ tav_dict.target = flt(flt(sd.target_amount) * month_percentage/100, 2)
if ad.month_name == month and get_item_group(ad.item_code) == sd.item_group \
and ad.sales_person == sd.name:
tav_dict.achieved += ad.amount
diff --git a/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
index 4a8cc7c..829f781 100644
--- a/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
+++ b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
@@ -46,37 +46,36 @@
label = (" ".join(fieldname.split("_"))).title()
msgprint(_("Please specify") + ": " + label, raise_exception=True)
- columns = ["Territory:Link/Territory:80", "Item Group:Link/Item Group:80"]
+ columns = ["Territory:Link/Territory:120", "Item Group:Link/Item Group:120"]
group_months = False if filters["period"] == "Monthly" else True
for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]):
for label in ["Target (%s)", "Achieved (%s)", "Variance (%s)"]:
if group_months:
- columns.append(label % (from_date.strftime("%b") + " - " + to_date.strftime("%b")))
+ label = label % (from_date.strftime("%b") + " - " + to_date.strftime("%b"))
else:
- columns.append(label % from_date.strftime("%b"))
+ label = label % from_date.strftime("%b")
+ columns.append(label+":Float:120")
- return columns + ["Total Target::80", "Total Achieved::80", "Total Variance::80"]
+ return columns + ["Total Target::120", "Total Achieved::120", "Total Variance::120"]
#Get territory & item group details
def get_territory_details(filters):
return webnotes.conn.sql("""select t.name, td.item_group, td.target_qty,
td.target_amount, t.distribution_id
from `tabTerritory` t, `tabTarget Detail` td
- where td.parent=t.name and td.fiscal_year=%s and
- ifnull(t.distribution_id, '')!='' order by t.name""",
+ where td.parent=t.name and td.fiscal_year=%s order by t.name""",
(filters["fiscal_year"]), as_dict=1)
#Get target distribution details of item group
def get_target_distribution_details(filters):
target_details = {}
- for d in webnotes.conn.sql("""select bdd.month, bdd.percentage_allocation \
- from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd, \
- `tabTerritory` t where bdd.parent=bd.name and t.distribution_id=bd.name and \
- bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
- target_details.setdefault(d.month, d)
+ for d in webnotes.conn.sql("""select bd.name, bdd.month, bdd.percentage_allocation
+ from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
+ where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
+ target_details.setdefault(d.name, {}).setdefault(d.month, d.percentage_allocation)
return target_details
@@ -99,25 +98,27 @@
tim_map = {}
for td in territory_details:
- for month in tdd:
+ for month_id in range(1, 13):
+ month = datetime.date(2013, month_id, 1).strftime('%B')
+
tim_map.setdefault(td.name, {}).setdefault(td.item_group, {})\
- .setdefault(month, webnotes._dict({
- "target": 0.0, "achieved": 0.0
- }))
+ .setdefault(month, webnotes._dict({
+ "target": 0.0, "achieved": 0.0
+ }))
tav_dict = tim_map[td.name][td.item_group][month]
+ month_percentage = td.distribution_id and \
+ tdd.get(td.distribution_id, {}).get(month, 0) or 100.0/12
for ad in achieved_details:
if (filters["target_on"] == "Quantity"):
- tav_dict.target = flt(td.target_qty) * \
- (tdd[month]["percentage_allocation"]/100)
+ tav_dict.target = flt(flt(td.target_qty) * month_percentage /100)
if ad.month_name == month and get_item_group(ad.item_code) == td.item_group \
and ad.territory == td.name:
tav_dict.achieved += ad.qty
if (filters["target_on"] == "Amount"):
- tav_dict.target = flt(td.target_amount) * \
- (tdd[month]["percentage_allocation"]/100)
+ tav_dict.target = flt(flt(td.target_amount) * month_percentage / 100)
if ad.month_name == month and get_item_group(ad.item_code) == td.item_group \
and ad.territory == td.name:
tav_dict.achieved += ad.amount
diff --git a/selling/utils.py b/selling/utils.py
index 858312a..7ccad6a 100644
--- a/selling/utils.py
+++ b/selling/utils.py
@@ -29,7 +29,7 @@
"warehouse": None,
"customer": "",
"conversion_rate": 1.0,
- "price_list_name": None,
+ "selling_price_list": None,
"price_list_currency": None,
"plc_conversion_rate": 1.0
}
@@ -57,7 +57,7 @@
if meta.get_field("currency"):
out.base_ref_rate = out.basic_rate = out.ref_rate = out.export_rate = 0.0
- if args.price_list_name and args.price_list_currency:
+ if args.selling_price_list and args.price_list_currency:
out.update(_get_price_list_rate(args, item_bean, meta))
out.update(_get_item_discount(out.item_group, args.customer))
@@ -129,7 +129,7 @@
def _get_price_list_rate(args, item_bean, meta):
base_ref_rate = item_bean.doclist.get({
"parentfield": "ref_rate_details",
- "price_list_name": args.price_list_name,
+ "price_list": args.selling_price_list,
"ref_currency": args.price_list_currency,
"buying_or_selling": "Selling"})
diff --git a/setup/doctype/naming_series/naming_series.py b/setup/doctype/naming_series/naming_series.py
index c9604fc..9cc4de2 100644
--- a/setup/doctype/naming_series/naming_series.py
+++ b/setup/doctype/naming_series/naming_series.py
@@ -121,8 +121,7 @@
def get_current(self, arg=None):
"""get series current"""
- self.doc.current_value = webnotes.conn.sql("""select current from tabSeries where name=%s""",
- self.doc.prefix)[0][0]
+ self.doc.current_value = webnotes.conn.get_value("Series", self.doc.prefix, "current")
def insert_series(self, series):
"""insert series if missing"""
diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js
index d11c4ba..5de8da5 100644
--- a/setup/doctype/price_list/price_list.js
+++ b/setup/doctype/price_list/price_list.js
@@ -19,7 +19,7 @@
},
show_item_prices: function() {
- var item_price = wn.model.get("Item Price", {price_list_name: cur_frm.doc.name});
+ var item_price = wn.model.get("Item Price", {price_list: cur_frm.doc.name});
var show = item_price && item_price.length;
diff --git a/setup/doctype/price_list/price_list.py b/setup/doctype/price_list/price_list.py
index 2a44e7b..112ce95 100644
--- a/setup/doctype/price_list/price_list.py
+++ b/setup/doctype/price_list/price_list.py
@@ -11,7 +11,7 @@
class DocType(DocListController):
def onload(self):
self.doclist.extend(webnotes.conn.sql("""select * from `tabItem Price`
- where price_list_name=%s""", self.doc.name, as_dict=True, update={"doctype": "Item Price"}))
+ where price_list=%s""", self.doc.name, as_dict=True, update={"doctype": "Item Price"}))
def validate(self):
if self.doc.buying_or_selling not in ["Buying", "Selling"]:
@@ -31,10 +31,20 @@
self.validate_table_has_rows("valid_for_territories")
def on_update(self):
+ self.set_default_if_missing()
cart_settings = webnotes.get_obj("Shopping Cart Settings")
if cint(cart_settings.doc.enabled):
cart_settings.validate_price_lists()
def on_trash(self):
- webnotes.conn.sql("""delete from `tabItem Price` where price_list_name = %s""",
- self.doc.name)
\ No newline at end of file
+ webnotes.conn.sql("""delete from `tabItem Price` where price_list = %s""",
+ self.doc.name)
+
+ def set_default_if_missing(self):
+ if self.doc.buying_or_selling=="Selling":
+ if not webnotes.conn.get_value("Selling Settings", None, "selling_price_list"):
+ webnotes.set_value("Selling Settings", "Selling Settings", "selling_price_list", self.doc.name)
+
+ elif self.doc.buying_or_selling=="Buying":
+ if not webnotes.conn.get_value("Buying Settings", None, "buying_price_list"):
+ webnotes.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.doc.name)
\ No newline at end of file
diff --git a/setup/utils.py b/setup/utils.py
index b0aa889..3d0c1ee 100644
--- a/setup/utils.py
+++ b/setup/utils.py
@@ -31,6 +31,6 @@
return result or []
@webnotes.whitelist()
-def get_price_list_currency(price_list_name):
- return {"price_list_currency": webnotes.conn.get_value("Price List", price_list_name,
+def get_price_list_currency(price_list):
+ return {"price_list_currency": webnotes.conn.get_value("Price List", price_list,
"currency")}
\ No newline at end of file
diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt
index e87d990..f1493bb 100644
--- a/stock/doctype/delivery_note/delivery_note.txt
+++ b/stock/doctype/delivery_note/delivery_note.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:09",
"docstatus": 0,
- "modified": "2013-08-08 14:22:21",
+ "modified": "2013-08-09 14:46:32",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -285,7 +285,7 @@
{
"description": "Select the price list as entered in \"Price List\" master. This will pull the reference rates of items against this price list as specified in \"Item\" master.",
"doctype": "DocField",
- "fieldname": "price_list_name",
+ "fieldname": "selling_price_list",
"fieldtype": "Link",
"label": "Price List",
"oldfieldname": "price_list_name",
diff --git a/stock/doctype/delivery_note/test_delivery_note.py b/stock/doctype/delivery_note/test_delivery_note.py
index 505cad3..2e3ab07 100644
--- a/stock/doctype/delivery_note/test_delivery_note.py
+++ b/stock/doctype/delivery_note/test_delivery_note.py
@@ -111,7 +111,7 @@
"posting_date": "2013-02-21",
"posting_time": "9:00:00",
"price_list_currency": "INR",
- "price_list_name": "_Test Price List",
+ "selling_price_list": "_Test Price List",
"status": "Draft",
"territory": "_Test Territory",
"net_total": 500.0,
diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js
index 7f43380..abf1e9e 100644
--- a/stock/doctype/item/item.js
+++ b/stock/doctype/item/item.js
@@ -5,16 +5,16 @@
erpnext.stock.Item = wn.ui.form.Controller.extend({
onload: function() {
- this.frm.add_fetch("price_list_name", "currency", "ref_currency");
- this.frm.add_fetch("price_list_name", "buying_or_selling", "buying_or_selling");
+ this.frm.add_fetch("price_list", "currency", "ref_currency");
+ this.frm.add_fetch("price_list", "buying_or_selling", "buying_or_selling");
},
ref_rate_details_add: function(doc, cdt, cdn) {
var row = wn.model.get_doc(cdt, cdn);
- if(row.price_list_name && !row.ref_currency) {
+ if(row.price_list && !row.ref_currency) {
// execute fetch
- var df = wn.meta.get_docfield(row.doctype, "price_list_name", row.parent);
- this.frm.script_manager.validate_link_and_fetch(df, row.name, row.price_list_name);
+ var df = wn.meta.get_docfield(row.doctype, "price_list", row.parent);
+ this.frm.script_manager.validate_link_and_fetch(df, row.name, row.price_list);
}
}
});
diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py
index cd70117..9ae1bfd 100644
--- a/stock/doctype/item/item.py
+++ b/stock/doctype/item/item.py
@@ -130,16 +130,16 @@
def validate_price_lists(self):
price_lists=[]
for d in getlist(self.doclist,'ref_rate_details'):
- if d.price_list_name in price_lists:
- msgprint(_("Cannot have two prices for same Price List") + ": " + d.price_list_name,
+ if d.price_list in price_lists:
+ msgprint(_("Cannot have two prices for same Price List") + ": " + d.price_list,
raise_exception= webnotes.DuplicateEntryError)
else:
- price_list_currency = webnotes.conn.get_value("Price List", d.price_list_name, "currency")
+ price_list_currency = webnotes.conn.get_value("Price List", d.price_list, "currency")
if price_list_currency and d.ref_currency != price_list_currency:
msgprint(_("Currency does not match Price List Currency for Price List") \
- + ": " + d.price_list_name, raise_exception=PriceListCurrencyMismatch)
+ + ": " + d.price_list, raise_exception=PriceListCurrencyMismatch)
- price_lists.append(d.price_list_name)
+ price_lists.append(d.price_list)
def fill_customer_code(self):
diff --git a/stock/doctype/item/test_item.py b/stock/doctype/item/test_item.py
index c28ba4f..a1d7852 100644
--- a/stock/doctype/item/test_item.py
+++ b/stock/doctype/item/test_item.py
@@ -61,7 +61,7 @@
}, {
"doctype": "Item Price",
"parentfield": "ref_rate_details",
- "price_list_name": "_Test Price List",
+ "price_list": "_Test Price List",
"ref_rate": 100,
"ref_currency": "INR",
"buying_or_selling": "Selling"
diff --git a/stock/doctype/item_price/item_price.txt b/stock/doctype/item_price/item_price.txt
index 7e23fb6..3a73a00 100644
--- a/stock/doctype/item_price/item_price.txt
+++ b/stock/doctype/item_price/item_price.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-02 16:29:48",
"docstatus": 0,
- "modified": "2013-07-31 17:30:34",
+ "modified": "2013-08-09 14:46:58",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -30,7 +30,7 @@
},
{
"doctype": "DocField",
- "fieldname": "price_list_name",
+ "fieldname": "price_list",
"fieldtype": "Link",
"in_filter": 1,
"label": "Price List Name",
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.txt b/stock/doctype/purchase_receipt/purchase_receipt.txt
index 6846288..1184643 100755
--- a/stock/doctype/purchase_receipt/purchase_receipt.txt
+++ b/stock/doctype/purchase_receipt/purchase_receipt.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
- "modified": "2013-08-08 14:22:28",
+ "modified": "2013-08-09 14:47:05",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -237,14 +237,14 @@
{
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
"doctype": "DocField",
- "fieldname": "price_list_name",
+ "fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
"print_hide": 1
},
{
- "depends_on": "price_list_name",
+ "depends_on": "buying_price_list",
"doctype": "DocField",
"fieldname": "price_list_currency",
"fieldtype": "Link",
@@ -255,7 +255,7 @@
"read_only": 1
},
{
- "depends_on": "price_list_name",
+ "depends_on": "buying_price_list",
"doctype": "DocField",
"fieldname": "plc_conversion_rate",
"fieldtype": "Float",
diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js
index 4fa6c6c..53998f8 100644
--- a/stock/doctype/stock_entry/stock_entry.js
+++ b/stock/doctype/stock_entry/stock_entry.js
@@ -4,34 +4,7 @@
wn.require("public/app/js/controllers/stock_controller.js");
wn.provide("erpnext.stock");
-erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
- onload: function() {
- this.set_default_account();
- },
-
- set_default_account: function() {
- var me = this;
-
- if (cint(wn.defaults.get_default("auto_inventory_accounting")) && !this.frm.doc.expense_adjustment_account) {
- if (this.frm.doc.purpose == "Sales Return")
- account_for = "stock_in_hand_account";
- else if (this.frm.doc.purpose == "Purchase Return")
- account_for = "stock_received_but_not_billed";
- else account_for = "stock_adjustment_account";
-
- return this.frm.call({
- method: "accounts.utils.get_company_default",
- args: {
- "fieldname": account_for,
- "company": this.frm.doc.company
- },
- callback: function(r) {
- if (!r.exc) me.frm.set_value("expense_adjustment_account", r.message);
- }
- });
- }
- },
-
+erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
setup: function() {
var me = this;
@@ -80,11 +53,7 @@
},
onload_post_render: function() {
- if(this.frm.doc.__islocal && (this.frm.doc.production_order || this.frm.doc.bom_no)
- && !getchildren('Stock Entry Detail', this.frm.doc.name, 'mtn_details').length) {
- // if production order / bom is mentioned, get items
- this.get_items();
- }
+ this.set_default_account();
},
refresh: function() {
@@ -115,6 +84,33 @@
after_cancel: function() {
this.clean_up();
},
+
+ set_default_account: function() {
+ var me = this;
+
+ if (cint(wn.defaults.get_default("auto_inventory_accounting")) && !this.frm.doc.expense_adjustment_account) {
+ var account_for = "stock_adjustment_account";
+ if (this.frm.doc.purpose == "Sales Return")
+ account_for = "stock_in_hand_account";
+ else if (this.frm.doc.purpose == "Purchase Return")
+ account_for = "stock_received_but_not_billed";
+
+ return this.frm.call({
+ method: "accounts.utils.get_company_default",
+ args: {
+ "fieldname": account_for,
+ "company": this.frm.doc.company
+ },
+ callback: function(r) {
+ if (!r.exc) me.frm.set_value("expense_adjustment_account", r.message);
+
+ me.get_items();
+ }
+ });
+ } else {
+ me.get_items();
+ }
+ },
clean_up: function() {
// Clear Production Order record from locals, because it is updated via Stock Entry
@@ -126,13 +122,17 @@
},
get_items: function() {
- return this.frm.call({
- doc: this.frm.doc,
- method: "get_items",
- callback: function(r) {
- if(!r.exc) refresh_field("mtn_details");
- }
- });
+ if(this.frm.doc.__islocal && (this.frm.doc.production_order || this.frm.doc.bom_no)
+ && !getchildren('Stock Entry Detail', this.frm.doc.name, 'mtn_details').length) {
+ // if production order / bom is mentioned, get items
+ return this.frm.call({
+ doc: this.frm.doc,
+ method: "get_items",
+ callback: function(r) {
+ if(!r.exc) refresh_field("mtn_details");
+ }
+ });
+ }
},
qty: function(doc, cdt, cdn) {
@@ -212,7 +212,6 @@
});
loaddoc("Journal Voucher", jv_name);
}
-
}
});
}
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index 66d1dbf..b702316 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -19,6 +19,7 @@
class NotUpdateStockError(webnotes.ValidationError): pass
class StockOverReturnError(webnotes.ValidationError): pass
+class IncorrectValuationRateError(webnotes.ValidationError): pass
from controllers.stock_controller import StockController
@@ -245,7 +246,7 @@
def validate_incoming_rate(self):
for d in getlist(self.doclist, 'mtn_details'):
if d.t_warehouse:
- self.validate_value("incoming_rate", ">", 0, d)
+ self.validate_value("incoming_rate", ">", 0, d, raise_exception=IncorrectValuationRateError)
def validate_bom(self):
for d in getlist(self.doclist, 'mtn_details'):
diff --git a/stock/doctype/stock_ledger/stock_ledger.py b/stock/doctype/stock_ledger/stock_ledger.py
index ed8196a..0af18b9 100644
--- a/stock/doctype/stock_ledger/stock_ledger.py
+++ b/stock/doctype/stock_ledger/stock_ledger.py
@@ -118,7 +118,7 @@
elif purpose == 'Sales Return':
webnotes.conn.sql("update `tabSerial No` set status = 'Delivered', purchase_document_type = '', purchase_document_no = '' where name = '%s'" % serial_no)
else:
- webnotes.conn.sql("update `tabSerial No` set docstatus = 2, status = 'Not in Use', purchase_document_type = '', purchase_document_no = '', purchase_date = null, purchase_rate = 0, supplier = null, supplier_name = '', supplier_address = '', warehouse = '' where name = '%s'" % serial_no)
+ webnotes.conn.sql("update `tabSerial No` set docstatus = 2, status = 'Not in Use', purchase_document_type = '', purchase_document_no = '', purchase_date = null, purchase_rate = 0, supplier = null, supplier_name = '', address_display = '', warehouse = '' where name = '%s'" % serial_no)
def check_serial_no_exists(self, serial_no, item_code):
diff --git a/stock/page/stock_balance/stock_balance.js b/stock/page/stock_balance/stock_balance.js
index 17f9b8d..1bc5d1c 100644
--- a/stock/page/stock_balance/stock_balance.js
+++ b/stock/page/stock_balance/stock_balance.js
@@ -133,8 +133,6 @@
} else {
break;
}
-
- me.round_item_values(item);
}
}
diff --git a/stock/report/item_prices/item_prices.py b/stock/report/item_prices/item_prices.py
index fbeba7c..0a6b29a 100644
--- a/stock/report/item_prices/item_prices.py
+++ b/stock/report/item_prices/item_prices.py
@@ -58,7 +58,7 @@
rate = {}
price_list = webnotes.conn.sql("""select parent, selling, buying,
- concat(price_list_name, " - ", ref_currency, " ", ref_rate) as price
+ concat(price_list, " - ", ref_currency, " ", ref_rate) as price
from `tabItem Price` where docstatus<2""", as_dict=1)
for j in price_list:
diff --git a/stock/report/item_wise_price_list/item_wise_price_list.txt b/stock/report/item_wise_price_list/item_wise_price_list.txt
index 824c603..2d5996a 100644
--- a/stock/report/item_wise_price_list/item_wise_price_list.txt
+++ b/stock/report/item_wise_price_list/item_wise_price_list.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-02-22 18:01:55",
"docstatus": 0,
- "modified": "2013-05-07 11:50:46",
+ "modified": "2013-05-07 11:52:00",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -10,7 +10,7 @@
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
- "query": "select\n item.name as \"ID:Link/Item:120\", \n item.item_name as \"Item Name::120\", \n item_price.price_list_name as \"Price List::80\",\n item_price.ref_currency as \"Currency::40\", \n item_price.ref_rate as \"Rate:Float:80\",\n item.description as \"Description::160\",\n item.item_group as \"Item Group:Link/Item Group:100\",\n item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price\nwhere\n item_price.parent = item.name",
+ "query": "select\n item.name as \"ID:Link/Item:120\", \n item.item_name as \"Item Name::120\", \n item_price.price_list as \"Price List::80\",\n item_price.ref_currency as \"Currency::40\", \n item_price.ref_rate as \"Rate:Float:80\",\n item.description as \"Description::160\",\n item.item_group as \"Item Group:Link/Item Group:100\",\n item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price\nwhere\n item_price.parent = item.name",
"ref_doctype": "Item",
"report_name": "Item-Wise Price List",
"report_type": "Query Report"
diff --git a/stock/report/material_requests_for_which_supplier_quotations_are_not_created/__init__.py b/stock/report/material_requests_for_which_supplier_quotations_are_not_created/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/report/material_requests_for_which_supplier_quotations_are_not_created/__init__.py
diff --git a/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.txt b/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.txt
new file mode 100644
index 0000000..5c842a8
--- /dev/null
+++ b/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-08-09 12:20:58",
+ "docstatus": 0,
+ "modified": "2013-08-09 12:25:29",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n mr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand not exists(select name from `tabSupplier Quotation Item` where prevdoc_docname=mr.name)\norder by mr.transaction_date asc",
+ "ref_doctype": "Material Request",
+ "report_name": "Material Requests for which Supplier Quotations are not created",
+ "report_type": "Query Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Material Requests for which Supplier Quotations are not created"
+ }
+]
\ No newline at end of file
diff --git a/stock/stock_ledger.py b/stock/stock_ledger.py
index 4dcca67..f0619c7 100644
--- a/stock/stock_ledger.py
+++ b/stock/stock_ledger.py
@@ -8,6 +8,7 @@
import json
# future reposting
+class NegativeStockError(webnotes.ValidationError): pass
_exceptions = []
def update_entries_after(args, verbose=1):
@@ -253,9 +254,9 @@
_exceptions[0]["voucher_type"], _exceptions[0]["voucher_no"],
abs(deficiency))
if verbose:
- msgprint(msg, raise_exception=1)
+ msgprint(msg, raise_exception=NegativeStockError)
else:
- raise webnotes.ValidationError, msg
+ raise NegativeStockError, msg
def get_previous_sle(args, for_update=False):
"""
diff --git a/stock/utils.py b/stock/utils.py
index 96eeef6..848783b 100644
--- a/stock/utils.py
+++ b/stock/utils.py
@@ -69,7 +69,7 @@
if valuation_method == 'FIFO':
if not previous_sle:
return 0.0
- previous_stock_queue = json.loads(previous_sle.get('stock_queue', '[]'))
+ previous_stock_queue = json.loads(previous_sle.get('stock_queue', '[]') or '[]')
in_rate = previous_stock_queue and \
get_fifo_rate(previous_stock_queue, args.get("qty") or 0) or 0
elif valuation_method == 'Moving Average':
@@ -184,8 +184,8 @@
def reorder_item():
""" Reorder item if stock reaches reorder level"""
if not hasattr(webnotes, "auto_indent"):
- webnotes.auto_indent = webnotes.conn.get_value('Stock Settings', None, 'auto_indent')
-
+ webnotes.auto_indent = cint(webnotes.conn.get_value('Stock Settings', None, 'auto_indent'))
+
if webnotes.auto_indent:
material_requests = {}
bin_list = webnotes.conn.sql("""select item_code, warehouse, projected_qty
@@ -280,8 +280,8 @@
if mr_list:
if not hasattr(webnotes, "reorder_email_notify"):
- webnotes.reorder_email_notify = webnotes.conn.get_value('Stock Settings', None,
- 'reorder_email_notify')
+ webnotes.reorder_email_notify = cint(webnotes.conn.get_value('Stock Settings', None,
+ 'reorder_email_notify'))
if(webnotes.reorder_email_notify):
send_email_notification(mr_list)
@@ -307,7 +307,6 @@
msg += "<tr><td>" + item.item_code + "</td><td>" + item.warehouse + "</td><td>" + \
cstr(item.qty) + "</td><td>" + cstr(item.uom) + "</td></tr>"
msg += "</table>"
-
sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg)
def notify_errors(exceptions_list):
diff --git a/utilities/demo_docs/BOM.csv b/utilities/demo_docs/BOM.csv
index 8e31275..446fc2e 100644
--- a/utilities/demo_docs/BOM.csv
+++ b/utilities/demo_docs/BOM.csv
@@ -1,48 +1,47 @@
-"Data Import Template"
-"Table:","BOM"
-""
-""
-"Notes:"
-"Please do not change the template headings."
-"First data column must be blank."
-"If you are uploading new records, leave the ""name"" (ID) column blank."
-"If you are uploading new records, ""Naming Series"" becomes mandatory, if present."
-"Only mandatory fields are necessary for new records. You can delete non-mandatory columns if you wish."
-"For updating, you can update only selective columns."
-"You can only upload upto 5000 records in one go. (may be less in some cases)"
-""
-"DocType:","BOM","","","","","","","","","","","","","","","","-","BOM Operation","bom_operations","","","","","","-","BOM Item","bom_materials","","","","","","","","","-","BOM Explosion Item","flat_bom_details","","","","","",""
-"Column Labels:","ID","Last Updated On","Item","Quantity","Is Active","Is Default","With Operations","Rate Of Materials Based On","Price List","Total Cost","Total Raw Material Cost","Total Operating Cost","Item UOM","Project Name","Item Desription","Amended From","-","ID","Operation No","Operation Description","Workstation","Hour Rate","Operation Time (mins)","Operating Cost","-","ID","Item Code","Qty","Stock UOM","Operation No","BOM No","Rate","Amount","Scrap %","Item Description","-","ID","Item Code","Description","Qty","Rate","Amount","Stock UOM","Qty Consumed Per Unit"
-"Column Name:","name","modified","item","quantity","is_active","is_default","with_operations","rm_cost_as_per","price_list","total_cost","raw_material_cost","operating_cost","uom","project_name","description","amended_from","-","name","operation_no","opn_description","workstation","hour_rate","time_in_mins","operating_cost","-","name","item_code","qty","stock_uom","operation_no","bom_no","rate","amount","scrap","description","-","name","item_code","description","qty","rate","amount","stock_uom","qty_consumed_per_unit"
-"Mandatory:","Yes","Yes","Yes","Yes","No","No","No","No","No","No","No","No","No","No","No","No","-","Yes","Yes","Yes","No","No","No","No","-","Yes","Yes","Yes","Yes","No","No","No","No","No","No","-","Yes","No","No","No","No","No","No","No"
-"Type:","Data (text)","Data","Link","Float","Check","Check","Check","Select","Link","Float","Float","Float","Select","Link","Small Text","Link","-","Data","Data","Text","Link","Float","Float","Float","-","Data","Link","Float","Link","Select","Link","Float","Float","Float","Text","-","Data","Link","Text","Float","Float","Float","Link","Float"
-"Info:","","Don't change!","Valid Item","","0 or 1","0 or 1","0 or 1","One of: Valuation Rate, Last Purchase Rate, Price List","Valid Price List","","","","Valid UOM","Valid Project","","Valid BOM","-","Leave blank for new records","","","Valid Workstation","","","","-","Leave blank for new records","Valid Item","","Valid UOM","","Valid BOM","","","","","-","Leave blank for new records","Valid Item","","","","","Valid UOM",""
-"Start entering data below this line"
-"","BOM/Bearing Assembly/001","""2013-08-07 16:58:00""","Bearing Assembly",1.0,1,"","","Price List","Standard Buying",130.0,130.0,0.0,"Nos","","Bearing Assembly","","","","","","","","","","","000000183","Base Bearing Plate",1.0,"Nos","","",15.0,15.0,"","1/4 in. x 6 in. x 6 in. Mild Steel Plate","","FBD/000039","Bearing Pipe","1.5 in. Diameter x 36 in. Mild Steel Tubing",1.0,15.0,15.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000184","Bearing Block",1.0,"Nos","","",10.0,10.0,"","CAST IRON, MCMASTER PART NO. 3710T13","","FBD/000040","Bearing Collar","1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar",2.0,20.0,40.0,"Nos",2.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000185","Bearing Collar",2.0,"Nos","","",20.0,40.0,"","1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar","","FBD/000041","Bearing Block","CAST IRON, MCMASTER PART NO. 3710T13",1.0,10.0,10.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000186","Bearing Pipe",1.0,"Nos","","",15.0,15.0,"","1.5 in. Diameter x 36 in. Mild Steel Tubing","","FBD/000042","Upper Bearing Plate","3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate",1.0,50.0,50.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000187","Upper Bearing Plate",1.0,"Nos","","",50.0,50.0,"","3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate","","FBD/000043","Base Bearing Plate","1/4 in. x 6 in. x 6 in. Mild Steel Plate",1.0,15.0,15.0,"Nos",1.0
-"","BOM/Wind Mill A Series/001","""2013-08-07 16:47:02""","Wind Mill A Series",1.0,1,"","","Price List","Standard Buying",223.0,223.0,0.0,"Nos","","Wind Mill A Series for Home Use 9ft","","","","","","","","","","","000000163","Base Bearing Plate",1.0,"Nos","","",15.0,15.0,"","1/4 in. x 6 in. x 6 in. Mild Steel Plate","","FBD/000008","Shaft","1.25 in. Diameter x 6 ft. Mild Steel Tubing",1.0,30.0,30.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000164","Base Plate",1.0,"Nos","","",20.0,20.0,"","3/4 in. x 2 ft. x 4 ft. Pine Plywood","","FBD/000009","Base Bearing Plate","1/4 in. x 6 in. x 6 in. Mild Steel Plate",1.0,15.0,15.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000165","Bearing Block",1.0,"Nos","","",10.0,10.0,"","CAST IRON, MCMASTER PART NO. 3710T13","","FBD/000010","External Disc","15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing",1.0,45.0,45.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000166","Bearing Pipe",1.0,"Nos","","",15.0,15.0,"","1.5 in. Diameter x 36 in. Mild Steel Tubing","","FBD/000011","Bearing Pipe","1.5 in. Diameter x 36 in. Mild Steel Tubing",1.0,15.0,15.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000167","External Disc",1.0,"Nos","","",45.0,45.0,"","15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing","","FBD/000012","Wing Sheet","1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet",4.0,22.0,88.0,"Nos",4.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000168","Shaft",1.0,"Nos","","",30.0,30.0,"","1.25 in. Diameter x 6 ft. Mild Steel Tubing","","FBD/000013","Base Plate","3/4 in. x 2 ft. x 4 ft. Pine Plywood",1.0,20.0,20.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000169","Wing Sheet",4.0,"Nos","","",22.0,88.0,"","1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet","","FBD/000014","Bearing Block","CAST IRON, MCMASTER PART NO. 3710T13",1.0,10.0,10.0,"Nos",1.0
-"","BOM/Wind MIll C Series/001","""2013-08-07 16:58:51""","Wind MIll C Series",1.0,1,"","","Price List","Standard Buying",314.0,314.0,0.0,"Nos","","Wind Mill C Series for Commercial Use 18ft","","","","","","","","","","","000000176","Base Plate",2.0,"Nos","","",20.0,40.0,"","3/4 in. x 2 ft. x 4 ft. Pine Plywood","","FBD/000061","Base Bearing Plate","1/4 in. x 6 in. x 6 in. Mild Steel Plate",1.0,15.0,15.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000178","Internal Disc",1.0,"Nos","","",33.0,33.0,"","For Bearing Collar","","FBD/000062","Bearing Collar","1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar",2.0,20.0,40.0,"Nos",2.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000179","External Disc",1.0,"Nos","","",45.0,45.0,"","15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing","","FBD/000063","Base Plate","3/4 in. x 2 ft. x 4 ft. Pine Plywood",2.0,20.0,40.0,"Nos",2.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000188","Bearing Assembly",1.0,"Nos","","BOM/Bearing Assembly/001",130.0,130.0,"","Bearing Assembly","","FBD/000064","Bearing Pipe","1.5 in. Diameter x 36 in. Mild Steel Tubing",1.0,15.0,15.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000189","Wing Sheet",3.0,"Nos","","",22.0,66.0,"","1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet","","FBD/000065","Internal Disc","For Bearing Collar",1.0,33.0,33.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","FBD/000066","Upper Bearing Plate","3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate",1.0,50.0,50.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","FBD/000067","Wing Sheet","1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet",3.0,22.0,66.0,"Nos",3.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","FBD/000068","External Disc","15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing",1.0,45.0,45.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","FBD/000069","Bearing Block","CAST IRON, MCMASTER PART NO. 3710T13",1.0,10.0,10.0,"Nos",1.0
-"","BOM/Wind Turbine/001","""2013-08-07 16:51:56""","Wind Turbine",1.0,1,"","","Price List","Standard Buying",139.0,139.0,0.0,"Nos","","Small Wind Turbine for Home Use","","","","","","","","","","","000000170","Base Bearing Plate",1.0,"Nos","","",15.0,15.0,"","1/4 in. x 6 in. x 6 in. Mild Steel Plate","","FBD/000021","Shaft","1.25 in. Diameter x 6 ft. Mild Steel Tubing",1.0,30.0,30.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000171","Base Plate",1.0,"Nos","","",20.0,20.0,"","3/4 in. x 2 ft. x 4 ft. Pine Plywood","","FBD/000022","Bearing Collar","1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar",1.0,20.0,20.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000172","Bearing Collar",1.0,"Nos","","",20.0,20.0,"","1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar","","FBD/000023","Base Plate","3/4 in. x 2 ft. x 4 ft. Pine Plywood",1.0,20.0,20.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000173","Blade Rib",1.0,"Nos","","",10.0,10.0,"","1/2 in. x 2 ft. x 4 ft. Pine Plywood","","FBD/000024","Base Bearing Plate","1/4 in. x 6 in. x 6 in. Mild Steel Plate",1.0,15.0,15.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000174","Shaft",1.0,"Nos","","",30.0,30.0,"","1.25 in. Diameter x 6 ft. Mild Steel Tubing","","FBD/000025","Blade Rib","1/2 in. x 2 ft. x 4 ft. Pine Plywood",1.0,10.0,10.0,"Nos",1.0
-"","","","","","","","","","","","","","","","","","","","","","","","","","","000000175","Wing Sheet",2.0,"Nos","","",22.0,44.0,"","1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet","","FBD/000026","Wing Sheet","1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet",2.0,22.0,44.0,"Nos",2.0
-
+Data Import Template,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+Table:,BOM,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+Notes:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+Please do not change the template headings.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+First data column must be blank.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+"If you are uploading new records, leave the ""name"" (ID) column blank.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+"If you are uploading new records, ""Naming Series"" becomes mandatory, if present.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+Only mandatory fields are necessary for new records. You can delete non-mandatory columns if you wish.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+"For updating, you can update only selective columns.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+You can only upload upto 5000 records in one go. (may be less in some cases),,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+DocType:,BOM,,,,,,,,,,,,,,,,-,BOM Operation,bom_operations,,,,,,-,BOM Item,bom_materials,,,,,,,,,-,BOM Explosion Item,flat_bom_details,,,,,,
+Column Labels:,ID,Last Updated On,Item,Quantity,Is Active,Is Default,With Operations,Rate Of Materials Based On,Price List,Total Cost,Total Raw Material Cost,Total Operating Cost,Item UOM,Project Name,Item Desription,Amended From,-,ID,Operation No,Operation Description,Workstation,Hour Rate,Operation Time (mins),Operating Cost,-,ID,Item Code,Qty,Stock UOM,Operation No,BOM No,Rate,Amount,Scrap %,Item Description,-,ID,Item Code,Description,Qty,Rate,Amount,Stock UOM,Qty Consumed Per Unit
+Column Name:,name,modified,item,quantity,is_active,is_default,with_operations,rm_cost_as_per,buying_price_list,total_cost,raw_material_cost,operating_cost,uom,project_name,description,amended_from,-,name,operation_no,opn_description,workstation,hour_rate,time_in_mins,operating_cost,-,name,item_code,qty,stock_uom,operation_no,bom_no,rate,amount,scrap,description,-,name,item_code,description,qty,rate,amount,stock_uom,qty_consumed_per_unit
+Mandatory:,Yes,Yes,Yes,Yes,No,No,No,No,No,No,No,No,No,No,No,No,-,Yes,Yes,Yes,No,No,No,No,-,Yes,Yes,Yes,Yes,No,No,No,No,No,No,-,Yes,No,No,No,No,No,No,No
+Type:,Data (text),Data,Link,Float,Check,Check,Check,Select,Link,Float,Float,Float,Select,Link,Small Text,Link,-,Data,Data,Text,Link,Float,Float,Float,-,Data,Link,Float,Link,Select,Link,Float,Float,Float,Text,-,Data,Link,Text,Float,Float,Float,Link,Float
+Info:,,Don't change!,Valid Item,,0 or 1,0 or 1,0 or 1,"One of: Valuation Rate, Last Purchase Rate, Price List",Valid Price List,,,,Valid UOM,Valid Project,,Valid BOM,-,Leave blank for new records,,,Valid Workstation,,,,-,Leave blank for new records,Valid Item,,Valid UOM,,Valid BOM,,,,,-,Leave blank for new records,Valid Item,,,,,Valid UOM,
+Start entering data below this line,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+,BOM/Bearing Assembly/001,"""2013-08-07 16:58:00""",Bearing Assembly,1.0,1,1,,Price List,Standard Buying,130.0,130.0,0.0,Nos,,Bearing Assembly,,,,,,,,,,,183,Base Bearing Plate,1.0,Nos,,,15.0,15.0,,1/4 in. x 6 in. x 6 in. Mild Steel Plate,,FBD/000039,Bearing Pipe,1.5 in. Diameter x 36 in. Mild Steel Tubing,1.0,15.0,15.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,184,Bearing Block,1.0,Nos,,,10.0,10.0,,"CAST IRON, MCMASTER PART NO. 3710T13",,FBD/000040,Bearing Collar,1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar,2.0,20.0,40.0,Nos,2.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,185,Bearing Collar,2.0,Nos,,,20.0,40.0,,1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar,,FBD/000041,Bearing Block,"CAST IRON, MCMASTER PART NO. 3710T13",1.0,10.0,10.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,186,Bearing Pipe,1.0,Nos,,,15.0,15.0,,1.5 in. Diameter x 36 in. Mild Steel Tubing,,FBD/000042,Upper Bearing Plate,3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate,1.0,50.0,50.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,187,Upper Bearing Plate,1.0,Nos,,,50.0,50.0,,3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate,,FBD/000043,Base Bearing Plate,1/4 in. x 6 in. x 6 in. Mild Steel Plate,1.0,15.0,15.0,Nos,1.0
+,BOM/Wind Mill A Series/001,"""2013-08-07 16:47:02""",Wind Mill A Series,1.0,1,1,,Price List,Standard Buying,223.0,223.0,0.0,Nos,,Wind Mill A Series for Home Use 9ft,,,,,,,,,,,163,Base Bearing Plate,1.0,Nos,,,15.0,15.0,,1/4 in. x 6 in. x 6 in. Mild Steel Plate,,FBD/000008,Shaft,1.25 in. Diameter x 6 ft. Mild Steel Tubing,1.0,30.0,30.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,164,Base Plate,1.0,Nos,,,20.0,20.0,,3/4 in. x 2 ft. x 4 ft. Pine Plywood,,FBD/000009,Base Bearing Plate,1/4 in. x 6 in. x 6 in. Mild Steel Plate,1.0,15.0,15.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,165,Bearing Block,1.0,Nos,,,10.0,10.0,,"CAST IRON, MCMASTER PART NO. 3710T13",,FBD/000010,External Disc,15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing,1.0,45.0,45.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,166,Bearing Pipe,1.0,Nos,,,15.0,15.0,,1.5 in. Diameter x 36 in. Mild Steel Tubing,,FBD/000011,Bearing Pipe,1.5 in. Diameter x 36 in. Mild Steel Tubing,1.0,15.0,15.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,167,External Disc,1.0,Nos,,,45.0,45.0,,15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing,,FBD/000012,Wing Sheet,1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet,4.0,22.0,88.0,Nos,4.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,168,Shaft,1.0,Nos,,,30.0,30.0,,1.25 in. Diameter x 6 ft. Mild Steel Tubing,,FBD/000013,Base Plate,3/4 in. x 2 ft. x 4 ft. Pine Plywood,1.0,20.0,20.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,169,Wing Sheet,4.0,Nos,,,22.0,88.0,,1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet,,FBD/000014,Bearing Block,"CAST IRON, MCMASTER PART NO. 3710T13",1.0,10.0,10.0,Nos,1.0
+,BOM/Wind MIll C Series/001,"""2013-08-07 16:58:51""",Wind MIll C Series,1.0,1,1,,Price List,Standard Buying,314.0,314.0,0.0,Nos,,Wind Mill C Series for Commercial Use 18ft,,,,,,,,,,,176,Base Plate,2.0,Nos,,,20.0,40.0,,3/4 in. x 2 ft. x 4 ft. Pine Plywood,,FBD/000061,Base Bearing Plate,1/4 in. x 6 in. x 6 in. Mild Steel Plate,1.0,15.0,15.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,178,Internal Disc,1.0,Nos,,,33.0,33.0,,For Bearing Collar,,FBD/000062,Bearing Collar,1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar,2.0,20.0,40.0,Nos,2.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,179,External Disc,1.0,Nos,,,45.0,45.0,,15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing,,FBD/000063,Base Plate,3/4 in. x 2 ft. x 4 ft. Pine Plywood,2.0,20.0,40.0,Nos,2.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,188,Bearing Assembly,1.0,Nos,,BOM/Bearing Assembly/001,130.0,130.0,,Bearing Assembly,,FBD/000064,Bearing Pipe,1.5 in. Diameter x 36 in. Mild Steel Tubing,1.0,15.0,15.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,189,Wing Sheet,3.0,Nos,,,22.0,66.0,,1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet,,FBD/000065,Internal Disc,For Bearing Collar,1.0,33.0,33.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,FBD/000066,Upper Bearing Plate,3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate,1.0,50.0,50.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,FBD/000067,Wing Sheet,1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet,3.0,22.0,66.0,Nos,3.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,FBD/000068,External Disc,15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing,1.0,45.0,45.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,FBD/000069,Bearing Block,"CAST IRON, MCMASTER PART NO. 3710T13",1.0,10.0,10.0,Nos,1.0
+,BOM/Wind Turbine/001,"""2013-08-07 16:51:56""",Wind Turbine,1.0,1,1,,Price List,Standard Buying,139.0,139.0,0.0,Nos,,Small Wind Turbine for Home Use,,,,,,,,,,,170,Base Bearing Plate,1.0,Nos,,,15.0,15.0,,1/4 in. x 6 in. x 6 in. Mild Steel Plate,,FBD/000021,Shaft,1.25 in. Diameter x 6 ft. Mild Steel Tubing,1.0,30.0,30.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,171,Base Plate,1.0,Nos,,,20.0,20.0,,3/4 in. x 2 ft. x 4 ft. Pine Plywood,,FBD/000022,Bearing Collar,1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar,1.0,20.0,20.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,172,Bearing Collar,1.0,Nos,,,20.0,20.0,,1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar,,FBD/000023,Base Plate,3/4 in. x 2 ft. x 4 ft. Pine Plywood,1.0,20.0,20.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,173,Blade Rib,1.0,Nos,,,10.0,10.0,,1/2 in. x 2 ft. x 4 ft. Pine Plywood,,FBD/000024,Base Bearing Plate,1/4 in. x 6 in. x 6 in. Mild Steel Plate,1.0,15.0,15.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,174,Shaft,1.0,Nos,,,30.0,30.0,,1.25 in. Diameter x 6 ft. Mild Steel Tubing,,FBD/000025,Blade Rib,1/2 in. x 2 ft. x 4 ft. Pine Plywood,1.0,10.0,10.0,Nos,1.0
+,,,,,,,,,,,,,,,,,,,,,,,,,,175,Wing Sheet,2.0,Nos,,,22.0,44.0,,1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet,,FBD/000026,Wing Sheet,1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet,2.0,22.0,44.0,Nos,2.0
\ No newline at end of file
diff --git a/utilities/demo_docs/Item.csv b/utilities/demo_docs/Item.csv
index b9ab6eb..3580748 100644
--- a/utilities/demo_docs/Item.csv
+++ b/utilities/demo_docs/Item.csv
@@ -1,38 +1,37 @@
-"Data Import Template"
-"Table:","Item"
-""
-""
-"Notes:"
-"Please do not change the template headings."
-"First data column must be blank."
-"If you are uploading new records, leave the ""name"" (ID) column blank."
-"If you are uploading new records, ""Naming Series"" becomes mandatory, if present."
-"Only mandatory fields are necessary for new records. You can delete non-mandatory columns if you wish."
-"For updating, you can update only selective columns."
-"You can only upload upto 5000 records in one go. (may be less in some cases)"
-""
-"DocType:","Item","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"Column Labels:","ID","Item Name","Item Group","Default Unit of Measure","Description","Is Stock Item","Is Asset Item","Has Batch No","Has Serial No","Is Purchase Item","Is Sales Item","Is Service Item","Allow Samples","Inspection Required","Allow Bill of Materials","Allow Production Order","Is Sub Contracted Item","Naming Series","Item Code","Brand","Barcode","Image","Description HTML","Default Warehouse","Allowance Percent","Valuation Method","Minimum Order Qty","Warranty Period (in days)","End of Life","Net Weight","Weight UOM","Re-Order Level","Re-Order Qty","Default Supplier","Lead Time Days","Default Expense Account","Default Cost Center","Last Purchase Rate","Standard Rate","Manufacturer","Manufacturer Part Number","Max Discount (%)","Default Income Account","Cost Center","Default BOM","Show in Website","Page Name","Weightage","Slideshow","Image","Website Warehouse","Website Description"
-"Column Name:","name","item_name","item_group","stock_uom","description","is_stock_item","is_asset_item","has_batch_no","has_serial_no","is_purchase_item","is_sales_item","is_service_item","is_sample_item","inspection_required","is_manufactured_item","is_pro_applicable","is_sub_contracted_item","naming_series","item_code","brand","barcode","image","description_html","default_warehouse","tolerance","valuation_method","min_order_qty","warranty_period","end_of_life","net_weight","weight_uom","re_order_level","re_order_qty","default_supplier","lead_time_days","purchase_account","cost_center","last_purchase_rate","standard_rate","manufacturer","manufacturer_part_no","max_discount","default_income_account","default_sales_cost_center","default_bom","show_in_website","page_name","weightage","slideshow","website_image","website_warehouse","web_long_description"
-"Mandatory:","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No"
-"Type:","Data (text)","Data","Link","Link","Small Text","Select","Select","Select","Select","Select","Select","Select","Select","Select","Select","Select","Select","Select","Data","Link","Data","Select","Small Text","Link","Float","Select","Float","Data","Date","Float","Link","Float","Float","Link","Int","Link","Link","Float","Float","Data","Data","Float","Link","Link","Link","Check","Data","Int","Link","Select","Link","Text Editor"
-"Info:","","","Valid Item Group","Valid UOM","","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: ITEM","","Valid Brand","","One of: attach_files:","","Valid Warehouse","","One of: FIFO, Moving Average","","","","","Valid UOM","","","Valid Supplier","Integer","Valid Account","Valid Cost Center","","","","","","Valid Account","Valid Cost Center","Valid BOM","0 or 1","","Integer","Valid Website Slideshow","One of: attach_files:","Valid Warehouse",""
-"Start entering data below this line"
-"","Base Bearing Plate","Base Bearing Plate","Raw Material","Nos","1/4 in. x 6 in. x 6 in. Mild Steel Plate","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Base Bearing Plate","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Base Plate","Base Plate","Raw Material","Nos","3/4 in. x 2 ft. x 4 ft. Pine Plywood","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Base Plate","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Bearing Assembly","Bearing Assembly","Sub Assemblies","Nos","Bearing Assembly","Yes","No","No","No","No","Yes","No","No","No","Yes","Yes","No","","Bearing Assembly","","","","","Stores - WP","","",0.0,"","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Bearing Block","Bearing Block","Raw Material","Nos","CAST IRON, MCMASTER PART NO. 3710T13","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Bearing Block","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Bearing Collar","Bearing Collar","Raw Material","Nos","1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Bearing Collar","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Bearing Pipe","Bearing Pipe","Raw Material","Nos","1.5 in. Diameter x 36 in. Mild Steel Tubing","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Bearing Pipe","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Blade Rib","Blade Rib","Raw Material","Nos","1/2 in. x 2 ft. x 4 ft. Pine Plywood","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Blade Rib","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Disc Collars","Disc Collars","Raw Material","Nos","For Upper Bearing","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Disc Collars","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","External Disc","External Disc","Raw Material","Nos","15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","External Disc","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Internal Disc","Internal Disc","Raw Material","Nos","For Bearing Collar","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Internal Disc","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Shaft","Shaft","Raw Material","Nos","1.25 in. Diameter x 6 ft. Mild Steel Tubing","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Shaft","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Stand","Stand","Raw Material","Nos","N/A","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Stand","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Upper Bearing Plate","Upper Bearing Plate","Raw Material","Nos","3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Upper Bearing Plate","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Wind Mill A Series","Wind Mill A Series","Products","Nos","Wind Mill A Series for Home Use 9ft","Yes","No","No","Yes","Yes","Yes","Yes","No","No","Yes","Yes","No","","Wind Mill A Series","","","","","Finished Goods - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Wind MIll C Series","Wind MIll C Series","Products","Nos","Wind Mill C Series for Commercial Use 18ft","Yes","No","No","Yes","Yes","Yes","Yes","No","No","Yes","Yes","No","","Wind MIll C Series","","","","","Finished Goods - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Wind Turbine","Wind Turbine","Products","Nos","Small Wind Turbine for Home Use","Yes","No","No","No","Yes","Yes","Yes","No","No","Yes","Yes","No","","Wind Turbine","","","","","Finished Goods - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-"","Wing Sheet","Wing Sheet","Raw Material","Nos","1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet","Yes","No","No","No","Yes","Yes","Yes","No","No","No","No","No","","Wing Sheet","","","","","Stores - WP","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
-
+Data Import Template,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+Table:,Item,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+Notes:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+Please do not change the template headings.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+First data column must be blank.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+"If you are uploading new records, leave the ""name"" (ID) column blank.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+"If you are uploading new records, ""Naming Series"" becomes mandatory, if present.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+Only mandatory fields are necessary for new records. You can delete non-mandatory columns if you wish.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+"For updating, you can update only selective columns.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+You can only upload upto 5000 records in one go. (may be less in some cases),,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+DocType:,Item,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+Column Labels:,ID,Item Name,Item Group,Default Unit of Measure,Description,Is Stock Item,Is Asset Item,Has Batch No,Has Serial No,Is Purchase Item,Is Sales Item,Is Service Item,Allow Samples,Inspection Required,Allow Bill of Materials,Allow Production Order,Is Sub Contracted Item,Document Numbering Series,Item Code,Brand,Barcode,Image,Description HTML,Default Warehouse,Allowance Percent,Valuation Method,Minimum Order Qty,Warranty Period (in days),End of Life,Net Weight,Weight UOM,Re-Order Level,Re-Order Qty,Default Supplier,Lead Time Days,Default Expense Account,Default Cost Center,Last Purchase Rate,Standard Rate,Manufacturer,Manufacturer Part Number,Max Discount (%),Default Income Account,Cost Center,Default BOM,Show in Website,Page Name,Weightage,Slideshow,Image,Website Warehouse,Website Description
+Column Name:,name,item_name,item_group,stock_uom,description,is_stock_item,is_asset_item,has_batch_no,has_serial_no,is_purchase_item,is_sales_item,is_service_item,is_sample_item,inspection_required,is_manufactured_item,is_pro_applicable,is_sub_contracted_item,naming_series,item_code,brand,barcode,image,description_html,default_warehouse,tolerance,valuation_method,min_order_qty,warranty_period,end_of_life,net_weight,weight_uom,re_order_level,re_order_qty,default_supplier,lead_time_days,purchase_account,cost_center,last_purchase_rate,standard_rate,manufacturer,manufacturer_part_no,max_discount,default_income_account,default_sales_cost_center,default_bom,show_in_website,page_name,weightage,slideshow,website_image,website_warehouse,web_long_description
+Mandatory:,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No
+Type:,Data (text),Data,Link,Link,Small Text,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Data,Link,Data,Select,Small Text,Link,Float,Select,Float,Data,Date,Float,Link,Float,Float,Link,Int,Link,Link,Float,Float,Data,Data,Float,Link,Link,Link,Check,Data,Int,Link,Select,Link,Text Editor
+Info:,,,Valid Item Group,Valid UOM,,"One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No",One of: ITEM,,Valid Brand,,One of: attach_files:,,Valid Warehouse,,"One of: FIFO, Moving Average",,,,,Valid UOM,,,Valid Supplier,Integer,Valid Account,Valid Cost Center,,,,,,Valid Account,Valid Cost Center,Valid BOM,0 or 1,,Integer,Valid Website Slideshow,One of: attach_files:,Valid Warehouse,
+Start entering data below this line,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+,Base Bearing Plate,Base Bearing Plate,Raw Material,Nos,1/4 in. x 6 in. x 6 in. Mild Steel Plate,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Base Bearing Plate,,,,,Stores - WP,,,,,,,,,,Eagle Hardware,,,,,,,,,,,,,,,,,,
+,Base Plate,Base Plate,Raw Material,Nos,3/4 in. x 2 ft. x 4 ft. Pine Plywood,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Base Plate,,,,,Stores - WP,,,,,,,,,,HomeBase,,,,,,,,,,,,,,,,,,
+,Bearing Assembly,Bearing Assembly,Sub Assemblies,Nos,Bearing Assembly,Yes,No,No,No,No,Yes,No,No,No,Yes,Yes,No,,Bearing Assembly,,,,,Stores - WP,,,0.0,,,,,,,Asiatic Solutions,,,,,,,,,,,,,,,,,,
+,Bearing Block,Bearing Block,Raw Material,Nos,"CAST IRON, MCMASTER PART NO. 3710T13",Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Bearing Block,,,,,Stores - WP,,,,,,,,,,Nan Duskin,,,,,,,,,,,,,,,,,,
+,Bearing Collar,Bearing Collar,Raw Material,Nos,1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Bearing Collar,,,,,Stores - WP,,,,,,,,,,Eagle Hardware,,,,,,,,,,,,,,,,,,
+,Bearing Pipe,Bearing Pipe,Raw Material,Nos,1.5 in. Diameter x 36 in. Mild Steel Tubing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Bearing Pipe,,,,,Stores - WP,,,,,,,,,,HomeBase,,,,,,,,,,,,,,,,,,
+,Blade Rib,Blade Rib,Raw Material,Nos,1/2 in. x 2 ft. x 4 ft. Pine Plywood,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Blade Rib,,,,,Stores - WP,,,,,,,,,,Ks Merchandise,,,,,,,,,,,,,,,,,,
+,Disc Collars,Disc Collars,Raw Material,Nos,For Upper Bearing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Disc Collars,,,,,Stores - WP,,,,,,,,,,Asiatic Solutions,,,,,,,,,,,,,,,,,,
+,External Disc,External Disc,Raw Material,Nos,15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,External Disc,,,,,Stores - WP,,,,,,,,,,HomeBase,,,,,,,,,,,,,,,,,,
+,Internal Disc,Internal Disc,Raw Material,Nos,For Bearing Collar,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Internal Disc,,,,,Stores - WP,,,,,,,,,,HomeBase,,,,,,,,,,,,,,,,,,
+,Shaft,Shaft,Raw Material,Nos,1.25 in. Diameter x 6 ft. Mild Steel Tubing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Shaft,,,,,Stores - WP,,,,,,,,,,Eagle Hardware,,,,,,,,,,,,,,,,,,
+,Stand,Stand,Raw Material,Nos,N/A,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Stand,,,,,Stores - WP,,,,,,,,,,Scott Ties,,,,,,,,,,,,,,,,,,
+,Upper Bearing Plate,Upper Bearing Plate,Raw Material,Nos,3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Upper Bearing Plate,,,,,Stores - WP,,,,,,,,,,Eagle Hardware,,,,,,,,,,,,,,,,,,
+,Wind Mill A Series,Wind Mill A Series,Products,Nos,Wind Mill A Series for Home Use 9ft,Yes,No,No,Yes,Yes,Yes,Yes,No,No,Yes,Yes,No,,Wind Mill A Series,,,,,Finished Goods - WP,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+,Wind MIll C Series,Wind MIll C Series,Products,Nos,Wind Mill C Series for Commercial Use 18ft,Yes,No,No,Yes,Yes,Yes,Yes,No,No,Yes,Yes,No,,Wind MIll C Series,,,,,Finished Goods - WP,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+,Wind Turbine,Wind Turbine,Products,Nos,Small Wind Turbine for Home Use,Yes,No,No,No,Yes,Yes,Yes,No,No,Yes,Yes,No,,Wind Turbine,,,,,Finished Goods - WP,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+,Wing Sheet,Wing Sheet,Raw Material,Nos,1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Wing Sheet,,,,,Stores - WP,,,,,,,,,,New World Realty,,,,,,,,,,,,,,,,,,
\ No newline at end of file
diff --git a/utilities/demo_docs/Item_Price.csv b/utilities/demo_docs/Item_Price.csv
index b181fb8..c1bc7ad 100644
--- a/utilities/demo_docs/Item_Price.csv
+++ b/utilities/demo_docs/Item_Price.csv
@@ -14,7 +14,7 @@
"If you are updating, please select ""Overwrite"" else existing rows will not be deleted.",,,,,
,,,,,
Column Labels,ID,Price List Name,Valid for Buying or Selling?,Ref Rate,Currency
-Column Name:,parent,price_list_name,buying_or_selling,ref_rate,ref_currency
+Column Name:,parent,price_list,buying_or_selling,ref_rate,ref_currency
Mandatory:,Yes,Yes,Yes,No,No
Type:,Data (text),Link,Select,Currency,Link
Info:,,Valid Price List,"One of: Buying, Selling",,Valid Currency
diff --git a/utilities/make_demo.py b/utilities/make_demo.py
index eaa3f41..a522862 100644
--- a/utilities/make_demo.py
+++ b/utilities/make_demo.py
@@ -3,32 +3,41 @@
import webnotes, os, datetime
import webnotes.utils
+from webnotes.widgets import query_report
import random
+import json
webnotes.session = webnotes._dict({"user":"Administrator"})
from core.page.data_import_tool.data_import_tool import upload
+# fix price list
+# fix fiscal year
+
company = "Wind Power LLC"
start_date = '2010-01-01'
-runs_for = 100
+runs_for = 20
prob = {
- "Quotation": { "make": 0.5, "qty": (1,3) },
- "Sales Order": { "make": 0.5, "qty": (1,2) }
+ "Quotation": { "make": 0.5, "qty": (1,5) },
+ "Sales Order": { "make": 0.5, "qty": (1,4) },
+ "Purchase Order": { "make": 0.7, "qty": (1,4) },
+ "Purchase Receipt": { "make": 0.7, "qty": (1,4) },
+ "Supplier Quotation": { "make": 0.5, "qty": (1, 3) }
}
-def make():
+def make(reset=False):
webnotes.connect()
webnotes.print_messages = True
webnotes.mute_emails = True
-
- # setup()
+
+ if reset:
+ setup()
simulate()
def setup():
install()
complete_setup()
- make_items()
make_customers_suppliers_contacts()
+ make_items()
make_users_and_employees()
# make_opening_stock()
# make_opening_accounts()
@@ -48,21 +57,68 @@
run_sales(current_date)
run_purchase(current_date)
run_manufacturing(current_date)
+ run_stock(current_date)
webnotes.conn.commit()
def run_sales(current_date):
- if random.random() < prob["Quotation"]["make"]:
- for i in xrange(random.randrange(*prob["Quotation"]["qty"])):
+ if can_make("Quotation"):
+ for i in xrange(how_many("Quotation")):
make_quotation(current_date)
-
- if random.random() < prob["Sales Order"]["make"]:
- for i in xrange(random.randrange(*prob["Sales Order"]["qty"])):
+
+ if can_make("Sales Order"):
+ for i in xrange(how_many("Sales Order")):
make_sales_order(current_date)
-def run_purchase(current_date):
- pass
+def run_stock(current_date):
+ # make purchase requests
+ if can_make("Purchase Receipt"):
+ from buying.doctype.purchase_order.purchase_order import make_purchase_receipt
+ report = "Purchase Order Items To Be Received"
+ for po in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Purchase Receipt")]:
+ pr = webnotes.bean(make_purchase_receipt(po))
+ pr.doc.posting_date = current_date
+ pr.doc.fiscal_year = "2010"
+ pr.insert()
+ pr.submit()
+ # make delivery notes (if possible)
+ if can_make("Delivery Note"):
+ from selling.doctype.sales_order.sales_order import make_delivery_note
+ report = "Ordered Items To Be Delivered"
+ for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Delivery Note")]:
+ dn = webnotes.bean(make_delivery_note(so))
+ dn.doc.posting_date = current_date
+ dn.doc.fiscal_year = "2010"
+ dn.insert()
+ dn.submit()
+
+
+def run_purchase(current_date):
+ # make supplier quotations
+ if can_make("Supplier Quotation"):
+ from stock.doctype.material_request.material_request import make_supplier_quotation
+ report = "Material Requests for which Supplier Quotations are not created"
+ for row in query_report.run(report)["result"][:how_many("Supplier Quotation")]:
+ if row[0] != "Total":
+ sq = webnotes.bean(make_supplier_quotation(row[0]))
+ sq.doc.transaction_date = current_date
+ sq.doc.fiscal_year = "2010"
+ sq.insert()
+ sq.submit()
+
+ # make purchase orders
+ if can_make("Purchase Order"):
+ from stock.doctype.material_request.material_request import make_purchase_order
+ report = "Requested Items To Be Ordered"
+ for row in query_report.run(report)["result"][:how_many("Purchase Order")]:
+ if row[0] != "Total":
+ po = webnotes.bean(make_purchase_order(row[0]))
+ po.doc.transaction_date = current_date
+ po.doc.fiscal_year = "2010"
+ po.insert()
+ po.submit()
+
def run_manufacturing(current_date):
ppt = webnotes.bean("Production Planning Tool", "Production Planning Tool")
ppt.doc.company = company
@@ -84,6 +140,40 @@
b = webnotes.bean("Material Request", pro[0])
b.submit()
+ # stores -> wip
+ if can_make("Stock Entry for WIP"):
+ for pro in query_report.run("Open Production Orders")["result"][:how_many("Stock Entry for WIP")]:
+ make_stock_entry_from_pro(pro[0], "Material Transfer", current_date)
+
+ # wip -> fg
+ if can_make("Stock Entry for FG"):
+ for pro in query_report.run("Production Orders in Progress")["result"][:how_many("Stock Entry for FG")]:
+ make_stock_entry_from_pro(pro[0], "Manufacture/Repack", current_date)
+
+ # try posting older drafts (if exists)
+ for st in webnotes.conn.get_values("Stock Entry", {"docstatus":0}):
+ try:
+ webnotes.bean("Stock Entry", st[0]).submit()
+ except NegativeStockError: pass
+ except IncorrectValuationRateError: pass
+
+
+def make_stock_entry_from_pro(pro_id, purpose, current_date):
+ from manufacturing.doctype.production_order.production_order import make_stock_entry
+ from stock.stock_ledger import NegativeStockError
+ from stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError
+
+ st = webnotes.bean(make_stock_entry(pro_id, purpose))
+ st.run_method("get_items")
+ st.doc.posting_date = current_date
+ st.doc.fiscal_year = "2010"
+ st.doc.expense_adjustment_account = "Stock in Hand - WP"
+ try:
+ st.insert()
+ st.submit()
+ except NegativeStockError: pass
+ except IncorrectValuationRateError: pass
+
def make_quotation(current_date):
b = webnotes.bean([{
"creation": current_date,
@@ -91,7 +181,6 @@
"quotation_to": "Customer",
"customer": get_random("Customer"),
"order_type": "Sales",
- "price_list_name": "Standard Selling",
"transaction_date": current_date,
"fiscal_year": "2010"
}])
@@ -109,12 +198,13 @@
def make_sales_order(current_date):
q = get_random("Quotation", {"status": "Submitted"})
- from selling.doctype.quotation.quotation import make_sales_order
- so = webnotes.bean(make_sales_order(q))
- so.doc.transaction_date = current_date
- so.doc.delivery_date = webnotes.utils.add_days(current_date, 10)
- so.insert()
- so.submit()
+ if q:
+ from selling.doctype.quotation.quotation import make_sales_order
+ so = webnotes.bean(make_sales_order(q))
+ so.doc.transaction_date = current_date
+ so.doc.delivery_date = webnotes.utils.add_days(current_date, 10)
+ so.insert()
+ so.submit()
def add_random_children(bean, template, rows, randomize, unique=None):
for i in xrange(random.randrange(1, rows)):
@@ -142,9 +232,15 @@
condition = ""
out = webnotes.conn.sql("""select name from `tab%s` %s
- order by RAND() limit 0,1""" % (doctype, condition))[0][0]
+ order by RAND() limit 0,1""" % (doctype, condition))
- return out
+ return out and out[0][0] or None
+
+def can_make(doctype):
+ return random.random() < prob.get(doctype, {"make": 0.5})["make"]
+
+def how_many(doctype):
+ return random.randrange(*prob.get(doctype, {"qty": (1, 3)})["qty"])
def install():
print "Creating Fresh Database..."
@@ -169,7 +265,8 @@
import_data("Fiscal_Year")
def make_items():
- import_data(["Item", "Item_Price", "BOM"])
+ import_data(["Item", "Item_Price"])
+ import_data("BOM", submit=True)
def make_customers_suppliers_contacts():
import_data(["Customer", "Supplier", "Contact", "Address", "Lead"])
@@ -180,12 +277,15 @@
import_data(["Profile", "Employee", "Salary_Structure"])
-def import_data(dt):
+def import_data(dt, submit=False):
if not isinstance(dt, (tuple, list)):
dt = [dt]
for doctype in dt:
print "Importing", doctype.replace("_", " "), "..."
+ webnotes.form_dict = {}
+ if submit:
+ webnotes.form_dict["params"] = json.dumps({"_submit": 1})
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", doctype+".csv")
upload()
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index ced4531..47e35f1 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -77,7 +77,7 @@
"""
customer_defaults = self.get_customer_defaults()
- customer_defaults["price_list"] = customer_defaults.get("price_list") or \
+ customer_defaults["price_list_name"] = customer_defaults.get("price_list") or \
webnotes.conn.get_value("Customer Group", self.doc.customer_group, "default_price_list") or \
self.doc.price_list
@@ -476,8 +476,8 @@
webnotes._dict({"fields": args})))
# validate price list conversion rate
- if meta.get_field("price_list_currency") and args.price_list_name and \
- args.price_list_currency:
+ if meta.get_field("price_list_currency") and (args.selling_price_list or args.buying_price_list) \
+ and args.price_list_currency:
validate_conversion_rate(args.price_list_currency, args.plc_conversion_rate,
meta.get_label("plc_conversion_rate"), args.company)
diff --git a/website/doctype/shopping_cart_price_list/shopping_cart_price_list.txt b/website/doctype/shopping_cart_price_list/shopping_cart_price_list.txt
index cdda874..361edf6 100644
--- a/website/doctype/shopping_cart_price_list/shopping_cart_price_list.txt
+++ b/website/doctype/shopping_cart_price_list/shopping_cart_price_list.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-06-20 16:00:18",
"docstatus": 0,
- "modified": "2013-07-10 14:54:23",
+ "modified": "2013-08-09 14:47:12",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -14,7 +14,7 @@
},
{
"doctype": "DocField",
- "fieldname": "price_list",
+ "fieldname": "selling_price_list",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Price List",
diff --git a/website/helpers/cart.py b/website/helpers/cart.py
index e184795..b6a7a01 100644
--- a/website/helpers/cart.py
+++ b/website/helpers/cart.py
@@ -297,7 +297,7 @@
def set_price_list_and_rate(quotation, cart_settings, billing_territory):
"""set price list based on billing territory"""
- quotation.doc.price_list_name = cart_settings.get_price_list(billing_territory)
+ quotation.doc.selling_price_list = cart_settings.get_price_list(billing_territory)
# reset values
quotation.doc.price_list_currency = quotation.doc.currency = \
@@ -309,7 +309,7 @@
quotation.run_method("set_price_list_and_item_details")
# set it in cookies for using in product page
- webnotes.cookies[b"price_list_name"] = quotation.doc.price_list_name
+ webnotes.cookies[b"selling_price_list"] = quotation.doc.selling_price_list
def set_taxes(quotation, cart_settings, billing_territory):
"""set taxes based on billing territory"""
diff --git a/website/helpers/product.py b/website/helpers/product.py
index 8c3d45c..8d817d0 100644
--- a/website/helpers/product.py
+++ b/website/helpers/product.py
@@ -16,7 +16,7 @@
cart_quotation = _get_cart_quotation()
- price_list = webnotes.cookies.get("price_list_name").value
+ price_list = webnotes.cookies.get("selling_price_list").value
warehouse = webnotes.conn.get_value("Item", item_code, "website_warehouse")
if warehouse:
@@ -28,7 +28,7 @@
in_stock = -1
price = price_list and webnotes.conn.sql("""select ref_rate, ref_currency from
- `tabItem Price` where parent=%s and price_list_name=%s""",
+ `tabItem Price` where parent=%s and price_list=%s""",
(item_code, price_list), as_dict=1) or []
price = price and price[0] or None