merged conflict in gl_control.py

This commit is contained in:
Rushabh Mehta 2011-07-13 14:37:17 +05:30
commit af596344ba
23 changed files with 1517 additions and 664 deletions

View File

@ -21,31 +21,34 @@ class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d,dl
def repost(self):
def repost(self, account = ''):
if not self.doc.company:
msgprint("Please select company", raise_exception=1)
if not in_transaction:
sql("start transaction")
self.clear_account_balances()
self.create_account_balances()
self.update_opening()
self.post_entries()
self.clear_account_balances(account)
self.create_account_balances(account)
self.update_opening(account)
self.post_entries(account)
sql("commit")
msgprint("Account balance reposted")
def clear_account_balances(self):
msg_cond = account and " and account: " + account or ""
msgprint("Account balance reposted for fiscal year: " + self.doc.name + msg_cond)
def clear_account_balances(self, account = ''):
# balances clear - `tabAccount Balance` for fiscal year
sql("update `tabAccount Balance` set opening=0, balance=0, debit=0, credit=0 where fiscal_year=%s", self.doc.name)
cond = account and (" and account = '" + account + "'") or ''
sql("update `tabAccount Balance` set opening=0, balance=0, debit=0, credit=0 where fiscal_year=%s %s", (self.doc.name, cond))
def create_account_balances(self):
def create_account_balances(self, account = ''):
# get periods
period_list = self.get_period_list()
cnt = 0
# get accounts
al = sql("select name from tabAccount")
al = account and [[account]] or sql("select name from tabAccount")
for a in al:
# check
@ -80,9 +83,14 @@ class DocType:
return periods
# ====================================================================================
def update_opening(self):
# set opening from last year closing
abl = sql("select t1.account, t1.balance from `tabAccount Balance` t1, tabAccount t2 where t1.period=%s and t2.company=%s and ifnull(t2.is_pl_account, 'No') = 'No' and t1.account = t2.name for update", (self.doc.past_year, self.doc.company))
def update_opening(self, account = ''):
"""
set opening from last year closing
"""
cond = account and (" and t2.name = '" + account + "'") or ''
abl = sql("select t1.account, t1.balance from `tabAccount Balance` t1, tabAccount t2 where t1.period= '%s' and t2.company= '%s' and ifnull(t2.is_pl_account, 'No') = 'No' and t1.account = t2.name %s for update" % (self.doc.past_year, self.doc.company, cond))
cnt = 0
for ab in abl:
@ -100,10 +108,11 @@ class DocType:
return sql("select debit_or_credit, lft, rgt, is_pl_account from tabAccount where name=%s", account)[0]
# ====================================================================================
def post_entries(self):
def post_entries(self, account = ''):
sql("LOCK TABLE `tabGL Entry` WRITE")
cond = account and (" and account = '" + account + "'") or ''
# post each gl entry (batch or complete)
gle = sql("select name, account, debit, credit, is_opening, posting_date from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled,'No')='No' and company=%s", (self.doc.name, self.doc.company))
gle = sql("select name, account, debit, credit, is_opening, posting_date from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled,'No')='No' and company=%s %s", (self.doc.name, self.doc.company, cond))
account_details = {}
cnt = 0
@ -153,7 +162,6 @@ class DocType:
sql("UNLOCK TABLES")
# Clear PV/RV outstanding
# ====================================================================================
def clear_outstanding(self):

View File

@ -44,11 +44,18 @@ class DocType(TransactionBase):
# Get party details
#------------------
def get_party_det(self):
party_det=sql("Select pan_number, address from `tabAccount` where name = '%s'" % self.doc.party_name)
party_det=sql("select master_type, master_name from `tabAccount` where name='%s'" % self.doc.party_name)
if party_det and party_det[0][0]=='Supplier':
try:
rec = sql("select name, address_line1, address_line2, city, country, pincode, state from `tabAddress` where supplier = '%s' and docstatus != 2 order by is_primary_address desc limit 1" %(party_det[0][1]), as_dict = 1)
address_display = cstr((rec[0]['address_line1'] and rec[0]['address_line1'] or '')) + cstr((rec[0]['address_line2'] and '\n' + rec[0]['address_line2'] or '')) + cstr((rec[0]['city'] and '\n'+rec[0]['city'] or '')) + cstr((rec[0]['pincode'] and '\n' + rec[0]['pincode'] or '')) + cstr((rec[0]['state'] and '\n'+rec[0]['state'] or '')) + cstr((rec[0]['country'] and '\n'+rec[0]['country'] or ''))
except:
address_display = ''
ret = {
'pan_number': cstr(party_det[0][0]) ,
'party_address': cstr(party_det[0][1])
'party_address': cstr(address_display)
}
return cstr(ret)
# Get TDS Return acknowledgement

View File

@ -405,18 +405,23 @@ In Account := %s User := %s has Repaired Outstanding Amount For %s : %s and foll
Find vouchers that are not cancelled correctly and repost them
"""
vl = sql("""
select voucher_type, voucher_no, sum(debit) as sum_debit, sum(credit) as sum_credit
select voucher_type, voucher_no, account, sum(debit) as sum_debit, sum(credit) as sum_credit
from `tabGL Entry`
where is_cancelled='Yes' and creation > %s
group by voucher_type, voucher_no
""", after_date, as_dict=1))
group by voucher_type, voucher_no, account
""", after_date, as_dict=1)
ac_list = []
for v in vl:
if c['sum_debit'] != 0 or c['sum_credit'] != 0:
ac_list += [a[0] for a in sql("""
select distinct account from `tabGL Entry`
where voucher_type=%s and voucher_no = %s
""", (c['voucher_type'], c['voucher_no']))]
if v['sum_debit'] != 0 or v['sum_credit'] != 0:
ac_list.append(v['account'])
fy_list = sql("""select name from `tabFiscal Year`
where (%s between year_start_date and date_sub(date_add(year_start_date,interval 1 year), interval 1 day))
or year_start_date > %s
order by year_start_date ASC""", (after_date, after_date))
for fy in fy_list:
fy_obj = get_obj('Fiscal Year', fy[0])
for a in set(ac_list):
get_obj('Account', a).respost()
fy_obj.repost(a)

View File

