Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Nabin Hait 2013-06-04 10:49:57 +05:30
commit 5c13163e84
10 changed files with 116 additions and 37 deletions

View File

@ -351,7 +351,7 @@ class DocType(SellingController):
if ret.get("warehouse"):
ret["actual_qty"] = flt(webnotes.conn.get_value("Bin",
{"item_code": args.get("item_code"), "warehouse": args.get("warehouse")},
{"item_code": args.get("item_code"), "warehouse": ret.get("warehouse")},
"actual_qty"))
return ret
@ -433,17 +433,6 @@ class DocType(SellingController):
from accounts.utils import reconcile_against_document
reconcile_against_document(lst)
def validate_customer(self):
""" Validate customer name with SO and DN"""
for d in getlist(self.doclist,'entries'):
dt = d.delivery_note and 'Delivery Note' or d.sales_order and 'Sales Order' or ''
if dt:
dt_no = d.delivery_note or d.sales_order
cust = webnotes.conn.sql("select customer from `tab%s` where name = %s" % (dt, '%s'), dt_no)
if cust and cstr(cust[0][0]) != cstr(self.doc.customer):
msgprint("Customer %s does not match with customer of %s: %s." %(self.doc.customer, dt, dt_no), raise_exception=1)
def validate_customer_account(self):
"""Validates Debit To Account and Customer Matches"""
if self.doc.customer and self.doc.debit_to and not cint(self.doc.is_pos):
@ -453,6 +442,19 @@ class DocType(SellingController):
(not acc_head and (self.doc.debit_to != cstr(self.doc.customer) + " - " + self.get_company_abbr())):
msgprint("Debit To: %s do not match with Customer: %s for Company: %s.\n If both correctly entered, please select Master Type \
and Master Name in account master." %(self.doc.debit_to, self.doc.customer,self.doc.company), raise_exception=1)
def validate_customer(self):
""" Validate customer name with SO and DN"""
if self.doc.customer:
for d in getlist(self.doclist,'entries'):
dt = d.delivery_note and 'Delivery Note' or d.sales_order and 'Sales Order' or ''
if dt:
dt_no = d.delivery_note or d.sales_order
cust = webnotes.conn.get_value(dt, dt_no, "customer")
if cust and cstr(cust) != cstr(self.doc.customer):
msgprint("Customer %s does not match with customer of %s: %s."
%(self.doc.customer, dt, dt_no), raise_exception=1)
def validate_debit_acc(self):

View File

@ -0,0 +1,49 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
def execute(filters=None):
account_map = get_account_map()
columns = get_columns(account_map)
data = []
customers = webnotes.conn.sql("select name from tabCustomer where docstatus < 2")
for cust in customers:
row = [cust[0]]
for company in sorted(account_map):
row.append(account_map[company].get(cust[0], ''))
data.append(row)
return columns, data
def get_account_map():
accounts = webnotes.conn.sql("""select name, company, master_name
from `tabAccount` where master_type = 'Customer'
and ifnull(master_name, '') != '' and docstatus < 2""", as_dict=1)
account_map = {}
for acc in accounts:
account_map.setdefault(acc.company, {}).setdefault(acc.master_name, {})
account_map[acc.company][acc.master_name] = acc.name
return account_map
def get_columns(account_map):
columns = ["Customer:Link/Customer:120"] + \
[(company + ":Link/Account:120") for company in sorted(account_map)]
return columns

View File

@ -0,0 +1,21 @@
[
{
"creation": "2013-06-03 16:17:34",
"docstatus": 0,
"modified": "2013-06-03 16:17:34",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Account",
"report_name": "Customer Account Head",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Customer Account Head"
}
]

View File

