Merge branch 'slow' of github.com:webnotes/erpnext into slow
This commit is contained in:
commit
48ba0a26ba
@ -35,8 +35,9 @@ class DocType:
|
|||||||
self.check_credit_limit()
|
self.check_credit_limit()
|
||||||
self.check_pl_account()
|
self.check_pl_account()
|
||||||
|
|
||||||
def on_update(self,adv_adj, cancel, update_outstanding = 'Yes'):
|
def on_update(self, adv_adj, cancel, update_outstanding = 'Yes'):
|
||||||
self.validate_account_details(adv_adj)
|
self.validate_account_details(adv_adj)
|
||||||
|
self.validate_cost_center()
|
||||||
self.check_freezing_date(adv_adj)
|
self.check_freezing_date(adv_adj)
|
||||||
self.check_negative_balance(adv_adj)
|
self.check_negative_balance(adv_adj)
|
||||||
|
|
||||||
@ -97,21 +98,36 @@ class DocType:
|
|||||||
from tabAccount where name=%s""", self.doc.account, as_dict=1)
|
from tabAccount where name=%s""", self.doc.account, as_dict=1)
|
||||||
|
|
||||||
if ret and ret[0]["group_or_ledger"]=='Group':
|
if ret and ret[0]["group_or_ledger"]=='Group':
|
||||||
msgprint(_("Account: ") + self.doc.account + _(" is not a ledger"), raise_exception=1)
|
msgprint(_("Account") + ": " + self.doc.account + _(" is not a ledger"), raise_exception=1)
|
||||||
|
|
||||||
if ret and ret[0]["docstatus"]==2:
|
if ret and ret[0]["docstatus"]==2:
|
||||||
msgprint(_("Account: ") + self.doc.account + _(" is not active"), raise_exception=1)
|
msgprint(_("Account") + ": " + self.doc.account + _(" is not active"), raise_exception=1)
|
||||||
|
|
||||||
# Account has been freezed for other users except account manager
|
# Account has been freezed for other users except account manager
|
||||||
if ret and ret[0]["freeze_account"]== 'Yes' and not adv_adj \
|
if ret and ret[0]["freeze_account"]== 'Yes' and not adv_adj \
|
||||||
and not 'Accounts Manager' in webnotes.user.get_roles():
|
and not 'Accounts Manager' in webnotes.user.get_roles():
|
||||||
msgprint(_("Account: ") + self.doc.account + _(" has been freezed. \
|
msgprint(_("Account") + ": " + self.doc.account + _(" has been freezed. \
|
||||||
Only Accounts Manager can do transaction against this account"), raise_exception=1)
|
Only Accounts Manager can do transaction against this account"), raise_exception=1)
|
||||||
|
|
||||||
if ret and ret[0]["company"] != self.doc.company:
|
if ret and ret[0]["company"] != self.doc.company:
|
||||||
msgprint(_("Account: ") + self.doc.account + _(" does not belong to the company: ") +
|
msgprint(_("Account") + ": " + self.doc.account + _(" does not belong to the company") \
|
||||||
self.doc.company, raise_exception=1)
|
+ ": " + self.doc.company, raise_exception=1)
|
||||||
|
|
||||||
|
def validate_cost_center(self):
|
||||||
|
if not hasattr(self, "cost_center_company"):
|
||||||
|
self.cost_center_company = {}
|
||||||
|
|
||||||
|
def _get_cost_center_company():
|
||||||
|
if not self.cost_center_company.get(self.doc.cost_center):
|
||||||
|
self.cost_center_company[self.doc.cost_center] = webnotes.conn.get_value("Cost Center",
|
||||||
|
self.doc.cost_center, "company_name")
|
||||||
|
|
||||||
|
return self.cost_center_company[self.doc.cost_center]
|
||||||
|
|
||||||
|
if self.doc.cost_center and _get_cost_center_company() != self.doc.company:
|
||||||
|
msgprint(_("Cost Center") + ": " + self.doc.cost_center \
|
||||||
|
+ _(" does not belong to the company") + ": " + self.doc.company, raise_exception=True)
|
||||||
|
|
||||||
def check_freezing_date(self, adv_adj):
|
def check_freezing_date(self, adv_adj):
|
||||||
"""
|
"""
|
||||||
Nobody can do GL Entries where posting date is before freezing date
|
Nobody can do GL Entries where posting date is before freezing date
|
||||||
|
10
patches/april_2013/p06_default_cost_center.py
Normal file
10
patches/april_2013/p06_default_cost_center.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import webnotes
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
for dt, fieldname in \
|
||||||
|
(("Journal Voucher Detail", "cost_center"),
|
||||||
|
("Sales Taxes and Charges", "cost_center_other_charges"),
|
||||||
|
("Purchase Taxes and Charges", "cost_center"), ("Delivery Note Item", "cost_center"),
|
||||||
|
("Purchase Invoice Item", "cost_center"), ("Sales Invoice Item", "cost_center")):
|
||||||
|
webnotes.conn.sql_ddl("""alter table `tab%s` alter `%s` drop default""" % (dt, fieldname))
|
||||||
|
webnotes.reload_doc(webnotes.conn.get_value("DocType", dt, "module"), "DocType", dt)
|
@ -241,5 +241,6 @@ patch_list = [
|
|||||||
"execute:webnotes.delete_doc('Search Criteria', 'time_log_summary')",
|
"execute:webnotes.delete_doc('Search Criteria', 'time_log_summary')",
|
||||||
"patches.april_2013.p04_update_role_in_pages",
|
"patches.april_2013.p04_update_role_in_pages",
|
||||||
"patches.april_2013.p05_fixes_in_reverse_modules",
|
"patches.april_2013.p05_fixes_in_reverse_modules",
|
||||||
"execute:webnotes.delete_doc('DocType Mapper', 'Delivery Note-Packing Slip')"
|
"execute:webnotes.delete_doc('DocType Mapper', 'Delivery Note-Packing Slip')",
|
||||||
|
"patches.april_2013.p06_default_cost_center",
|
||||||
]
|
]
|
Loading…
Reference in New Issue
Block a user