@ -179,9 +179,9 @@ class DocType(TransactionBase):
# Check Conversion Rate
# ----------------------
def check_conversion_rate(self):
default_currency = get_obj('Manage Account').doc.default_currency
default_currency = TransactionBase().get_company_currency(self.doc.company)
if not default_currency:
msgprint('Message: Please enter default currency in Manage Account')
msgprint('Message: Please enter default currency in Company Master')
raise Exception
if (self.doc.currency == default_currency and flt(self.doc.conversion_rate) != 1.00) or not self.doc.conversion_rate or (self.doc.currency != default_currency and flt(self.doc.conversion_rate) == 1.00):
msgprint("Message: Please Enter Appropriate Conversion Rate.")

View File

@ -15,9 +15,9 @@ in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType:
class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
@ -268,14 +268,11 @@ class DocType:
# validate conversion rate
def validate_conversion_rate(self, obj):
default_currency = get_obj('Manage Account').doc.default_currency
default_currency = TransactionBase().get_company_currency(obj.doc.company)
if not default_currency:
msgprint('Message: Please enter default currency in Global Defaults')
msgprint('Message: Please enter default currency in Company Master')
raise Exception
company_currency = sql("select default_currency from `tabCompany` where name = '%s'" % obj.doc.company)
curr = company_currency and cstr(company_currency[0][0]) or default_currency
if (obj.doc.currency == curr and flt(obj.doc.conversion_rate) != 1.00) or not obj.doc.conversion_rate or (obj.doc.currency != curr and flt(obj.doc.conversion_rate) == 1.00):
if (obj.doc.currency == default_currency and flt(obj.doc.conversion_rate) != 1.00) or not obj.doc.conversion_rate or (obj.doc.currency != default_currency and flt(obj.doc.conversion_rate) == 1.00):
msgprint("Message: Please Enter Appropriate Conversion Rate.")
raise Exception

View File

@ -91,7 +91,7 @@ def update_feed1(doc):
subject = subject % doc.fields
make_feed(doc, subject, color)
def update_feed(doc, method):
def update_feed(doc, method=None):
"adds a new feed"
if method=='validate':
return

View File

@ -3,16 +3,16 @@
# These values are common in all dictionaries
{
'creation': '2011-02-10 14:10:08',
'creation': '2011-02-17 13:25:56',
'docstatus': 0,
'modified': '2011-02-17 13:44:37',
'modified': '2011-07-08 13:28:15',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1305714022',
'_last_update': '1310019491',
'autoname': 'LAP/.#####',
'colour': 'White:FFF',
'doctype': 'DocType',
@ -24,7 +24,7 @@
'show_in_menu': 0,
'subject': 'From %(employee_name)s, %(designation)s',
'tag_fields': 'leave_type',
'version': 18
'version': 17
},
# These values are common for all DocField
@ -54,37 +54,24 @@
# DocPerm
{
'amend': 1,
'cancel': 1,
'amend': 0,
'cancel': 0,
'create': 1,
'doctype': 'DocPerm',
'idx': 1,
'match': 'owner',
'permlevel': 0,
'submit': 1,
'role': 'Employee',
'submit': 0,
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 2,
'match': 'owner',
'permlevel': 0,
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 3,
'idx': 2,
'permlevel': 0,
'role': 'HR User',
'submit': 1,
@ -97,7 +84,7 @@
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 4,
'idx': 3,
'permlevel': 0,
'role': 'HR Manager',
'submit': 1,
@ -106,24 +93,33 @@
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 5,
'idx': 4,
'permlevel': 1,
'role': 'HR User'
'role': 'HR User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 6,
'idx': 5,
'permlevel': 1,
'role': 'HR Manager'
'role': 'HR Manager',
'submit': 0,
'write': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'column_break1',
'fieldtype': 'Column Break',
'idx': 1,
'permlevel': 0,
@ -211,7 +207,6 @@
# DocField
{
'doctype': 'DocField',
'fieldname': 'column_break8',
'fieldtype': 'Column Break',
'idx': 8,
'permlevel': 0,
@ -275,12 +270,23 @@
'width': '300px'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'letter_head',
'fieldtype': 'Link',
'idx': 14,
'label': 'Letter Head',
'options': 'Letter Head',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'amended_from',
'fieldtype': 'Data',
'idx': 14,
'idx': 15,
'label': 'Amended From',
'permlevel': 1
},
@ -290,7 +296,7 @@
'doctype': 'DocField',
'fieldname': 'amendment_date',
'fieldtype': 'Date',
'idx': 15,
'idx': 16,
'label': 'Amendment Date',
'permlevel': 1
}

292
patches/index_patch.py Normal file
View File

