Merge pull request #1355 from akhileshdarjee/hotfix
Allow rename for price list
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index a39702b..1768b9b 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -320,12 +320,9 @@
item = webnotes.conn.sql("select name,is_asset_item,is_sales_item from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())"% d.item_code)
acc = webnotes.conn.sql("select account_type from `tabAccount` where name = '%s' and docstatus != 2" % d.income_account)
if not acc:
- msgprint("Account: "+d.income_account+" does not exist in the system")
- raise Exception
+ msgprint("Account: "+d.income_account+" does not exist in the system", raise_exception=True)
elif item and item[0][1] == 'Yes' and not acc[0][0] == 'Fixed Asset Account':
- msgprint("Please select income head with account type 'Fixed Asset Account' as Item %s is an asset item" % d.item_code)
- raise Exception
-
+ msgprint("Please select income head with account type 'Fixed Asset Account' as Item %s is an asset item" % d.item_code, raise_exception=True)
def validate_with_previous_doc(self):
super(DocType, self).validate_with_previous_doc(self.tname, {
diff --git a/accounts/report/accounts_receivable/accounts_receivable.py b/accounts/report/accounts_receivable/accounts_receivable.py
index de96abb..c826fcb 100644
--- a/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/accounts/report/accounts_receivable/accounts_receivable.py
@@ -37,12 +37,15 @@
return columns
def get_data(self, customer_naming_by):
+ from accounts.utils import get_currency_precision
+ currency_precision = get_currency_precision() or 2
+
data = []
future_vouchers = self.get_entries_after(self.filters.report_date)
for gle in self.get_entries_till(self.filters.report_date):
if self.is_receivable(gle, future_vouchers):
outstanding_amount = self.get_outstanding_amount(gle, self.filters.report_date)
- if abs(outstanding_amount) > 0.0:
+ if abs(outstanding_amount) > 0.1/10**currency_precision:
due_date = self.get_due_date(gle)
invoiced_amount = gle.debit if (gle.debit > 0) else 0
payment_received = invoiced_amount - outstanding_amount
diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py
index 02e970b..af6a87c 100644
--- a/accounts/report/general_ledger/general_ledger.py
+++ b/accounts/report/general_ledger/general_ledger.py
@@ -51,7 +51,7 @@
gl_entries = webnotes.conn.sql("""select posting_date, account,
sum(ifnull(debit, 0)) as debit, sum(ifnull(credit, 0)) as credit,
- voucher_type, voucher_no, cost_center, remarks, is_advance, against
+ voucher_type, voucher_no, cost_center, remarks, is_opening, against
from `tabGL Entry`
where company=%(company)s {conditions}
{group_by_condition}
diff --git a/accounts/utils.py b/accounts/utils.py
index fdd57b3..a3557ae 100644
--- a/accounts/utils.py
+++ b/accounts/utils.py
@@ -378,4 +378,13 @@
account_for_field = "account_type"
return webnotes.conn.get_value("Account", {account_for_field: account_for_doctype,
- "master_name": account_for})
\ No newline at end of file
+ "master_name": account_for})
+
+def get_currency_precision(currency=None):
+ if not currency:
+ currency = webnotes.conn.get_value("Company",
+ webnotes.conn.get_default("company"), "default_currency")
+ currency_format = webnotes.conn.get_value("Currency", currency, "number_format")
+
+ from webnotes.utils import get_number_format_info
+ return get_number_format_info(currency_format)[2]
\ No newline at end of file
diff --git a/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt b/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt
index 49c7478..4d3558c 100644
--- a/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt
+++ b/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-13 16:10:02",
"docstatus": 0,
- "modified": "2013-05-13 16:21:07",
+ "modified": "2014-01-24 18:19:11",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -11,7 +11,7 @@
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
- "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.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.ordered_qty as \"Ordered Qty:Float:100\", \n\t(mr_item.qty - ifnull(mr_item.ordered_qty, 0)) as \"Qty to Order: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 ifnull(mr_item.ordered_qty, 0) < ifnull(mr_item.qty, 0)\norder by mr.transaction_date asc",
+ "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tsum(ifnull(mr_item.qty, 0)) as \"Qty:Float:100\",\n\tsum(ifnull(mr_item.ordered_qty, 0)) as \"Ordered Qty:Float:100\", \n\t(sum(mr_item.qty) - sum(ifnull(mr_item.ordered_qty, 0))) as \"Qty to Order: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\"\ngroup by mr.name, mr_item.item_code\nhaving\n\tsum(ifnull(mr_item.ordered_qty, 0)) < sum(ifnull(mr_item.qty, 0))\norder by mr.transaction_date asc",
"ref_doctype": "Purchase Order",
"report_name": "Requested Items To Be Ordered",
"report_type": "Query Report"
diff --git a/config.json b/config.json
index d454594..f71ed9b 100644
--- a/config.json
+++ b/config.json
@@ -1,6 +1,6 @@
{
"app_name": "ERPNext",
- "app_version": "3.6.5",
+ "app_version": "3.6.6",
"base_template": "app/portal/templates/base.html",
"modules": {
"Accounts": {
@@ -74,5 +74,5 @@
"type": "module"
}
},
- "requires_framework_version": "==3.7.4"
+ "requires_framework_version": "==3.7.5"
}
\ No newline at end of file
diff --git a/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/manufacturing/doctype/production_planning_tool/production_planning_tool.py
index 29232f5..90d9dc5 100644
--- a/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -243,10 +243,10 @@
"item_code": [qty_required, description, stock_uom, min_order_qty]
}
"""
- bom_wise_item_details = {}
item_list = []
for bom, so_wise_qty in bom_dict.items():
+ bom_wise_item_details = {}
if self.doc.use_multi_level_bom:
# get all raw materials with sub assembly childs
for d in webnotes.conn.sql("""select fb.item_code,
diff --git a/patches/1401/fix_planned_qty.py b/patches/1401/fix_planned_qty.py
new file mode 100644
index 0000000..96f56fb
--- /dev/null
+++ b/patches/1401/fix_planned_qty.py
@@ -0,0 +1,10 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import webnotes
+
+def execute():
+ from utilities.repost_stock import repost_stock
+ for d in webnotes.conn.sql("""select distinct production_item, fg_warehouse
+ from `tabProduction Order` where docstatus>0""", as_dict=1):
+ repost_stock(d.production_item, d.fg_warehouse)
\ No newline at end of file
diff --git a/patches/1401/fix_serial_no_status_and_warehouse.py b/patches/1401/fix_serial_no_status_and_warehouse.py
new file mode 100644
index 0000000..fe43c28
--- /dev/null
+++ b/patches/1401/fix_serial_no_status_and_warehouse.py
@@ -0,0 +1,17 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+def execute():
+ serial_nos = webnotes.conn.sql("""select name from `tabSerial No` where docstatus=0
+ and status in ('Available', 'Sales Returned') and ifnull(warehouse, '') = ''""")
+ for sr in serial_nos:
+ try:
+ sr_bean = webnotes.bean("Serial No", sr[0])
+ sr_bean.make_controller().via_stock_ledger = True
+ sr_bean.save()
+ webnotes.conn.commit()
+ except:
+ pass
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 89e3309..3061720 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -267,4 +267,6 @@
"patches.1401.p01_make_buying_selling_as_check_box_in_price_list",
"patches.1401.update_billing_status_for_zero_value_order",
"patches.1401.enable_all_price_list",
+ "patches.1401.fix_serial_no_status_and_warehouse",
+ "patches.1401.fix_planned_qty",
]
\ No newline at end of file
diff --git a/portal/templates/sale.html b/portal/templates/sale.html
index 5dc72c7..c0996cc 100644
--- a/portal/templates/sale.html
+++ b/portal/templates/sale.html
@@ -10,9 +10,9 @@
<li class="active"><i class="icon-file icon-fixed-width"></i> {{ doc.name }}</li>
</ul>
<h3><i class="icon-file icon-fixed-width"></i> {{ doc.name }}</h3>
- {% if doc.name == "Not Allowed" -%}
+ {% if session_user == "Guest" -%}
<script>ask_to_login();</script>
- {% else %}
+ {% elif doc.name != "Not Allowed"%}
<hr>
<div>
<div class="row">
diff --git a/portal/utils.py b/portal/utils.py
index 89800f3..e210f1a 100644
--- a/portal/utils.py
+++ b/portal/utils.py
@@ -41,21 +41,23 @@
}
def get_transaction_context(doctype, name):
+ context = {"session_user": webnotes.session.user}
+
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
"customer")
bean = webnotes.bean(doctype, name)
if bean.doc.customer != customer:
- return {
- "doc": {"name": "Not Allowed"}
- }
+ context.update({"doc": {"name": "Not Allowed"}})
else:
- return {
+ context.update({
"doc": bean.doc,
"doclist": bean.doclist,
"webnotes": webnotes,
"utils": webnotes.utils
- }
+ })
+
+ return context
@webnotes.whitelist(allow_guest=True)
def send_message(subject="Website Query", message="", sender="", status="Open"):
diff --git a/selling/doctype/sales_order/templates/pages/order.py b/selling/doctype/sales_order/templates/pages/order.py
index d53a8b0..9b4a83c 100644
--- a/selling/doctype/sales_order/templates/pages/order.py
+++ b/selling/doctype/sales_order/templates/pages/order.py
@@ -10,11 +10,12 @@
def get_context():
from portal.utils import get_transaction_context
context = get_transaction_context("Sales Order", webnotes.form_dict.name)
- modify_status(context.get("doc"))
- context.update({
- "parent_link": "orders",
- "parent_title": "My Orders"
- })
+ if context.get("doc").get("name") != "Not Allowed":
+ modify_status(context.get("doc"))
+ context.update({
+ "parent_link": "orders",
+ "parent_title": "My Orders"
+ })
return context
def modify_status(doc):
diff --git a/selling/utils/cart.py b/selling/utils/cart.py
index 3cd7b3c..7904627 100644
--- a/selling/utils/cart.py
+++ b/selling/utils/cart.py
@@ -282,7 +282,7 @@
party = get_lead_or_customer()
if not quotation:
quotation = _get_cart_quotation(party)
-
+
cart_settings = webnotes.get_obj("Shopping Cart Settings")
billing_territory = get_address_territory(quotation.doc.customer_address) or \
@@ -310,7 +310,8 @@
quotation.run_method("set_price_list_and_item_details")
# set it in cookies for using in product page
- webnotes.local._response.set_cookie("selling_price_list", quotation.doc.selling_price_list)
+ if quotation.doc.selling_price_list:
+ webnotes.local._response.set_cookie("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/stock/doctype/item/test_item.py b/stock/doctype/item/test_item.py
index b8f6f9e..4754174 100644
--- a/stock/doctype/item/test_item.py
+++ b/stock/doctype/item/test_item.py
@@ -36,6 +36,7 @@
"stock_uom": "_Test UOM",
"default_income_account": "Sales - _TC",
"default_warehouse": "_Test Warehouse - _TC",
+ "purchase_account": "_Test Account Cost for Goods Sold - _TC"
}, {
"doctype": "Item Reorder",
"parentfield": "item_reorder",
@@ -64,6 +65,7 @@
"stock_uom": "_Test UOM",
"default_income_account": "Sales - _TC",
"default_warehouse": "_Test Warehouse - _TC",
+ "purchase_account": "_Test Account Cost for Goods Sold - _TC"
}],
[{
"doctype": "Item",
@@ -73,6 +75,7 @@
"item_group": "_Test Item Group Desktops",
"default_warehouse": "_Test Warehouse - _TC",
"default_income_account": "Sales - _TC",
+ "purchase_account": "_Test Account Cost for Goods Sold - _TC",
"is_stock_item": "Yes",
"is_asset_item": "No",
"has_batch_no": "No",
@@ -99,6 +102,7 @@
"item_group": "_Test Item Group Desktops",
"default_warehouse": "_Test Warehouse - _TC",
"default_income_account": "Sales - _TC",
+ "purchase_account": "_Test Account Cost for Goods Sold - _TC",
"is_stock_item": "Yes",
"is_asset_item": "No",
"has_batch_no": "No",
@@ -119,6 +123,7 @@
"description": "_Test Sales BOM Item",
"item_group": "_Test Item Group Desktops",
"default_income_account": "Sales - _TC",
+ "purchase_account": "_Test Account Cost for Goods Sold - _TC",
"is_stock_item": "No",
"is_asset_item": "No",
"has_batch_no": "No",
@@ -140,6 +145,7 @@
"is_stock_item": "Yes",
"default_warehouse": "_Test Warehouse - _TC",
"default_income_account": "Sales - _TC",
+ "purchase_account": "_Test Account Cost for Goods Sold - _TC",
"is_asset_item": "No",
"has_batch_no": "No",
"has_serial_no": "No",
@@ -216,6 +222,7 @@
"item_group": "_Test Item Group Desktops",
"default_warehouse": "_Test Warehouse - _TC",
"default_income_account": "Sales - _TC",
+ "purchase_account": "_Test Account Cost for Goods Sold - _TC",
"is_stock_item": "Yes",
"is_asset_item": "No",
"has_batch_no": "No",
@@ -238,6 +245,7 @@
"is_stock_item": "Yes",
"default_warehouse": "_Test Warehouse - _TC",
"default_income_account": "Sales - _TC",
+ "purchase_account": "_Test Account Cost for Goods Sold - _TC",
"is_asset_item": "No",
"has_batch_no": "No",
"has_serial_no": "No",
diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py
index bd2704d..e6557b4 100644
--- a/stock/doctype/serial_no/serial_no.py
+++ b/stock/doctype/serial_no/serial_no.py
@@ -87,6 +87,8 @@
self.doc.status = "Sales Returned"
else:
self.doc.status = "Available"
+ if not self.doc.warehouse:
+ self.doc.warehouse = last_sle.warehouse
else:
if document_type == "Purchase Return":
self.doc.status = "Purchase Returned"
@@ -94,6 +96,8 @@
self.doc.status = "Delivered"
else:
self.doc.status = "Not Available"
+ else:
+ self.doc.status = "Not Available"
def set_purchase_details(self, purchase_sle):
if purchase_sle:
@@ -185,10 +189,9 @@
def on_stock_ledger_entry(self):
if self.via_stock_ledger and not self.doc.fields.get("__islocal"):
last_sle = self.get_last_sle()
- if last_sle:
- self.set_status(last_sle.get("last_sle"))
- self.set_purchase_details(last_sle.get("purchase_sle"))
- self.set_sales_details(last_sle.get("delivery_sle"))
+ self.set_status(last_sle.get("last_sle"))
+ self.set_purchase_details(last_sle.get("purchase_sle"))
+ self.set_sales_details(last_sle.get("delivery_sle"))
def on_communication(self):
return
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index 7dec878..c322a1a 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -346,7 +346,8 @@
pro_bean = webnotes.bean("Production Order", self.doc.production_order)
_validate_production_order(pro_bean)
self.update_produced_qty(pro_bean)
- self.update_planned_qty(pro_bean)
+ if self.doc.purpose == "Manufacture/Repack":
+ self.update_planned_qty(pro_bean)
def update_produced_qty(self, pro_bean):
if self.doc.purpose == "Manufacture/Repack":
diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py
index e1b0ef3..0b2fa84 100644
--- a/stock/doctype/warehouse/warehouse.py
+++ b/stock/doctype/warehouse/warehouse.py
@@ -92,23 +92,19 @@
exists for this warehouse."""))
def before_rename(self, olddn, newdn, merge=False):
- # Add company abbr if not provided
- from setup.doctype.company.company import get_name_with_abbr
- new_warehouse = get_name_with_abbr(newdn, self.doc.company)
-
if merge:
if not webnotes.conn.exists("Warehouse", newdn):
webnotes.throw(_("Warehouse ") + newdn +_(" does not exists"))
- if self.doc.company != webnotes.conn.get_value("Warehouse", new_warehouse, "company"):
+ if self.doc.company != webnotes.conn.get_value("Warehouse", newdn, "company"):
webnotes.throw(_("Both Warehouse must belong to same Company"))
webnotes.conn.sql("delete from `tabBin` where warehouse=%s", olddn)
from accounts.utils import rename_account_for
- rename_account_for("Warehouse", olddn, new_warehouse, merge)
+ rename_account_for("Warehouse", olddn, newdn, merge)
- return new_warehouse
+ return newdn
def after_rename(self, olddn, newdn, merge=False):
if merge:
diff --git a/stock/report/item_prices/item_prices.py b/stock/report/item_prices/item_prices.py
index c9efd69..50c923b 100644
--- a/stock/report/item_prices/item_prices.py
+++ b/stock/report/item_prices/item_prices.py
@@ -15,6 +15,7 @@
bom_rate = get_item_bom_rate()
val_rate_map = get_valuation_rate()
+ from accounts.utils import get_currency_precision
precision = get_currency_precision() or 2
data = []
for item in sorted(item_map):
@@ -29,14 +30,6 @@
])
return columns, data
-
-def get_currency_precision():
- company_currency = webnotes.conn.get_value("Company",
- webnotes.conn.get_default("company"), "default_currency")
- currency_format = webnotes.conn.get_value("Currency", company_currency, "number_format")
-
- from webnotes.utils import get_number_format_info
- return get_number_format_info(currency_format)[2]
def get_columns(filters):
"""return columns based on filters"""
diff --git a/utilities/demo/demo_docs/Fiscal_Year.csv b/utilities/demo/demo_docs/Fiscal_Year.csv
index d56b1b9..1a06e87 100644
--- a/utilities/demo/demo_docs/Fiscal_Year.csv
+++ b/utilities/demo/demo_docs/Fiscal_Year.csv
@@ -20,4 +20,5 @@
Start entering data below this line,,,,
,,2009,01-01-2009,31-12-2009,No
,,2010,01-01-2010,31-12-2010,No
-,,2011,01-01-2011,31-12-2011,No
\ No newline at end of file
+,,2011,01-01-2011,31-12-2011,No
+,,2012,01-01-2012,31-12-2012,No
\ No newline at end of file
diff --git a/utilities/demo/make_demo.py b/utilities/demo/make_demo.py
index b98fd7a..99c3e8b 100644
--- a/utilities/demo/make_demo.py
+++ b/utilities/demo/make_demo.py
@@ -19,7 +19,7 @@
country = "United States"
currency = "USD"
time_zone = "America/New_York"
-start_date = '2013-01-01'
+start_date = '2014-01-01'
bank_name = "Citibank"
runs_for = None
prob = {
@@ -105,6 +105,10 @@
for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Sales Invoice")]:
si = webnotes.bean(make_sales_invoice(so))
si.doc.posting_date = current_date
+ for d in si.doclist.get({"parentfield": "entries"}):
+ if not d.income_account:
+ d.income_account = "Sales - {}".format(company_abbr)
+
si.insert()
si.submit()
webnotes.conn.commit()
@@ -170,6 +174,9 @@
dn = webnotes.bean(make_delivery_note(so))
dn.doc.posting_date = current_date
dn.doc.fiscal_year = current_date.year
+ for d in dn.doclist.get({"parentfield": "delivery_note_details"}):
+ d.expense_account = "Cost of Goods Sold - {}".format(company_abbr)
+
dn.insert()
try:
dn.submit()
@@ -236,7 +243,7 @@
ppt = webnotes.bean("Production Planning Tool", "Production Planning Tool")
ppt.doc.company = company
ppt.doc.use_multi_level_bom = 1
- ppt.doc.purchase_request_for_warehouse = "Stores - WP"
+ ppt.doc.purchase_request_for_warehouse = "Stores - {}".format(company_abbr)
ppt.run_method("get_open_sales_orders")
ppt.run_method("get_items_from_so")
ppt.run_method("raise_production_order")
@@ -380,8 +387,8 @@
setup_account({
"first_name": "Test",
"last_name": "User",
- "fy_start_date": "2013-01-01",
- "fy_end_date": "2013-12-31",
+ "fy_start_date": "2014-01-01",
+ "fy_end_date": "2014-12-31",
"industry": "Manufacturing",
"company_name": company,
"company_abbr": company_abbr,