Merge pull request #1232 from nabinhait/hotfix

Hotfix
This commit is contained in:
Nabin Hait 2013-12-23 23:29:00 -08:00
commit 2ca388b0a5
5 changed files with 33 additions and 13 deletions

View File

@ -5,8 +5,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, cstr
from webnotes import msgprint, _
from webnotes import _
class DocType:
def __init__(self, d, dl):
@ -16,6 +15,11 @@ class DocType:
webnotes.conn.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock)
if self.doc.auto_accounting_for_stock:
for wh in webnotes.conn.sql("select name from `tabWarehouse`"):
wh_bean = webnotes.bean("Warehouse", wh[0])
warehouse_list = webnotes.conn.sql("select name, company from tabWarehouse", as_dict=1)
warehouse_with_no_company = [d.name for d in warehouse_list if not d.company]
if warehouse_with_no_company:
webnotes.throw(_("Company is missing in following warehouses") + ": \n" +
"\n".join(warehouse_with_no_company))
for wh in warehouse_list:
wh_bean = webnotes.bean("Warehouse", wh.name)
wh_bean.save()

View File

@ -9,8 +9,9 @@ from accounts.utils import get_balance_on
def execute(filters=None):
account_details = webnotes.conn.get_value("Account", filters["account"],
["debit_or_credit", "group_or_ledger"], as_dict=True)
validate_filters(filters, account_details.group_or_ledger)
["debit_or_credit", "group_or_ledger"], as_dict=True) if filters.get("account") else None
validate_filters(filters, account_details)
columns = get_columns()
data = []
if filters.get("group_by"):
@ -20,14 +21,15 @@ def execute(filters=None):
if data:
data.append(get_total_row(data))
if filters.get("account"):
if account_details:
data = [get_opening_balance_row(filters, account_details.debit_or_credit)] + data + \
[get_closing_balance_row(filters, account_details.debit_or_credit)]
return columns, data
def validate_filters(filters, group_or_ledger):
if group_or_ledger == "Ledger" and filters.get("group_by") == "Group by Account":
def validate_filters(filters, account_details):
if account_details and account_details.group_or_ledger == "Ledger" \
and filters.get("group_by") == "Group by Account":
webnotes.throw(_("Can not filter based on Account, if grouped by Account"))
if filters.get("voucher_no") and filters.get("group_by") == "Group by Voucher":

View File

@ -2,7 +2,7 @@
{
"creation": "2012-12-20 12:50:49",
"docstatus": 0,
"modified": "2013-11-03 14:20:18",
"modified": "2013-12-24 11:40:19",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -90,7 +90,7 @@
"doctype": "DocField",
"fieldname": "fs_packing_details",
"fieldtype": "Check",
"label": "Packing Detials"
"label": "Packing Details"
},
{
"description": "To get Item Group in details table",

View File

@ -20,6 +20,19 @@ class DocType:
if self.doc.email_id and not validate_email_add(self.doc.email_id):
msgprint("Please enter valid Email Id", raise_exception=1)
self.update_parent_account()
def update_parent_account(self):
if not self.doc.__islocal and (self.doc.create_account_under !=
webnotes.conn.get_value("Warehouse", self.doc.name, "create_account_under")):
warehouse_account = webnotes.conn.get_value("Account",
{"account_type": "Warehouse", "company": self.doc.company,
"master_name": self.doc.name}, ["name", "parent_account"])
if warehouse_account and warehouse_account[1] != self.doc.create_account_under:
acc_bean = webnotes.bean("Account", warehouse_account[0])
acc_bean.doc.parent_account = self.doc.create_account_under
acc_bean.save()
def on_update(self):
self.create_account_head()

View File

@ -62,9 +62,10 @@ def get_item_conditions(filters):
def get_sle_conditions(filters):
conditions = []
if filters.get("item_code"):
item_conditions=get_item_conditions(filters)
if item_conditions:
conditions.append("""item_code in (select name from tabItem
{item_conditions})""".format(item_conditions=get_item_conditions(filters)))
{item_conditions})""".format(item_conditions=item_conditions))
if filters.get("warehouse"):
conditions.append("warehouse=%(warehouse)s")
if filters.get("voucher_no"):