@ -0,0 +1,292 @@
"""
This patch removes wrong indexs and add proper indexes in tables
"""
def create_proper_index():
from webnotes.modules.export_module import export_to_files
dt_index_fields={
'Purchase Receipt Detail': ['prevdoc_docname', 'item_code', 'warehouse', 'prevdoc_detail_docname'],
'Period Closing Voucher': ['closing_account_head', 'fiscal_year'],
'Lead': ['lead_name', 'status', 'transaction_date'],
'Time Sheet Detail': ['app_name'],
'Item Specification Detail': [],
'Budget Detail': ['fiscal_year', 'account'],
'Grade': [],
'RV Tax Detail': ['parenttype', 'account_head'],
'TDS Category Account': ['account_head'],
'Role': [],
'Leave Allocation': ['leave_type', 'employee', 'fiscal_year'],
'Branch': [],
'Department': [],
'Contact Detail': [],
'Territory': ['lft', 'rgt', 'parent_territory'],
'Item Tax': ['tax_type'],
'Bin': ['warehouse', 'item_code'],
'PPW Detail': ['warehouse'],
'Sales Partner': ['partner_name'],
'Default Home Page': ['home_page', 'role'],
'Custom Field': ['dt'],
'DocFormat': ['format'],
'DocType Mapper': ['from_doctype', 'to_doctype'],
'Brand': [],
'Order Lost Reason': [],
'Journal Voucher': ['posting_date', 'voucher_type'],
'TDS Return Acknowledgement': ['date_of_receipt', 'acknowledgement'],
'BOM Report Detail': ['item_code'],
'Quotation Detail': ['item_code'],
'Update Delivery Date Detail': ['sales_order_no'],
'Advance Adjustment Detail': ['journal_voucher'],
'Authorization Rule': ['approving_user', 'system_user', 'system_role', 'approving_role'],
'DocPerm': ['permlevel', 'role'],
'Stock Entry Detail': ['item_code', 't_warehouse', 's_warehouse'],
'Stock Entry': ['posting_date', 'delivery_note_no', 'purchase_receipt_no', 'production_order'],
'Price List': [],
'KRA Sheet': [],
'Production Order': ['status', 'project_name', 'production_item'],
'Account': ['lft', 'rgt', 'parent_account'],
'Earn Deduction Detail': [],
'Indent': ['status', 'transaction_date'],
'Tag Detail': [],
'SS Deduction Detail': ['d_type'],
'Batch': ['item'],
'Deduction Type': [],
'Project': ['project_name', 'customer'],
'UserRole': ['role'],
'DocField': ['label', 'fieldtype', 'fieldname'],
'Property Setter': ['doc_type', 'doc_name', 'property'],
'Appraisal': ['status', 'employee'],
'Letter Head': [],
'Follow up': ['follow_up_by'],
'Project Cost Breakup': [],
'Table Mapper Detail': [],
'Campaign': [],
'Static Parameter Detail': [],
'Leave Type': [],
'Account Balance': ['period', 'start_date', 'end_date', 'account'],
'Absent Days Detail': [],
'Tag': [],
'Raw Materials Supplied': ['raw_material'],
'Project Activity Update': [],
'PR Raw Material Detail': [],
'Bank Reconciliation Detail': ['voucher_id'],
'Sales Order': ['quotation_no', 'project_name', 'customer', 'posting_date'],
'Chapter VI A Detail': [],
'Experience In Company Detail': [],
'Order Reconciliation Detail': ['sales_order_no'],
'Attendance': ['employee', 'att_date'],
'Previous Experience Detail': [],
'Earning Detail': ['e_type'],
'Sales Order Detail': ['item_code', 'prevdoc_docname', 'reserved_warehouse'],
'KRA Template': [],
'Budget Distribution': ['fiscal_year'],
'Workstation': ['warehouse'],
'Period': [],
'Training Session Details': [],
'Other Charges': [],
'State': [],
'Bulk Rename Tool': [],
'Landed Cost Master Detail': [],
'Employee': ['employee_name', 'designation', 'department'],
'Terms And Conditions': [],
'TC Detail': [],
'UOM': [],
'Supplier Type': [],
'Project Milestone': [],
'Landed Cost Master': [],
'Budget Distribution Detail': [],
'Form 16A Ack Detail': [],
'Campaign Expense': [],
'Time Sheet': ['employee_name', 'time_sheet_date'],
'File Group': ['parent_group'],
'Maintenance Visit Detail': ['item_code', 'service_person'],
'Support Ticket Response': [],
'PV Detail': ['item_code', 'purchase_order', 'po_detail', 'purchase_receipt', 'pr_detail', 'expense_head', 'cost_center'],
'Timesheet Detail': ['project_name', 'task_id', 'customer_name'],
'Holiday List Detail': [],
'Workflow Rule Detail': [],
'Module Def': ['module_seq', 'module_page'],
'Term': [],
'PF Detail': ['item_code'],
'POS Setting': ['user', 'territory'],
'QA Specification Detail': [],
'Support Ticket': ['customer', 'allocated_to', 'status'],
'Project Activity': ['project'],
'Customer Group': ['lft', 'rgt', 'parent_customer_group'],
'Return Detail': ['item_code'],
'Series Detail': [],
'Event Role': ['role'],
'Contact': ['employee_id'],
'BOM Material': ['item_code', 'bom_no'],
'Invest 80 Declaration Detail': [],
'PO Raw Material Detail': [],
'Industry Type': [],
'Declaration Detail': [],
'Holiday List': ['fiscal_year'],
'Sales Person': ['lft', 'rgt', 'parent_sales_person'],
'RV Detail': ['item_code', 'sales_order', 'so_detail', 'delivery_note', 'dn_detail', 'cost_center', 'income_account'],
'Module Def Item': [],
'TDS Category': [],
'DocTrigger': [],
'Print Format': ['standard'],
'Installed Item Details': ['prevdoc_docname', 'item_code'],
'Form 16A Tax Detail': [],
'Event': ['event_date', 'event_type'],
'Currency': [],
'Service Quotation Detail': ['item_code'],
'Warehouse Type': ['warehouse_type'],
'Sales BOM': ['item_group'],
'IT Checklist': ['employee'],
'Purchase Other Charges': [],
'Company': [],
'Call Log': [],
'Professional Training Details': [],
'Warehouse': ['warehouse_type'],
'Competitor': [],
'Mode of Payment': [],
'Training Session': ['customer'],
'Cost Center': ['lft', 'rgt', 'parent_cost_center'],
'Timesheet': ['status', 'timesheet_date'],
'Form 16A': ['party_no'],
'Sales BOM Detail': ['item_code'],
'Answer': ['question'],
'Supplier': [],
'Installation Note': ['delivery_note_no', 'customer', 'inst_date'],
'Expense Voucher': ['approval_status', 'employee'],
'Target Detail': ['from_date', 'to_date', 'fiscal_year'],
'Page Role': ['role'],
'Partner Target Detail': ['fiscal_year', 'item_group'],
'Shipping Address': ['customer'],
'Indent Detail': ['item_code', 'warehouse'],
'TDS Payment Detail': [],
'Market Segment': [],
'Comment Widget Record': [],
'Service Order Detail': ['item_code', 'prevdoc_docname'],
'TDS Payment': ['from_date', 'to_date', 'tds_category'],
'Lead Email CC Detail': [],
'User Setting-Role User': [],
'Salary Slip': ['month', 'year', 'employee'],
'Maintenance Schedule Detail': ['item_code', 'scheduled_date'],
'Employment Type': [],
'Advance Allocation Detail': ['journal_voucher'],
'Quotation': ['customer', 'transaction_date'],
'Deduction Detail': ['d_type'],
'Bill Of Materials': ['item', 'project_name'],
'Earning Type': [],
'Designation': [],
'BOM Replace Utility Detail': ['parent_bom'],
'Question': [],
'Stock Ledger Entry': ['item_code', 'warehouse', 'posting_date', 'posting_time'],
'Educational Qualifications Detail': [],
'BOM Operation': [],
'Item Group': ['lft', 'rgt', 'parent_item_group'],
'Workflow Action Detail': [],
'User Setting-Profile': [],
'Customer Issue': ['item_code', 'customer', 'complaint_date'],
'Feed': [],
'Purchase Tax Detail': ['account_head'],
'GL Mapper Detail': [],
'TDS Detail': [],
'PRO Detail': ['item_code', 'source_warehouse'],
'DocType Label': [],
'Receivable Voucher': ['posting_date', 'debit_to', 'project_name'],
'GL Entry': ['posting_date', 'account', 'voucher_no'],
'Serial No': ['status', 'warehouse'],
'Delivery Note': ['posting_date', 'project_name', 'customer'],
'UOM Conversion Detail': ['uom'],
'Search Criteria': ['criteria_name'],
'Salary Structure': [],
'Educational Qualifications': ['qualification'],
'TDS Rate Chart': ['applicable_from', 'applicable_to'],
'GL Mapper': [],
'Announcement': [],
'Call Log Details': [],
'Enquiry': ['lead', 'customer', 'transaction_date'],
'Flat BOM Detail': ['item_code'],
'Landed Cost Detail': ['account_head'],
'Field Mapper Detail': ['from_field', 'to_field'],
'File Data': [],
'Question Tag': [],
'QA Inspection Report': ['item_code', 'purchase_receipt_no', 'report_date'],
'Appraisal Detail': [],
'POS Settings': ['territory'],
'Delivery Note Detail': ['item_code', 'prevdoc_docname', 'warehouse', 'prevdoc_detail_docname'],
'Profile': [],
'Other Income Detail': [],
'Product': ['item_code', 'stock_warehouse'],
'PO Detail': ['prevdoc_docname', 'item_code', 'prevdoc_detail_docname', 'warehouse'],
'Module Def Role': ['role'],
'Sales Team': ['sales_person'],
'Enquiry Detail': ['item_code'],
'DocType': [],
'Compaint Note': ['nature_of_complaint', 'compliance_date'],
'Maintenance Schedule': ['customer', 'sales_order_no'],
'Event User': ['person'],
'Stock Reconciliation': ['reconciliation_date'],
'Purchase Receipt': ['posting_date', 'supplier', 'project_name'],
'Complaint Detail': ['item_name'],
'Address': ['customer', 'supplier'],
'Ticket': ['request_date', 'allocated_to', 'category', 'customer', 'project'],
'Territory Target Detail': ['month', 'fiscal_year'],
'LC PR Detail': ['purchase_receipt_no'],
'Customer': ['customer_name', 'customer_group'],
'PP SO Detail': [],
'PP Detail': ['document_date', 'item_code', 'parent_item'],
'User Setting-Role Permission': [],
'Custom Script': ['dt'],
'Country': [],
'DefaultValue': [],
'Ledger Detail': [],
'SS Earning Detail': ['e_type'],
'SMS Log': [],
'Expense Type': [],
'Item': ['item_group'],
'Fiscal Year': [],
'ToDo Item': ['role'],
'Payable Voucher': ['posting_date', 'credit_to', 'project_name', 'supplier'],
'Journal Voucher Detail': ['account', 'against_voucher', 'against_invoice', 'against_jv'],
'Online Contact': [],
'Page': ['module'],
'Leave Application': ['employee', 'leave_type', 'from_date', 'to_date'],
'Expense Voucher Detail': ['expense_type'],
'Maintenance Visit': ['customer', 'sales_order_no', 'customer_issue_no'],
'Ref Rate Detail': ['price_list_name', 'ref_currency'],
'Receiver Detail': [],
'Naming Series Options': ['doc_type'],
'Activity Type': [],
'PRO PP Detail': [],
'Delivery Note Packing Detail': ['item_code', 'parent_item', 'warehouse'],
'Workflow Rule': ['select_form'],
'File': ['file_group'],
'Item Maintenance Detail': ['item_code', 'start_date', 'end_date', 'prevdoc_docname'],
'Purchase Order': ['supplier', 'project_name', 'posting_date'],
'Print Heading': [],
'TDS Rate Detail': ['category']
}
for dt in dt_index_fields.keys():
current_index = sql("show indexes from `tab%s`" % dt)
proper_index = dt_index_fields[dt]
for d in current_index:
if d[4] not in ['name', 'parent', 'parenttype']:
if d[4] not in proper_index:
sql("ALTER TABLE `tab%s` DROP INDEX %s" % (dt, d[4]))
sql("start transaction")
sql("UPDATE `tabDocField` SET search_index = 0 WHERE fieldname = '%s' AND parent = '%s'" % (d[4], dt))
sql("commit")
else:
proper_index.remove(d[4])
for d in proper_index:
sql("ALTER TABLE `tab%s` ADD INDEX ( `%s` ) " % (dt, d))
sql("start transaction")
sql("UPDATE `tabDocField` SET search_index = 1 WHERE fieldname = '%s' AND parent = '%s'" % (d, dt))
sql("commit")
sql("start transaction")
dt_module = sql("select module from `tabDocType` where name = '%s'" % dt)[0][0]
export_to_files(record_list = [['DocType', dt]], record_module = dt_module)
sql("commit")

