fixes in cleanup data

This commit is contained in:
Nabin Hait
2013-03-12 10:41:21 +05:30
parent 29ece5f95b
commit bffbc18b2d
2 changed files with 74 additions and 69 deletions

View File

@@ -724,6 +724,8 @@ class DocType(SellingController):
# expense account gl entries # expense account gl entries
if auto_inventory_accounting and flt(item.buying_amount): if auto_inventory_accounting and flt(item.buying_amount):
self.check_expense_account(item)
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
"account": item.expense_account, "account": item.expense_account,
@@ -813,6 +815,11 @@ class DocType(SellingController):
item_buying_amount = item_buying_rate * flt(item.qty) item_buying_amount = item_buying_rate * flt(item.qty)
return item_buying_amount return item_buying_amount
def check_expense_account(self, item):
if not item.expense_account:
msgprint(_("""Expense account is mandatory for item: """) + item.item_code,
raise_exception=1)
def update_c_form(self): def update_c_form(self):
"""Update amended id in C-form""" """Update amended id in C-form"""

View File

@@ -20,16 +20,14 @@ import webnotes
def delete_transactions(): def delete_transactions():
print "Deleting transactions..." print "Deleting transactions..."
trans = ['Timesheet','Task','Support Ticket','Stock Reconciliation', 'Stock Ledger Entry', \ trans = ['Timesheet', 'Task', 'Support Ticket', 'Stock Reconciliation', 'Stock Ledger Entry',
'Stock Entry','Sales Order','Salary Slip','Sales Invoice','Quotation', 'Quality Inspection', \ 'Stock Entry', 'Sales Order', 'Salary Slip','Sales Invoice', 'Quotation',
'Purchase Receipt','Purchase Order','Production Order', 'POS Setting','Period Closing Voucher', \ 'Quality Inspection', 'Purchase Receipt', 'Purchase Order', 'Production Order',
'Purchase Invoice','Maintenance Visit','Maintenance Schedule','Leave Application', \ 'POS Setting', 'Period Closing Voucher', 'Purchase Invoice', 'Maintenance Visit',
'Leave Allocation', 'Lead', 'Journal Voucher', 'Installation Note','Material Request', \ 'Maintenance Schedule', 'Leave Application', 'Leave Allocation', 'Lead', 'Journal Voucher',
'GL Entry','Expense Claim','Opportunity','Delivery Note','Customer Issue','Bin', \ 'Installation Note', 'Material Request', 'GL Entry', 'Expense Claim', 'Opportunity',
'Authorization Rule','Attendance', 'C-Form', 'Form 16A', 'Lease Agreement', \ 'Delivery Note', 'Customer Issue', 'Bin', 'Authorization Rule', 'Attendance', 'C-Form',
'Lease Installment', 'TDS Payment', 'TDS Return Acknowledgement', 'Appraisal', \ 'Appraisal', 'Installation Note', 'Communication']
'Installation Note', 'Communication'
]
for d in trans: for d in trans:
for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d): for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d):
webnotes.conn.sql("delete from `tab%s`" % (t)) webnotes.conn.sql("delete from `tab%s`" % (t))
@@ -41,55 +39,55 @@ def delete_transactions():
def delete_masters(): def delete_masters():
print "Deleting masters...." print "Deleting masters...."
masters = { masters = {
'Workstation':['Default Workstation'], 'Workstation': ['Default Workstation'],
'Warehouse Type':['Default Warehouse Type', 'Fixed Asset', 'Rejected', 'Reserved', 'Warehouse Type': ['Default Warehouse Type', 'Fixed Asset', 'Rejected', 'Reserved',
'Sample', 'Stores', 'WIP Warehouse'], 'Sample', 'Stores', 'WIP Warehouse'],
'Warehouse':['Default Warehouse'], 'Warehouse': ['Default Warehouse'],
'UOM':['Kg', 'Mtr', 'Box', 'Ltr', 'Nos', 'Ft', 'Pair', 'Set'], 'UOM': ['Kg', 'Mtr', 'Box', 'Ltr', 'Nos', 'Ft', 'Pair', 'Set'],
'Territory':['All Territories', 'Default Territory'], 'Territory': ['All Territories', 'Default Territory'],
'Terms and Conditions':'', 'Terms and Conditions': '',
'Tag':'', 'Tag': '',
'Supplier Type':['Default Supplier Type'], 'Supplier Type': ['Default Supplier Type'],
'Supplier':'', 'Supplier': '',
'Serial No':'', 'Serial No': '',
'Sales Person':['All Sales Persons'], 'Sales Person': ['All Sales Persons'],
'Sales Partner':'', 'Sales Partner': '',
'Sales BOM':'', 'Sales BOM': '',
'Salary Structure':'', 'Salary Structure': '',
'Purchase Taxes and Charges Master':'', 'Purchase Taxes and Charges Master': '',
'Project':'', 'Project': '',
'Print Heading':'', 'Print Heading': '',
'Price List':['Default Price List'], 'Price List': ['Default Price List'],
'Sales Taxes and Charges Master':'', 'Sales Taxes and Charges Master': '',
'Letter Head':'', 'Letter Head': '',
'Leave Type':['Leave Without Pay', 'Privilege Leave', 'Casual Leave', 'PL', 'CL', 'LWP', 'Leave Type': ['Leave Without Pay', 'Privilege Leave', 'Casual Leave', 'PL', 'CL', 'LWP',
'Compensatory Off', 'Sick Leave'], 'Compensatory Off', 'Sick Leave'],
'Appraisal Template':'', 'Appraisal Template': '',
'Item Group':['All Item Groups', 'Default'], 'Item Group': ['All Item Groups', 'Default'],
'Item':'', 'Item': '',
'Holiday List':'', 'Holiday List': '',
'Grade':'', 'Grade': '',
'Feed':'', 'Feed': '',
'Expense Claim Type':['Travel', 'Medical', 'Calls', 'Food', 'Others'], 'Expense Claim Type': ['Travel', 'Medical', 'Calls', 'Food', 'Others'],
'Event':'', 'Event': '',
'Employment Type':'', 'Employment Type': '',
'Employee':'', 'Employee': '',
'Earning Type':['Basic', 'Conveyance', 'House Rent Allowance', 'Dearness Allowance', 'Earning Type': ['Basic', 'Conveyance', 'House Rent Allowance', 'Dearness Allowance',
'Medical Allowance', 'Telephone'], 'Medical Allowance', 'Telephone'],
'Designation':'', 'Designation': '',
'Department':'', 'Department': '',
'Deduction Type':['Income Tax', 'Professional Tax', 'Provident Fund', 'Leave Deduction'], 'Deduction Type': ['Income Tax', 'Professional Tax', 'Provident Fund', 'Leave Deduction'],
'Customer Group':['All Customer Groups', 'Default Customer Group'], 'Customer Group': ['All Customer Groups', 'Default Customer Group'],
'Customer':'', 'Customer': '',
'Cost Center':'', 'Cost Center': '',
'Contact':'', 'Contact': '',
'Campaign':'', 'Campaign': '',
'Budget Distribution':'', 'Budget Distribution': '',
'Brand':'', 'Brand': '',
'Branch':'', 'Branch': '',
'Batch':'', 'Batch': '',
'Appraisal':'', 'Appraisal': '',
'Account':'', 'Account': '',
'BOM': '' 'BOM': ''
} }
for d in masters.keys(): for d in masters.keys():
@@ -115,40 +113,40 @@ def reset_all_series():
def reset_transaction_series(): def reset_transaction_series():
webnotes.conn.sql("""update tabSeries set current = 0 where name in webnotes.conn.sql("""update tabSeries set current = 0 where name in
('JV', 'INV', 'BILL', 'SO', 'DN', 'PO', 'LEAD', 'ENQUIRY', 'ENQ', 'CI', ('JV', 'INV', 'BILL', 'SO', 'DN', 'PO', 'LEAD', 'ENQUIRY', 'ENQ', 'CI',
'IN', 'PS', 'IDT', 'QAI', 'QTN', 'STE', 'SQTN', 'SUP', 'TDSP', 'SR', 'IN', 'PS', 'IDT', 'QAI', 'QTN', 'STE', 'SQTN', 'SUP', 'SR',
'POS', 'LAP', 'LAL', 'EXP')""") 'POS', 'LAP', 'LAL', 'EXP')""")
print "Series updated" print "Series updated"
def delete_main_masters(): def delete_main_masters():
main_masters = ['Fiscal Year','Company', 'DefaultValue'] main_masters = ['Fiscal Year', 'Company', 'DefaultValue']
for d in main_masters: for d in main_masters:
for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d): for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d):
webnotes.conn.sql("delete from `tab%s`" % (t)) webnotes.conn.sql("delete from `tab%s`" % (t))
webnotes.conn.sql("delete from `tab%s`" % (d)) webnotes.conn.sql("delete from `tab%s`" % (d))
print "Deleted " + d print "Deleted " + d
def reset_global_defaults(): def reset_global_defaults():
flds = { flds = {
'default_company': '', 'default_company': None,
'default_currency': '', 'default_currency': None,
'current_fiscal_year': '', 'current_fiscal_year': None,
'date_format': 'dd-mm-yyyy', 'date_format': 'dd-mm-yyyy',
'sms_sender_name': '', 'sms_sender_name': None,
'default_item_group': 'Default', 'default_item_group': 'Default',
'default_stock_uom': 'Nos', 'default_stock_uom': 'Nos',
'default_valuation_method': 'FIFO', 'default_valuation_method': 'FIFO',
'default_warehouse_type': 'Default Warehouse Type', 'default_warehouse_type': 'Default Warehouse Type',
'tolerance': '', 'tolerance': None,
'acc_frozen_upto': '', 'acc_frozen_upto': None,
'bde_auth_role': '', 'bde_auth_role': None,
'credit_controller': '', 'credit_controller': None,
'default_customer_group': 'Default Customer Group', 'default_customer_group': 'Default Customer Group',
'default_territory': 'Default', 'default_territory': 'Default',
'default_price_list': 'Standard', 'default_price_list': 'Standard',
'default_supplier_type': 'Default Supplier Type' 'default_supplier_type': 'Default Supplier Type',
'hide_currency_symbol': None,
'default_price_list_currency': None,
} }
from webnotes.model.code import get_obj from webnotes.model.code import get_obj