@ -273,36 +273,45 @@ def create_stock_in_hand_jv(reverse=False):
jv = webnotes.bean([
{
"doctype": "Journal Voucher",
"naming_series": "_PATCH-",
"naming_series": "JV-AUTO-",
"company": company,
"posting_date": today,
"fiscal_year": fiscal_year,
"voucher_type": "Journal Entry",
"user_remark": "Accounting Entry for Stock: \
Initial booking of stock received but not billed account"
"user_remark": (_("Auto Inventory Accounting") + ": " +
(_("Disabled") if reverse else _("Enabled")) + ". " +
_("Journal Entry for inventory that is received but not yet invoiced"))
},
{
"doctype": "Journal Voucher Detail",
"parentfield": "entries",
"account": get_company_default(company, "stock_received_but_not_billed"),
(stock_rbnb_value > 0 and "credit" or "debit"): abs(stock_rbnb_value)
(stock_rbnb_value > 0 and "credit" or "debit"): abs(stock_rbnb_value)
},
{
"doctype": "Journal Voucher Detail",
"parentfield": "entries",
"account": get_company_default(company, "stock_adjustment_account"),
(stock_rbnb_value > 0 and "debit" or "credit"): abs(stock_rbnb_value),
(stock_rbnb_value > 0 and "debit" or "credit"): abs(stock_rbnb_value),
"cost_center": get_company_default(company, "stock_adjustment_cost_center")
},
])
jv.insert()
jv.submit()
jv_list.append(jv.doc.name)
if jv_list:
webnotes.msgprint("""Folowing Journal Vouchers has been created automatically:
%s""" % '\n'.join(jv_list))
msgprint(_("Following Journal Vouchers have been created automatically") + \
":\n%s" % ("\n".join([("<a href=\"#Form/Journal Voucher/%s\">%s</a>" % (jv, jv)) for jv in jv_list]),))
msgprint(_("""These adjustment vouchers book the difference between \
the total value of received items and the total value of invoiced items, \
as a required step to use Auto Inventory Accounting.
This is an approximation to get you started.
You will need to submit these vouchers after checking if the values are correct.
For more details, read: \
<a href="http://erpnext.com/auto-inventory-accounting" target="_blank">\
Auto Inventory Accounting</a>"""))
webnotes.msgprint("""Please refresh the system to get effect of Auto Inventory Accounting""")

View File

@ -317,9 +317,9 @@ class DocType:
items_to_be_requested = webnotes._dict()
for item in self.item_dict:
if flt(self.item_dict[item][0]) > item_projected_qty[item]:
if flt(self.item_dict[item][0]) > item_projected_qty.get(item, 0):
# shortage
requested_qty = flt(self.item_dict[item][0]) - item_projected_qty[item]
requested_qty = flt(self.item_dict[item][0]) - item_projected_qty.get(item, 0)
# comsider minimum order qty
requested_qty = requested_qty > flt(self.item_dict[item][3]) and \
requested_qty or flt(self.item_dict[item][3])
@ -379,4 +379,4 @@ class DocType:
webnotes.msgprint("Following Material Request created successfully: \n%s" %
"\n".join(pur_req))
else:
webnotes.msgprint("Nothing to request")
webnotes.msgprint("Nothing to request")

View File

@ -2,11 +2,13 @@ import webnotes, os, webnotes.utils
def execute():
files_path = webnotes.utils.get_path("public", "files")
webnotes.conn.auto_commit_on_many_writes = 1
for f in webnotes.conn.sql("""select name, file_name from
`tabFile Data`""", as_dict=True):
if f.file_name:
filepath = os.path.join(files_path, f.file_name)
if os.path.exists(filepath):
webnotes.conn.set_value("File Data", f.name, "file_size", os.stat(filepath).st_size)
webnotes.conn.auto_commit_on_many_writes = 0

View File

@ -2,6 +2,8 @@ import webnotes
def execute():
from patches.april_2013.p05_update_file_data import update_file_list, get_single_doctypes
webnotes.conn.auto_commit_on_many_writes = 1
singles = get_single_doctypes()
for doctype in webnotes.conn.sql_list("""select table_name from `information_schema`.`columns`
where table_schema=%s and column_name='file_list'""", webnotes.conn.cur_db_name):
@ -13,4 +15,5 @@ def execute():
webnotes.conn.sql("""delete from `tabCustom Field` where fieldname='file_list'
and parent=%s""", doctype)
webnotes.conn.auto_commit_on_many_writes = 0

View File

@ -123,16 +123,9 @@ class DocType:
def validate_series_name(self, n):
import re
if "." in n:
parts = n.split(".")
if len(parts) > 2:
msgprint("Only one dot (.) allowed in " + n, raise_exception=1)
if not re.match("#+$", parts[-1]):
msgprint("Numbering series must be in hashes (e.g. ####)", raise_exception=1)
n = n[0]
if not re.match("^[a-zA-Z0-9-/]*$", n):
msgprint('Special Characters except "-" and "/" not allowed in naming series')
raise Exception
if not re.match("^[a-zA-Z0-9-/.#]*$", n):
msgprint('Special Characters except "-" and "/" not allowed in naming series',
raise_exception=True)
def get_options(self, arg=''):
sr = webnotes.model.doctype.get_property(self.doc.select_doc_for_series,

View File

@ -73,7 +73,7 @@ wn.module_page["Setup"] = [
{
"route":"Form/Naming Series/Naming Series",
doctype: "Naming Series",
label: wn._("Manage numbering series"),
label: wn._("Manage Numbering Series"),
"description":wn._("Set multiple numbering series for transactions")
},
{