View File

@ -1,7 +1,7 @@
# REMEMBER to update this
# ========================
last_patch = 315
last_patch = 323
#-------------------------------------------
@ -1271,3 +1271,21 @@ def execute(patch_no):
m.parenttype = 'Module Def'
m.parentfield = 'roles'
m.save(1)
elif patch_no == 316:
pass
elif patch_no == 317:
sql("update `tabPage` set name = 'profile-settings' where page_name = 'Profile Settings'")
elif patch_no == 318:
reload_doc('utilities', 'doctype', 'bulk_rename_tool')
elif patch_no == 319:
sql("delete from tabFeed where doc_name like 'New %'")
elif patch_no == 320:
reload_doc('setup', 'doctype', 'series_detail')
elif patch_no == 321:
reload_doc('hr','doctype','leave_application')
elif patch_no == 322:
sql("delete from `tabDocField` where parent = 'Leave Application' and fieldname = 'latter_head'")
elif patch_no == 323:
reload_doc('stock', 'doctype', 'stock_entry')
sql("update `tabDocField` set options = 'get_stock_and_rate' where parent = 'Stock Entry' and label = 'Get Stock and Rate'")
sql("delete from `tabDocField` where label = 'Get Current Stock' and parent = 'Stock Entry'")

View File

@ -15,8 +15,9 @@ convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType:
class DocType(TransactionBase):
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
@ -262,10 +263,11 @@ class DocType:
# Check Conversion Rate (i.e. it will not allow conversion rate to be 1 for Currency other than default currency set in Global Defaults)
# ===========================================================================
def check_conversion_rate(self, obj):
default_currency = get_obj('Manage Account').doc.default_currency
company_currency = sql("select default_currency from `tabCompany` where name = '%s'" % obj.doc.company)
curr = company_currency and cstr(company_currency[0][0]) or default_currency
if (obj.doc.currency == curr and flt(obj.doc.conversion_rate) != 1.00) or not obj.doc.conversion_rate or (obj.doc.currency != curr and flt(obj.doc.conversion_rate) == 1.00):
default_currency = TransactionBase().get_company_currency(obj.doc.company)
if not default_currency:
msgprint('Message: Please enter default currency in Company Master')
raise Exception
if (obj.doc.currency == default_currency and flt(obj.doc.conversion_rate) != 1.00) or not obj.doc.conversion_rate or (obj.doc.currency != default_currency and flt(obj.doc.conversion_rate) == 1.00):
msgprint("Please Enter Appropriate Conversion Rate.")
raise Exception

