[aii] [patches] minor fixes

This commit is contained in:
Anand Doshi 2013-03-29 20:40:23 +05:30
parent 96a5f1dda0
commit 19acce9fa1
9 changed files with 42 additions and 11 deletions

View File

@ -17,7 +17,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.model.bean import getlist
from webnotes import msgprint
from webnotes import msgprint, _
from webnotes.utils.nestedset import DocTypeNestedSet
@ -37,6 +37,8 @@ class DocType(DocTypeNestedSet):
if self.doc.cost_center_name != 'Root' and not self.doc.parent_cost_center:
msgprint("Please enter parent cost center", raise_exception=1)
elif self.doc.cost_center_name == "Root" and self.doc.parent_cost_center:
msgprint(_("Root cannot have a parent cost center"), raise_exception=1)
def convert_group_to_ledger(self):
if self.check_if_child_exists():

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-26 11:03:08",
"creation": "2013-03-29 18:21:58",
"docstatus": 0,
"modified": "2013-03-28 15:42:14",
"modified": "2013-03-29 19:32:32",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -223,7 +223,7 @@
"fieldname": "cost_center",
"fieldtype": "Link",
"in_filter": 1,
"label": "Sales Cost Center",
"label": "Cost Center",
"oldfieldname": "cost_center",
"oldfieldtype": "Link",
"options": "Cost Center",

View File

@ -2,6 +2,9 @@ import webnotes
from webnotes.utils import now_datetime
def execute():
webnotes.reload_doc("stock", "doctype", "delivery_note_item")
webnotes.reload_doc("accounts", "doctype", "sales_invoice_item")
webnotes.conn.auto_commit_on_many_writes = True
for company in webnotes.conn.sql("select name from `tabCompany`"):
print company[0]

View File

@ -1,6 +1,8 @@
import webnotes
def execute():
webnotes.reload_doc("accounts", "doctype", "purchase_invoice_item")
for purchase_invoice in webnotes.conn.sql_list("""select distinct parent
from `tabPurchase Invoice Item` pi_item where docstatus = 1 and ifnull(valuation_rate, 0)=0
and exists(select name from `tabPurchase Invoice` where name = pi_item.parent)"""):

View File

@ -1,8 +1,15 @@
import webnotes
def execute():
webnotes.reload_doc("setup", "doctype", "company")
add_group_accounts()
add_ledger_accounts()
add_aii_cost_center()
set_default_accounts()
def set_default_accounts():
for company in webnotes.conn.sql_list("select name from `tabCompany`"):
webnotes.get_obj("Company", company).set_default_accounts()
def _check(parent_account, company):
def _get_root(is_pl_account, debit_or_credit):
@ -45,6 +52,14 @@ def add_ledger_accounts():
def add_accounts(accounts_to_add, check_fn=None):
for company, abbr in webnotes.conn.sql("""select name, abbr from `tabCompany`"""):
count = webnotes.conn.sql("""select count(name) from `tabAccount`
where company=%s and ifnull(parent_account, '')=''""", company)[0][0]
if count > 4:
print "Company", company, \
"has more than 4 root accounts. cannot apply patch to this company."
continue
for account_name, parent_account_name, group_or_ledger, account_type in accounts_to_add:
if not webnotes.conn.exists("Account", "%s - %s" % (account_name, abbr)):
parent_account = "%s - %s" % (parent_account_name, abbr)
@ -64,7 +79,11 @@ def add_aii_cost_center():
for company, abbr in webnotes.conn.sql("""select name, abbr from `tabCompany`"""):
if not webnotes.conn.exists("Cost Center", "Auto Inventory Accounting - %s" % abbr):
parent_cost_center = webnotes.conn.get_value("Cost Center",
{"parent_cost_center['']": '', "company_name": company}, 'name')
{"parent_cost_center['']": '', "company_name": company})
if not parent_cost_center:
print "Company", company, "does not have a root cost center"
continue
cc = webnotes.bean({
"doctype": "Cost Center",

View File

@ -212,7 +212,8 @@ class DocType(TransactionBase):
# ***************** Get Ref rate as entered in Item Master ********************
def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate):
ref_rate = webnotes.conn.sql("select ref_rate from `tabItem Price` where parent = %s and price_list_name = %s and ref_currency = %s", (item_code, price_list_name, price_list_currency))
ref_rate = webnotes.conn.sql("select ref_rate from `tabItem Price` where parent = %s and price_list_name = %s and ref_currency = %s and selling=1",
(item_code, price_list_name, price_list_currency))
base_ref_rate = ref_rate and flt(ref_rate[0][0]) * flt(plc_conv_rate) or 0
return base_ref_rate

View File

@ -17,7 +17,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt
from webnotes.utils import cstr, flt, cint
from webnotes.model.doc import addchild
from webnotes.model.bean import getlist
from webnotes import msgprint, _
@ -119,7 +119,7 @@ class DocType(DocListController):
def check_ref_rate_detail(self):
check_list=[]
for d in getlist(self.doclist,'ref_rate_details'):
if [cstr(d.price_list_name),cstr(d.ref_currency)] in check_list:
if [cstr(d.price_list_name),cstr(d.ref_currency),cint(d.selling),cint(d.buying)] in check_list:
msgprint("Ref Rate is entered twice for Price List : '%s' and Currency : '%s'." % (d.price_list_name,d.ref_currency))
raise Exception
else:

View File

@ -360,7 +360,8 @@ cur_frm.cscript.uom = function(doc, cdt, cdn) {
cur_frm.cscript.validate = function(doc, cdt, cdn) {
cur_frm.cscript.validate_items(doc);
validated = cur_frm.cscript.get_doctype_docname() ? true : false;
if($.inArray(cur_frm.doc.purpose, ["Purchase Return", "Sales Return"])!==-1)
validated = cur_frm.cscript.get_doctype_docname() ? true : false;
}
cur_frm.cscript.validate_items = function(doc) {

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-02-22 01:28:04",
"creation": "2013-03-29 18:22:12",
"docstatus": 0,
"modified": "2013-03-07 07:03:32",
"modified": "2013-03-29 19:43:04",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -158,6 +158,7 @@
"label": "Conversion Factor",
"oldfieldname": "conversion_factor",
"oldfieldtype": "Currency",
"print_hide": 1,
"read_only": 1,
"reqd": 1
},
@ -168,6 +169,7 @@
"label": "Qty as per Stock UOM",
"oldfieldname": "transfer_qty",
"oldfieldtype": "Currency",
"print_hide": 1,
"read_only": 1,
"reqd": 1
},
@ -180,6 +182,7 @@
"oldfieldname": "stock_uom",
"oldfieldtype": "Link",
"options": "UOM",
"print_hide": 1,
"read_only": 1,
"reqd": 1,
"search_index": 0