[bug fixes] [global defaults] [cleanup]

This commit is contained in:
Rushabh Mehta
2013-06-24 18:18:46 +05:30
parent 7925bd7079
commit 7a93d5de30
23 changed files with 339 additions and 291 deletions

View File

@@ -147,7 +147,7 @@ class DocType:
def get_authorized_user(self):
# Check logged-in user is authorized
if webnotes.conn.get_value('Global Defaults', None, 'credit_controller') \
if webnotes.conn.get_value('Accounts Settings', None, 'credit_controller') \
in webnotes.user.get_roles():
return 1

View File

@@ -0,0 +1,23 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self):
self.make_adjustment_jv_for_auto_inventory()
def make_adjustment_jv_for_auto_inventory(self):
previous_auto_inventory_accounting = cint(webnotes.conn.get_value("Accounts Settings",
None, "auto_inventory_accounting"))
if cint(self.doc.auto_inventory_accounting) != previous_auto_inventory_accounting:
from accounts.utils import create_stock_in_hand_jv
create_stock_in_hand_jv(reverse = \
cint(self.doc.auto_inventory_accounting) < previous_auto_inventory_accounting)
def on_update(self):
for key in ["auto_inventory_accounting"]:
webnotes.conn.set_default(key, self.doc.fields.get(key, ''))

View File

@@ -0,0 +1,73 @@
[
{
"creation": "2013-06-24 15:49:57",
"docstatus": 0,
"modified": "2013-06-24 16:12:29",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"description": "Settings for Accounts",
"doctype": "DocType",
"issingle": 1,
"module": "Accounts",
"name": "__common__"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Accounts Settings",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"create": 1,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Accounts Settings",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"role": "Accounts Manager",
"write": 1
},
{
"doctype": "DocType",
"name": "Accounts Settings"
},
{
"description": "If enabled, the system will post accounting entries for inventory automatically.",
"doctype": "DocField",
"fieldname": "auto_inventory_accounting",
"fieldtype": "Check",
"label": "Enable Auto Inventory Accounting"
},
{
"description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.",
"doctype": "DocField",
"fieldname": "acc_frozen_upto",
"fieldtype": "Date",
"label": "Accounts Frozen Upto"
},
{
"description": "Users with this role are allowed to do / modify accounting entry before frozen date",
"doctype": "DocField",
"fieldname": "bde_auth_role",
"fieldtype": "Link",
"label": "Allow Editing of Frozen Accounts For",
"options": "Role"
},
{
"description": "Role that is allowed to submit transactions that exceed credit limits set.",
"doctype": "DocField",
"fieldname": "credit_controller",
"fieldtype": "Link",
"label": "Credit Controller",
"options": "Role"
},
{
"doctype": "DocPerm"
}
]

View File

@@ -2,7 +2,7 @@ test_records = [
[{
"doctype": "Cost Center",
"cost_center_name": "_Test Cost Center",
"parent_cost_center": "Root - _TC",
"parent_cost_center": "_Test Company - _TC",
"company_name": "_Test Company",
"group_or_ledger": "Ledger"
}],

View File

@@ -135,9 +135,9 @@ class DocType:
except authorized person
"""
if not adv_adj:
acc_frozen_upto = webnotes.conn.get_value('Global Defaults', None, 'acc_frozen_upto')
acc_frozen_upto = webnotes.conn.get_value('Accounts Settings', None, 'acc_frozen_upto')
if acc_frozen_upto:
bde_auth_role = webnotes.conn.get_value( 'Global Defaults', None,'bde_auth_role')
bde_auth_role = webnotes.conn.get_value( 'Accounts Settings', None,'bde_auth_role')
if getdate(self.doc.posting_date) <= getdate(acc_frozen_upto) \
and not bde_auth_role in webnotes.user.get_roles():
msgprint(_("You are not authorized to do/modify back dated entries before ") +

View File

@@ -84,6 +84,12 @@ wn.module_page["Accounts"] = [
title: wn._("Setup"),
icon: "icon-cog",
items: [
{
"label": wn._("Accounts Settings"),
"route": "Form/Accounts Settings",
"doctype":"Accounts Settings",
"description": "Settings for Accounts"
},
{
"label": wn._("Sales Taxes and Charges Master"),
"doctype":"Sales Taxes and Charges Master",