View File

View File

@ -0,0 +1,63 @@
# DocType, Series Detail
[
# These values are common in all dictionaries
{
'creation': '2011-07-08 13:20:10',
'docstatus': 0,
'modified': '2011-07-08 13:20:34',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'colour': 'White:FFF',
'doctype': 'DocType',
'istable': 1,
'module': 'Setup',
'name': '__common__',
'section_style': 'Tray',
'show_in_menu': 0,
'version': 3
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Series Detail',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# DocType, Series Detail
{
'doctype': 'DocType',
'name': 'Series Detail'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'series',
'fieldtype': 'Read Only',
'idx': 1,
'label': 'Series',
'oldfieldname': 'series',
'oldfieldtype': 'Read Only'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'remove',
'fieldtype': 'Check',
'idx': 2,
'label': 'Remove',
'oldfieldname': 'remove',
'oldfieldtype': 'Check',
'trigger': 'Client'
}
]

View File

@ -57,7 +57,8 @@ class DocType:
# Company
master_dict = {'Company':{'company_name':company_name,
'abbr':comp_abbr
'abbr':comp_abbr,
'default_currency':currency
}}
self.create_records(master_dict)
@ -73,7 +74,9 @@ class DocType:
'pr_required':'No',
'emp_created_by':'Naming Series',
'cust_master_name':'Customer Name',
'supp_master_name':'Supplier Name'}
'supp_master_name':'Supplier Name',
'default_currency_format': (currency=='INR') and 'Lacs' or 'Millions'
}
# Set
self.set_defaults(def_args)

View File

@ -1,6 +1,18 @@
cur_frm.cscript.refresh = function(doc) {
if(cint(doc.is_local) && doc.has_serial_no) set_field_permlevel('has_serial_no', 1);
if(cint(doc.is_local) && doc.is_stock_item) set_field_permlevel('is_stock_item', 1);
// make sensitive fields(has_serial_no, is_stock_item, valuation_method)
// read only if any stock ledger entry exists
if ((!doc.__islocal) && (doc.is_stock_item == 'Yes')) {
var callback = function(r, rt) {
if (r.message == 'exists') permlevel = 1;
else permlevel = 0;
set_field_permlevel('has_serial_no', permlevel);
set_field_permlevel('is_stock_item', permlevel);
set_field_permlevel('valuation_method', permlevel);
}
$c_obj(make_doclist(doc.doctype, doc.name),'check_if_sle_exists','',callback);
}
}

View File

@ -170,3 +170,11 @@ Total Available Qty: %s
}
return str(ret)
def check_if_sle_exists(self):
"""
checks if any stock ledger entry exists for this item
"""
sle = sql("select name from `tabStock Ledger Entry` where item_code = %s and ifnull(is_cancelled, 'No') = 'No'", self.doc.name)
return sle and 'exists' or 'not exists'

View File

@ -140,7 +140,8 @@ class DocType(TransactionBase):
self.check_for_stopped_status(pc_obj)
# get total in words
self.doc.in_words = pc_obj.get_total_in_words(get_defaults().get('currency') or 'INR', self.doc.grand_total)
dcc = TransactionBase().get_company_currency(self.doc.company)
self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
# update valuation rate
self.update_valuation_rate()

View File

@ -250,9 +250,9 @@ class DocType:
if self.doc.production_order:
pro_obj = get_obj('Production Order', self.doc.production_order)
self.validate_for_production_order(pro_obj)
self.get_stock_and_rate(pro_obj and pro_obj.doc.bom_no or '')
self.validate_incoming_rate()
self.validate_warehouse(pro_obj)
self.get_stock_and_rate(pro_obj and pro_obj.doc.bom_no or '')
self.calc_amount()
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:25',
'creation': '2009-05-12 16:46:45',
'docstatus': 0,
'modified': '2011-06-14 12:50:12',
'modified': '2011-07-10 14:12:39',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
@ -13,17 +13,33 @@
# These values are common for all DocType
{
'_last_update': '1308741898',
'allow_attach': 0,
'allow_copy': 0,
'allow_email': 0,
'allow_print': 0,
'allow_rename': 0,
'allow_trash': 0,
'colour': 'White:FFF',
'doctype': 'DocType',
'hide_heading': 0,
'hide_toolbar': 0,
'in_create': 0,
'in_dialog': 0,
'is_transaction_doc': 0,
'issingle': 0,
'max_attachments': 0,
'module': 'Stock',
'name': '__common__',
'print_outline': 'No',
'read_only': 0,
'read_only_onload': 0,
'search_fields': 'transfer_date, from_warehouse, to_warehouse, purpose, remarks',
'section_style': 'Tabbed',
'server_code_error': ' ',
'show_in_menu': 0,
'subject': '%(remarks)s',
'tag_fields': 'purpose',
'use_template': 0,
'version': 243
},
@ -60,7 +76,7 @@
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 0,
'role': 'Material Manager',
'role': 'Material User',
'submit': 1,
'write': 1
},
@ -73,35 +89,28 @@
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 1,
'role': 'Material Manager',
'role': 'Material User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'create': 0,
'doctype': 'DocPerm',
'idx': 3,
'permlevel': 0,
'role': 'Material User',
'submit': 1,
'permlevel': 2,
'role': 'Production User',
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 4,
'permlevel': 1,
'role': 'Material User',
'submit': 0,
'write': 0
'permlevel': 2,
'role': 'Production Manager',
'write': 1
},
# DocPerm
@ -125,23 +134,13 @@
'role': 'Production User'
},
# DocPerm
{
'create': 0,
'doctype': 'DocPerm',
'idx': 7,
'permlevel': 2,
'role': 'Production User',
'write': 1
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 8,
'idx': 7,
'permlevel': 0,
'role': 'Production Manager',
'submit': 1,
@ -151,17 +150,34 @@
# DocPerm
{
'doctype': 'DocPerm',
'idx': 9,
'idx': 8,
'permlevel': 1,
'role': 'Production Manager'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 9,
'permlevel': 1,
'role': 'Material Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 10,
'permlevel': 2,
'role': 'Production Manager',
'permlevel': 0,
'role': 'Material Manager',
'submit': 1,
'write': 1
},
@ -187,85 +203,114 @@
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'description': 'To manage multiple series please go to Setup > Manage Series',
'doctype': 'DocField',
'fieldname': 'naming_series',
'fieldtype': 'Select',
'hidden': 0,
'idx': 3,
'in_filter': 0,
'label': 'Series',
'no_copy': 1,
'oldfieldname': 'naming_series',
'oldfieldtype': 'Select',
'options': 'STE',
'options': '\nSTE',
'permlevel': 0,
'print_hide': 1,
'reqd': 1
'report_hide': 0,
'reqd': 1,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'description': 'The date at which current entry is corrected in the system.',
'doctype': 'DocField',
'fieldname': 'amendment_date',
'fieldtype': 'Date',
'hidden': 0,
'idx': 4,
'in_filter': 0,
'label': 'Amendment Date',
'no_copy': 1,
'oldfieldname': 'amendment_date',
'oldfieldtype': 'Date',
'permlevel': 0,
'print_hide': 1
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'purpose',
'fieldtype': 'Select',
'hidden': 0,
'idx': 5,
'in_filter': 1,
'label': 'Purpose',
'no_copy': 0,
'oldfieldname': 'purpose',
'oldfieldtype': 'Select',
'options': 'Material Issue\nMaterial Receipt\nMaterial Transfer\nSales Return\nPurchase Return\nSubcontracting\nProduction Order',
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 1,
'search_index': 0,
'trigger': 'Client'
},
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'delivery_note_no',
'fieldtype': 'Link',
'hidden': 1,
'idx': 6,
'in_filter': 0,
'label': 'Delivery Note No',
'no_copy': 0,
'oldfieldname': 'delivery_note_no',
'oldfieldtype': 'Link',
'options': 'Delivery Note',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': 'Client'
},
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'purchase_receipt_no',
'fieldtype': 'Link',
'hidden': 1,
'idx': 7,
'in_filter': 0,
'label': 'Purchase Receipt No',
'no_copy': 0,
'oldfieldname': 'purchase_receipt_no',
'oldfieldtype': 'Link',
'options': 'Purchase Receipt',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': 'Client'
},
@ -284,93 +329,135 @@
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'supplier',
'fieldtype': 'Link',
'hidden': 1,
'idx': 9,
'in_filter': 0,
'label': 'Supplier',
'no_copy': 0,
'oldfieldname': 'supplier',
'oldfieldtype': 'Link',
'options': 'Supplier',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': 'Client'
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'supplier_name',
'fieldtype': 'Data',
'hidden': 0,
'idx': 10,
'in_filter': 0,
'label': 'Supplier Name',
'no_copy': 0,
'oldfieldname': 'supplier_name',
'oldfieldtype': 'Data',
'permlevel': 1
'permlevel': 1,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'supplier_address',
'fieldtype': 'Small Text',
'hidden': 1,
'idx': 11,
'in_filter': 0,
'label': 'Supplier Address',
'no_copy': 0,
'oldfieldname': 'supplier_address',
'oldfieldtype': 'Small Text',
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': 'Client'
},
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'customer',
'fieldtype': 'Link',
'hidden': 1,
'idx': 12,
'in_filter': 0,
'label': 'Customer',
'no_copy': 0,
'oldfieldname': 'customer',
'oldfieldtype': 'Link',
'options': 'Customer',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': 'Client'
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'customer_name',
'fieldtype': 'Data',
'hidden': 1,
'idx': 13,
'in_filter': 0,
'label': 'Customer Name',
'no_copy': 0,
'oldfieldname': 'customer_name',
'oldfieldtype': 'Data',
'permlevel': 1
'permlevel': 1,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'customer_address',
'fieldtype': 'Small Text',
'hidden': 1,
'idx': 14,
'in_filter': 0,
'label': 'Customer Address',
'no_copy': 0,
'oldfieldname': 'customer_address',
'oldfieldtype': 'Small Text',
'permlevel': 0
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'process',
@ -379,16 +466,21 @@
'idx': 15,
'in_filter': 1,
'label': 'Process',
'no_copy': 0,
'oldfieldname': 'process',
'oldfieldtype': 'Select',
'options': '\nMaterial Transfer\nBackflush',
'permlevel': 2,
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': 'Client'
},
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'production_order',
@ -397,25 +489,36 @@
'idx': 16,
'in_filter': 1,
'label': 'Production Order',
'no_copy': 0,
'oldfieldname': 'production_order',
'oldfieldtype': 'Link',
'options': 'Production Order',
'permlevel': 2,
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': 'Client'
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'fg_completed_qty',
'fieldtype': 'Currency',
'hidden': 0,
'idx': 17,
'in_filter': 0,
'label': 'FG Completed Qty',
'no_copy': 0,
'oldfieldname': 'fg_completed_qty',
'oldfieldtype': 'Currency',
'permlevel': 2,
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': 'Client'
},
@ -424,47 +527,59 @@
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldtype': 'HTML',
'hidden': 0,
'idx': 18,
'label': 'Warehouse HTML',
'no_copy': 0,
'oldfieldtype': 'HTML',
'options': "<div class='columnHeading'>Warehouse</div>",
'permlevel': 0,
'print_hide': 1
'print_hide': 1,
'reqd': 0
},
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'from_warehouse',
'fieldtype': 'Link',
'hidden': 0,
'idx': 19,
'in_filter': 0,
'label': 'Source Warehouse',
'no_copy': 0,
'oldfieldname': 'from_warehouse',
'oldfieldtype': 'Link',
'options': 'Warehouse',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': 'Client'
},
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'description': '<b>Notes:</b> Either Source or Target is Mandatory',
'doctype': 'DocField',
'fieldname': 'to_warehouse',
'fieldtype': 'Link',
'hidden': 0,
'idx': 20,
'in_filter': 0,
'label': 'Target Warehouse',
'no_copy': 0,
'oldfieldname': 'to_warehouse',
'oldfieldtype': 'Link',
'options': 'Warehouse',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 1,
'trigger': 'Client'
@ -473,8 +588,22 @@
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'fieldname': 'project_name',
'fieldtype': 'Link',
'idx': 21,
'in_filter': 1,
'label': 'Project Name',
'oldfieldname': 'project_name',
'oldfieldtype': 'Link',
'options': 'Project',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 22,
'oldfieldtype': 'Column Break',
'permlevel': 0,
'width': '50%'
@ -482,11 +611,13 @@
# DocField
{
'allow_on_submit': 0,
'default': 'Today',
'doctype': 'DocField',
'fieldname': 'transfer_date',
'fieldtype': 'Date',
'idx': 22,
'hidden': 0,
'idx': 23,
'in_filter': 1,
'label': 'Transfer Date',
'no_copy': 1,
@ -494,17 +625,20 @@
'oldfieldtype': 'Date',
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 1,
'search_index': 1
},
# DocField
{
'allow_on_submit': 0,
'description': 'The date at which current entry will get or has actually executed.',
'doctype': 'DocField',
'fieldname': 'posting_date',
'fieldtype': 'Date',
'idx': 23,
'hidden': 0,
'idx': 24,
'in_filter': 1,
'label': 'Posting Date',
'no_copy': 1,
@ -512,16 +646,19 @@
'oldfieldtype': 'Date',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 1,
'search_index': 1
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'posting_time',
'fieldtype': 'Time',
'idx': 24,
'hidden': 0,
'idx': 25,
'in_filter': 0,
'label': 'Posting Time',
'no_copy': 1,
@ -529,103 +666,143 @@
'oldfieldtype': 'Time',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 1,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'amended_from',
'fieldtype': 'Link',
'idx': 25,
'hidden': 0,
'idx': 26,
'in_filter': 0,
'label': 'Amended From',
'no_copy': 1,
'oldfieldname': 'amended_from',
'oldfieldtype': 'Link',
'options': 'Stock Entry',
'permlevel': 1,
'print_hide': 1
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'transporter',
'fieldtype': 'Data',
'idx': 26,
'hidden': 0,
'idx': 27,
'in_filter': 0,
'label': 'Transporter',
'no_copy': 0,
'oldfieldname': 'transporter',
'oldfieldtype': 'Data',
'permlevel': 0,
'print_hide': 1
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'is_excisable_goods',
'fieldtype': 'Select',
'idx': 27,
'hidden': 0,
'idx': 28,
'in_filter': 0,
'label': 'Is Excisable Goods',
'no_copy': 0,
'oldfieldname': 'is_excisable_goods',
'oldfieldtype': 'Select',
'options': '\nYes\nNo',
'permlevel': 0,
'print_hide': 1
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'excisable_goods',
'fieldtype': 'Select',
'idx': 28,
'hidden': 0,
'idx': 29,
'in_filter': 0,
'label': 'Excisable Goods',
'no_copy': 0,
'oldfieldname': 'excisable_goods',
'oldfieldtype': 'Select',
'options': '\nReturnable\nNon-Returnable',
'permlevel': 0,
'print_hide': 1
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'under_rule',
'fieldtype': 'Select',
'hidden': 1,
'idx': 29,
'idx': 30,
'in_filter': 0,
'label': 'Under Rule',
'no_copy': 0,
'oldfieldname': 'under_rule',
'oldfieldtype': 'Select',
'options': '\nOrdinary\n57 AC (5) a\n57 F (2) Non-Exc.',
'permlevel': 0,
'print_hide': 1
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'remarks',
'fieldtype': 'Text',
'idx': 30,
'hidden': 0,
'idx': 31,
'in_filter': 0,
'label': 'Remarks',
'no_copy': 1,
'oldfieldname': 'remarks',
'oldfieldtype': 'Text',
'permlevel': 0,
'print_hide': 1,
'reqd': 1
'report_hide': 0,
'reqd': 1,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'cancel_reason',
'fieldtype': 'Data',
'hidden': 1,
'idx': 31,
'idx': 32,
'in_filter': 0,
'label': 'Cancel Reason',
'no_copy': 1,
@ -633,6 +810,7 @@
'oldfieldtype': 'Data',
'permlevel': 1,
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
@ -641,7 +819,7 @@
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 32,
'idx': 33,
'label': 'Items',
'oldfieldtype': 'Section Break',
'permlevel': 0
@ -651,7 +829,7 @@
{
'doctype': 'DocField',
'fieldtype': 'Button',
'idx': 33,
'idx': 34,
'label': 'Get Stock and Rate',
'oldfieldtype': 'Button',
'options': 'get_stock_and_rate',
@ -659,34 +837,59 @@
'print_hide': 1
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldtype': 'Button',
'hidden': 0,
'idx': 35,
'in_filter': 0,
'label': 'Get Current Stock',
'no_copy': 0,
'oldfieldtype': 'Button',
'options': 'get_stock_and_rate',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 34,
'idx': 36,
'oldfieldtype': 'Column Break',
'permlevel': 0
},
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldtype': 'Button',
'hidden': 0,
'idx': 35,
'idx': 37,
'in_filter': 0,
'label': 'Get Items',
'no_copy': 0,
'oldfieldtype': 'Button',
'options': 'get_items',
'permlevel': 2,
'print_hide': 1
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 36,
'idx': 38,
'oldfieldtype': 'Section Break',
'options': 'Simple',
'permlevel': 0
@ -694,37 +897,51 @@
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'mtn_details',
'fieldtype': 'Table',
'idx': 37,
'hidden': 0,
'idx': 39,
'in_filter': 0,
'label': 'MTN Details',
'no_copy': 0,
'oldfieldname': 'mtn_details',
'oldfieldtype': 'Table',
'options': 'Stock Entry Detail',
'permlevel': 0,
'print_hide': 0
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'total_amount',
'fieldtype': 'Currency',
'idx': 38,
'hidden': 0,
'idx': 40,
'in_filter': 0,
'label': 'Total Amount',
'no_copy': 0,
'oldfieldname': 'total_amount',
'oldfieldtype': 'Currency',
'permlevel': 1,
'print_hide': 1
'print_hide': 1,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 39,
'idx': 41,
'label': 'Other Details',
'oldfieldtype': 'Section Break',
'permlevel': 0
@ -732,48 +949,64 @@
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'company',
'fieldtype': 'Link',
'idx': 40,
'hidden': 0,
'idx': 42,
'in_filter': 1,
'label': 'Company',
'no_copy': 0,
'oldfieldname': 'company',
'oldfieldtype': 'Link',
'options': 'Company',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 1,
'search_index': 1
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'fiscal_year',
'fieldtype': 'Select',
'idx': 41,
'hidden': 0,
'idx': 43,
'in_filter': 0,
'label': 'Fiscal Year',
'no_copy': 0,
'oldfieldname': 'fiscal_year',
'oldfieldtype': 'Select',
'options': 'link:Fiscal Year',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 1,
'search_index': 1
},
# DocField
{
'allow_on_submit': 0,
'doctype': 'DocField',
'fieldname': 'select_print_heading',
'fieldtype': 'Link',
'idx': 42,
'hidden': 0,
'idx': 44,
'in_filter': 0,
'label': 'Select Print Heading',
'no_copy': 0,
'oldfieldname': 'select_print_heading',
'oldfieldtype': 'Link',
'options': 'Print Heading',
'permlevel': 0
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
}
]

View File

@ -35,7 +35,7 @@ class SupportMailbox(POP3Mailbox):
st = get_obj('Support Ticket', thread_id)
st.make_response_record(content, mail.mail['From'], content_type)
webnotes.conn.set(st.doc, 'status', 'To Reply')
webnotes.conn.set(st.doc, 'status', 'Open')
update_feed(st.doc)
return
@ -62,3 +62,9 @@ def get_support_mails():
Gets new emails from support inbox and updates / creates Support Ticket records
"""
SupportMailbox().get_messages()
def auto_close_tickets():
"""
Auto Closes Waiting for Customer Support Ticket after 15 days
"""
webnotes.conn.sql("update `tabSupport Ticket` set status = 'Closed' where status = 'Waiting for Customer' and date_sub(curdate(),interval 15 Day) > modified")

View File

@ -0,0 +1,82 @@
# Please edit this list and import only required elements
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
from webnotes.model.doclist import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, is_testing, msgprint, errprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
# bulk rename
def do_rename(self):
import csv
data = csv.reader(self.get_csv_data().splitlines())
updated = 0
msgprint(self.doc.rename_doctype)
if self.doc.rename_doctype == 'Account':
for line in data:
if len(line)==2:
rec = sql("select tc.abbr, ta.name from `tabAccount` ta, `tabCompany` tc where ta.company = tc.name and ta.account_name = %s", line[0], as_dict=1)
if rec:
new_name = line[1] + ' - ' + rec[0]['abbr']
webnotes.conn.begin()
webnotes.model.rename(self.doc.rename_doctype, rec[0]['name'], new_name)
sql("update `tabAccount` set account_name = '%s' where name = '%s'" %(line[1],new_name))
webnotes.conn.commit()
updated += 1
else:
msgprint("[Ignored] Incorrect format: %s" % str(line))
else:
for line in data:
if len(line)==2:
webnotes.conn.begin()
obj = get_obj(self.doc.rename_doctype, line[0])
if hasattr(obj, 'on_rename'):
obj.on_rename(line[1],line[0])
webnotes.model.rename(self.doc.rename_doctype, line[0], line[1])
webnotes.conn.commit()
updated += 1
else:
msgprint("[Ignored] Incorrect format: %s" % str(line))
msgprint("<b>%s</b> items updated" % updated)
# Update CSV data
def get_csv_data(self):
if not self.doc.file_list:
msgprint("File not attached!")
raise Exception
fid = self.doc.file_list.split(',')[1]
from webnotes.utils import file_manager
fn, content = file_manager.get_file(fid)
if not type(content) == str:
content = content.tostring()
return content

View File

@ -0,0 +1,99 @@
# DocType, Bulk Rename Tool
[
# These values are common in all dictionaries
{
'creation': '2011-07-08 13:30:05',
'docstatus': 0,
'modified': '2011-07-08 13:30:05',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1310035501',
'allow_attach': 1,
'autoname': 'field:rename_doctype',
'colour': 'White:FFF',
'doctype': 'DocType',
'module': 'Utilities',
'name': '__common__',
'section_style': 'Simple',
'show_in_menu': 0,
'version': 6
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Bulk Rename Tool',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Bulk Rename Tool',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1,
'role': 'System Manager'
},
# DocType, Bulk Rename Tool
{
'doctype': 'DocType',
'name': 'Bulk Rename Tool'
},
# DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 0,
'submit': 1,
'write': 1
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'rename_doctype',
'fieldtype': 'Data',
'idx': 1,
'label': 'Rename DocType',
'options': 'Suggest',
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'file_list',
'fieldtype': 'Text',
'idx': 2,
'label': 'File List'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Button',
'idx': 3,
'label': 'Rename',
'options': 'do_rename'
}
]

View File

@ -44,7 +44,7 @@ class DocType:
# =============================================================================
def get_bin_qty(self, wh, item):
# get actual_qty
act_qty = sql("select ifnull(actual_qty, 0) from `tabBin` where warehouse = '%s' and item_code = '%s'" % (wh, item))
act_qty = sql("select sum(actual_qty) from `tabStock Ledger Entry` where warehouse = '%s' and item_code = '%s' and ifnull(is_cancelled, 'No') = 'No'" % (wh, item))
act_qty = act_qty and flt(act_qty[0][0]) or 0
# get indented_qty
@ -120,6 +120,17 @@ class DocType:
self.repair_bin(bin[0])
# =============================================================================
def repair_bins_for_illegal_cancelled(self, after_date = '2011-01-01'):
bins = sql("select name from tabBin where modified >= %s", after_date)
cnt = 0
for bin in bins:
if cnt % 20 == 0:
sql("commit")
sql("start transaction")
cnt += 1
self.repair_bin(bin[0])
# =============================================================================
def repair_opening_bal(self, d, acc_obj, past_yr, fiscal_yr):
# check opening balance
opbal = sql("select balance from `tabAccount Balance` where account=%s and period = %s", (acc_obj.doc.name, past_yr))