From ea69ff207a0a7a6e7bd0a36ae9da7451bf0abe57 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 28 Sep 2012 15:27:23 +0530 Subject: [PATCH 01/11] repost_acc_bal patch andpur taxes and charges --- .../purchase_taxes_and_charges.txt | 2 +- erpnext/patches/before_jan_2012/repost_account_bal.py | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt index 4673189ad3..3198b25632 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt @@ -5,7 +5,7 @@ { u'creation': '2012-09-18 11:20:24', u'docstatus': 0, - u'modified': '2012-09-28 12:19:57', + u'modified': '2012-09-28 12:27:43', u'modified_by': u'Administrator', u'owner': u'wasim@webnotestech.com' }, diff --git a/erpnext/patches/before_jan_2012/repost_account_bal.py b/erpnext/patches/before_jan_2012/repost_account_bal.py index a87bfe0cfc..b1d68c7d0f 100644 --- a/erpnext/patches/before_jan_2012/repost_account_bal.py +++ b/erpnext/patches/before_jan_2012/repost_account_bal.py @@ -30,10 +30,7 @@ def execute(): fy_obj = get_obj('Fiscal Year', f[0]) fy_obj.doc.past_year = prev_fy fy_obj.doc.company = c[0] - fy_obj.doc.save() - - fy_obj = get_obj('Fiscal Year', f[0]) fy_obj.repost() prev_fy = f[0] - sql("commit") - sql("start transaction") + webnotes.conn.commit() + webnotes.conn.begin() \ No newline at end of file From 62091db7a8d5e5aae52a4ee820c4e60de264e391 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 28 Sep 2012 16:06:06 +0530 Subject: [PATCH 02/11] fix in expiry msg --- erpnext/startup/event_handlers.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index ffbf11373b..9b9c03019f 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -118,22 +118,17 @@ def check_if_expired(): # if expired, stop user from logging in from webnotes.utils import formatdate + msg = """Oops! Your subscription expired on %s. +
Nothing catastrophic.
""" % formatdate(conf.expires_on) + if 'System Manager' in webnotes.user.roles: - webnotes.response['server_messages'] = """Oops! \ - Your subscription expired on %s. - - Nothing catastrophic. - - Just drop in a mail at support@erpnext.com and \ - we will guide you to get your account re-activated.""" % formatdate(conf.expires_on) + msg += """Just drop in a mail at support@erpnext.com and + we will guide you to get your account re-activated.""" else: - webnotes.response['server_messages'] = """Oops! \ - Your subscription expired on %s. - - Nothing catastrophic. - - Just ask your System Manager to drop in a mail at support@erpnext.com and \ - we will guide him to get your account re-activated.""" % formatdate(conf.expires_on) + msg += """Just ask your System Manager to drop in a mail at support@erpnext.com and + we will guide him to get your account re-activated.""" + + webnotes.msgprint(msg) webnotes.response['message'] = 'Account Expired' raise webnotes.AuthenticationError From dcb6c2c707425af4006cc549aff53503b5dfeb8b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 28 Sep 2012 16:09:49 +0530 Subject: [PATCH 03/11] fixed expiry message --- erpnext/startup/event_handlers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index 9b9c03019f..472d5d105c 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -118,8 +118,7 @@ def check_if_expired(): # if expired, stop user from logging in from webnotes.utils import formatdate - msg = """Oops! Your subscription expired on %s. -
Nothing catastrophic.
""" % formatdate(conf.expires_on) + msg = """Oops! Your subscription expired on %s.
""" % formatdate(conf.expires_on) if 'System Manager' in webnotes.user.roles: msg += """Just drop in a mail at support@erpnext.com and From 3cd9b312689ccdadbc31ad8cc244dc0273070722 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 28 Sep 2012 16:14:38 +0530 Subject: [PATCH 04/11] due date based on credit days in pur invoice --- erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index d9c3fb149f..257d02b789 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -66,7 +66,9 @@ class DocType(TransactionBase): def get_cust(self): ret = {} if self.doc.credit_to: - ret['supplier'] = get_value('Account',self.doc.credit_to,'master_name') + acc = get_value('Account',self.doc.credit_to,['master_name', 'credit_days']) + ret['supplier'] = acc[0] + ret['due_date'] = add_days(cstr(self.doc.posting_date), acc and cint(acc[1]) or 0) return ret From ce15b3e3bcfa5077bc79c0a8e4471fac3c8615ed Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 1 Oct 2012 12:16:31 +0530 Subject: [PATCH 05/11] shipping address in sales order should be hidden --- erpnext/selling/doctype/sales_order/sales_order.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index f4089be20f..0d67fd3e07 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -37,7 +37,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { // load default charges if(doc.__islocal && !doc.customer){ - hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','shipping_address']); + hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']); } } @@ -100,7 +100,7 @@ cur_frm.cscript.customer = function(doc,dt,dn) { var callback = function(r,rt) { var callback2 = function(r, rt) { - if(doc.customer) unhide_field(['customer_address', 'contact_person', 'territory','customer_group','shipping_address']); + if(doc.customer) unhide_field(['customer_address', 'contact_person', 'territory','customer_group']); cur_frm.refresh(); if(!onload && (pl != doc.price_list_name)) cur_frm.cscript.price_list_name(doc, dt, dn); @@ -141,8 +141,8 @@ cur_frm.cscript.pull_quotation_details = function(doc,dt,dn) { if(r.message){ doc.quotation_no = r.message; if(doc.quotation_no) { - unhide_field(['quotation_date','customer_address','contact_person','territory','customer_group','shipping_address']); - if(doc.customer) get_server_fields('get_shipping_address',doc.customer,'',doc, dt, dn, 0); + unhide_field(['quotation_date', 'customer_address', 'contact_person', 'territory', 'customer_group']); + if(doc.customer) get_server_fields('get_shipping_address', doc.customer, '', doc, dt, dn, 0); } cur_frm.refresh(); } From ecf2e0ed1067f2d48a8510d5519356652835e053 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 1 Oct 2012 12:51:44 +0530 Subject: [PATCH 06/11] Either debit or credit amount should be entered in journal voucher --- .../journal_voucher/journal_voucher.py | 738 ++++++++---------- 1 file changed, 332 insertions(+), 406 deletions(-) diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py index 1c01700cac..ab5d5564e1 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py @@ -8,11 +8,11 @@ # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # Please edit this list and import only required elements from __future__ import unicode_literals @@ -35,431 +35,357 @@ convert_to_lists = webnotes.conn.convert_to_lists from utilities.transaction_base import TransactionBase class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl - self.master_type = {} - self.credit_days_for = {} - self.credit_days_global = -1 - self.is_approving_authority = -1 + def __init__(self,d,dl): + self.doc, self.doclist = d,dl + self.master_type = {} + self.credit_days_for = {} + self.credit_days_global = -1 + self.is_approving_authority = -1 - #-------------------------------------------------------------------------------------------------------- - # Autoname - #-------------------------------------------------------------------------------------------------------- - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series+'.#####') + def autoname(self): + self.doc.name = make_autoname(self.doc.naming_series+'.#####') - #-------------------------------------------------------------------------------------------------------- - # Fetch outstanding amount from RV/PV - #-------------------------------------------------------------------------------------------------------- - def get_outstanding(self, args): - args = eval(args) - o_s = sql("select outstanding_amount from `tab%s` where name = '%s'" % (args['doctype'],args['docname'])) - if args['doctype'] == 'Purchase Invoice': - return {'debit': o_s and flt(o_s[0][0]) or 0} - if args['doctype'] == 'Sales Invoice': - return {'credit': o_s and flt(o_s[0][0]) or 0} + def get_outstanding(self, args): + args = eval(args) + o_s = sql("select outstanding_amount from `tab%s` where name = '%s'" % (args['doctype'],args['docname'])) + if args['doctype'] == 'Purchase Invoice': + return {'debit': o_s and flt(o_s[0][0]) or 0} + if args['doctype'] == 'Sales Invoice': + return {'credit': o_s and flt(o_s[0][0]) or 0} - #-------------------------------------------------------------------------------------------------------- - # Create remarks - #-------------------------------------------------------------------------------------------------------- - def create_remarks(self): - r = [] - if self.doc.cheque_no : - if self.doc.cheque_date: - r.append('Via cheque #%s dated %s' % (self.doc.cheque_no, formatdate(self.doc.cheque_date))) - else : - msgprint("Please enter cheque date") - raise Exception - - for d in getlist(self.doclist, 'entries'): - if d.against_invoice and d.credit: - currency = sql("select currency from `tabSales Invoice` where name = '%s'" % d.against_invoice) - currency = currency and currency[0][0] or '' - r.append('%s %s against Invoice: %s' % (cstr(currency), fmt_money(flt(d.credit)), d.against_invoice)) - if d.against_voucher and d.debit: - bill_no = sql("select bill_no, bill_date, currency from `tabPurchase Invoice` where name=%s", d.against_voucher) - if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() not in ['na', 'not applicable', 'none']: - bill_no = bill_no and bill_no[0] - r.append('%s %s against Bill %s dated %s' % (bill_no[2] and cstr(bill_no[2]) or '', fmt_money(flt(d.debit)), bill_no[0], bill_no[1] and formatdate(bill_no[1].strftime('%Y-%m-%d')) or '')) - if self.doc.ded_amount: - r.append("TDS Amount: %s" % self.doc.ded_amount) - - if self.doc.user_remark: - r.append("User Remark : %s"%self.doc.user_remark) + def create_remarks(self): + r = [] + if self.doc.cheque_no : + if self.doc.cheque_date: + r.append('Via cheque #%s dated %s' % (self.doc.cheque_no, formatdate(self.doc.cheque_date))) + else : + msgprint("Please enter cheque date") + raise Exception + + for d in getlist(self.doclist, 'entries'): + if d.against_invoice and d.credit: + currency = sql("select currency from `tabSales Invoice` where name = '%s'" % d.against_invoice) + currency = currency and currency[0][0] or '' + r.append('%s %s against Invoice: %s' % (cstr(currency), fmt_money(flt(d.credit)), d.against_invoice)) + if d.against_voucher and d.debit: + bill_no = sql("select bill_no, bill_date, currency from `tabPurchase Invoice` where name=%s", d.against_voucher) + if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() not in ['na', 'not applicable', 'none']: + bill_no = bill_no and bill_no[0] + r.append('%s %s against Bill %s dated %s' % (bill_no[2] and cstr(bill_no[2]) or '', fmt_money(flt(d.debit)), bill_no[0], bill_no[1] and formatdate(bill_no[1].strftime('%Y-%m-%d')) or '')) + if self.doc.ded_amount: + r.append("TDS Amount: %s" % self.doc.ded_amount) + + if self.doc.user_remark: + r.append("User Remark : %s"%self.doc.user_remark) - if r: - self.doc.remark = ("\n").join(r) - - # -------------------------------------------------------------------------------------------------------- - # Check user role for approval process - # -------------------------------------------------------------------------------------------------------- - def get_authorized_user(self): - if self.is_approving_authority==-1: - self.is_approving_authority = 0 + if r: + self.doc.remark = ("\n").join(r) + + def get_authorized_user(self): + if self.is_approving_authority==-1: + self.is_approving_authority = 0 - # Fetch credit controller role - approving_authority = sql("select value from `tabSingles` where field='credit_controller' and doctype='Global Defaults'") - approving_authority = approving_authority and approving_authority[0][0] or '' - - # Check logged-in user is authorized - if approving_authority in webnotes.user.get_roles(): - self.is_approving_authority = 1 - - return self.is_approving_authority - - # get master type - # --------------- - def get_master_type(self, ac): - if not self.master_type.get(ac): - self.master_type[ac] = sql("select master_type from `tabAccount` where name=%s", ac)[0][0] or 'None' - return self.master_type[ac] - - # get credit days for - # ------------------- - def get_credit_days_for(self, ac): + # Fetch credit controller role + approving_authority = sql("select value from `tabSingles` where field='credit_controller' and doctype='Global Defaults'") + approving_authority = approving_authority and approving_authority[0][0] or '' + + # Check logged-in user is authorized + if approving_authority in webnotes.user.get_roles(): + self.is_approving_authority = 1 + + return self.is_approving_authority + + def get_master_type(self, ac): + if not self.master_type.get(ac): + self.master_type[ac] = sql("select master_type from `tabAccount` where name=%s", ac)[0][0] or 'None' + return self.master_type[ac] + + def get_credit_days_for(self, ac): + if not self.credit_days_for.has_key(ac): + self.credit_days_for[ac] = sql("select credit_days from `tabAccount` where name='%s'" % ac)[0][0] or 0 - if not self.credit_days_for.has_key(ac): - self.credit_days_for[ac] = sql("select credit_days from `tabAccount` where name='%s'" % ac)[0][0] or 0 + if not self.credit_days_for[ac]: + if self.credit_days_global==-1: + self.credit_days_global = sql("select credit_days from `tabCompany` where name='%s'" % self.doc.company)[0][0] or 0 + return self.credit_days_global + else: + return self.credit_days_for[ac] + + def check_credit_days(self): + date_diff = 0 + if self.doc.cheque_date: + date_diff = (getdate(self.doc.cheque_date)-getdate(self.doc.posting_date)).days + + if date_diff <= 0: return + + # Get List of Customer Account + acc_list = filter(lambda d: self.get_master_type(d.account)=='Customer', getlist(self.doclist,'entries')) + + for d in acc_list: + credit_days = self.get_credit_days_for(d.account) + + # Check credit days + if credit_days > 0 and not self.get_authorized_user() and cint(date_diff) > credit_days: + msgprint("Credit Not Allowed: Cannot allow a check that is dated more than %s days after the posting date" % credit_days) + raise Exception + + def check_account_against_entries(self): + for d in getlist(self.doclist,'entries'): + if d.against_invoice: + acc=sql("select debit_to from `tabSales Invoice` where name='%s'"%d.against_invoice) + if acc and acc[0][0] != d.account: + msgprint("Debit account is not matching with receivable voucher") + raise Exception + + if d.against_voucher: + acc=sql("select credit_to from `tabPurchase Invoice` where name='%s'"%d.against_voucher) + if acc and acc[0][0] != d.account: + msgprint("Credit account is not matching with payable voucher") + raise Exception + + def validate_cheque_info(self): + if self.doc.voucher_type in ['Bank Voucher']: + if not self.doc.cheque_no or not self.doc.cheque_date: + msgprint("Cheque No & Cheque Date is required for " + cstr(self.doc.voucher_type)) + raise Exception + + if self.doc.cheque_date and not self.doc.cheque_no: + msgprint("Cheque No is mandatory if you entered Cheque Date") + raise Exception + + def validate_entries_for_advance(self): + for d in getlist(self.doclist,'entries'): + if not d.is_advance and not d.against_voucher and not d.against_invoice and d.against_jv: + master_type = self.get_master_type(d.account) + if (master_type == 'Customer' and flt(d.credit) > 0) or (master_type == 'Supplier' and flt(d.debit) > 0): + msgprint("Message: Please check Is Advance as 'Yes' against Account %s if this is an advance entry." % d.account) + + def get_tds_category_account(self): + for d in getlist(self.doclist,'entries'): + if flt(d.debit) > 0 and not d.against_voucher and d.is_advance == 'Yes': + acc = sql("select tds_applicable from `tabAccount` where name = '%s'" % d.account) + acc_tds_applicable = acc and acc[0][0] or 'No' + if acc_tds_applicable == 'Yes': + # TDS applicable field become mandatory for advance payment towards supplier or related party + if not self.doc.tds_applicable: + msgprint("Please select TDS Applicable or Not") + raise Exception + + # If TDS applicable, category and supplier account bocome mandatory + elif self.doc.tds_applicable == 'Yes': + self.validate_category_account(d.account) + if self.doc.ded_amount and not self.doc.tax_code: + msgprint("Please enter Tax Code in TDS section") + raise Exception - if not self.credit_days_for[ac]: - if self.credit_days_global==-1: - self.credit_days_global = sql("select credit_days from `tabCompany` where name='%s'" % self.doc.company)[0][0] or 0 - return self.credit_days_global - else: - return self.credit_days_for[ac] - - - # -------------------------------------------------------------------------------------------------------- - # Check Credit Days - Cheque Date can not after (Posting date + Credit Days) - # -------------------------------------------------------------------------------------------------------- - def check_credit_days(self): - date_diff = 0 - if self.doc.cheque_date: - date_diff = (getdate(self.doc.cheque_date)-getdate(self.doc.posting_date)).days - - if date_diff <= 0: return - - # Get List of Customer Account - acc_list = filter(lambda d: self.get_master_type(d.account)=='Customer', getlist(self.doclist,'entries')) - - for d in acc_list: - credit_days = self.get_credit_days_for(d.account) - - # Check credit days - if credit_days > 0 and not self.get_authorized_user() and cint(date_diff) > credit_days: - msgprint("Credit Not Allowed: Cannot allow a check that is dated more than %s days after the posting date" % credit_days) - raise Exception - - #-------------------------------------------------------------------------------------------------------- - # validation of debit/credit account with Debit To Account(RV) or Credit To Account (PV) - #-------------------------------------------------------------------------------------------------------- - def check_account_against_entries(self): - for d in getlist(self.doclist,'entries'): - if d.against_invoice: - acc=sql("select debit_to from `tabSales Invoice` where name='%s'"%d.against_invoice) - if acc and acc[0][0] != d.account: - msgprint("Debit account is not matching with receivable voucher") - raise Exception - - if d.against_voucher: - acc=sql("select credit_to from `tabPurchase Invoice` where name='%s'"%d.against_voucher) - if acc and acc[0][0] != d.account: - msgprint("Credit account is not matching with payable voucher") - raise Exception - - #-------------------------------------------------------------------------------------------------------- - # Validate Cheque Info: Mandatory for Bank/Contra voucher - #-------------------------------------------------------------------------------------------------------- - def validate_cheque_info(self): - if self.doc.voucher_type in ['Bank Voucher']: - if not self.doc.cheque_no or not self.doc.cheque_date: - msgprint("Cheque No & Cheque Date is required for " + cstr(self.doc.voucher_type)) - raise Exception - - if self.doc.cheque_date and not self.doc.cheque_no: - msgprint("Cheque No is mandatory if you entered Cheque Date") - raise Exception - - #-------------------------------------------------------------------------------------------------------- - # Gives reminder for making is_advance = 'Yes' in Advance Entry - #-------------------------------------------------------------------------------------------------------- - def validate_entries_for_advance(self): - for d in getlist(self.doclist,'entries'): - if not d.is_advance and not d.against_voucher and not d.against_invoice and d.against_jv: - master_type = self.get_master_type(d.account) - if (master_type == 'Customer' and flt(d.credit) > 0) or (master_type == 'Supplier' and flt(d.debit) > 0): - msgprint("Message: Please check Is Advance as 'Yes' against Account %s if this is an advance entry." % d.account) - - #-------------------------------------------------------------------------------------------------------- - # TDS: Validate tds related fields - #-------------------------------------------------------------------------------------------------------- - def get_tds_category_account(self): - for d in getlist(self.doclist,'entries'): - if flt(d.debit) > 0 and not d.against_voucher and d.is_advance == 'Yes': - acc = sql("select tds_applicable from `tabAccount` where name = '%s'" % d.account) - acc_tds_applicable = acc and acc[0][0] or 'No' - if acc_tds_applicable == 'Yes': - # TDS applicable field become mandatory for advance payment towards supplier or related party - if not self.doc.tds_applicable: - msgprint("Please select TDS Applicable or Not") - raise Exception - - # If TDS applicable, category and supplier account bocome mandatory - elif self.doc.tds_applicable == 'Yes': - self.validate_category_account(d.account) - if self.doc.ded_amount and not self.doc.tax_code: - msgprint("Please enter Tax Code in TDS section") - raise Exception + #If TDS not applicable, all related fields should blank + else: + self.set_fields_null() + + # If tds amount but tds applicability not mentioned in account master + elif self.doc.ded_amount: + msgprint("Please select TDS Applicable = 'Yes' in account head: '%s' if you want to deduct TDS." % self.doc.supplier_account) + raise Exception + + def validate_category_account(self, credit_account): + if not self.doc.tds_category: + msgprint("Please select TDS Category") + raise Exception + + if not self.doc.supplier_account: + self.doc.supplier_account = credit_account + elif self.doc.supplier_account and self.doc.supplier_account != credit_account: + msgprint("Supplier Account is not matching with the account mentioned in the table. Please select proper Supplier Account and click on 'Get TDS' button.") + raise Exception + + def set_fields_null(self): + self.doc.ded_amount = 0 + self.doc.rate = 0 + self.doc.tax_code = '' + self.doc.tds_category = '' + self.doc.supplier_account = '' + + def get_tds(self): + if cstr(self.doc.is_opening) != 'Yes': + if self.doc.total_debit > 0: + self.get_tds_category_account() + if self.doc.supplier_account and self.doc.tds_category: + get_obj('TDS Control').get_tds_amount(self) - #If TDS not applicable, all related fields should blank - else: - self.set_fields_null() - - # If tds amount but tds applicability not mentioned in account master - elif self.doc.ded_amount: - msgprint("Please select TDS Applicable = 'Yes' in account head: '%s' if you want to deduct TDS." % self.doc.supplier_account) - raise Exception - - + def get_balance(self): + if not getlist(self.doclist,'entries'): + msgprint("Please enter atleast 1 entry in 'GL Entries' table") + else: + flag, self.doc.total_debit, self.doc.total_credit = 0,0,0 + diff = flt(self.doc.difference) + + # If any row without amount, set the diff on that row + for d in getlist(self.doclist,'entries'): + if (d.credit==0 or d.credit is None) and (d.debit==0 or d.debit is None) and (flt(diff) != 0): + if diff>0: + d.credit = flt(diff) + elif diff<0: + d.debit = flt(diff) + flag = 1 + + # Set the diff in a new row + if flag == 0 and (flt(diff) != 0): + jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist) + if diff>0: + jd.credit = flt(diff) + elif diff<0: + jd.debit = flt(diff) + + # Set the total debit, total credit and difference + for d in getlist(self.doclist,'entries'): + self.doc.total_debit += flt(d.debit) + self.doc.total_credit += flt(d.credit) - #-------------------------------------------------------------------------------------------------------- - # If TDS applicable , TDS category and supplier account should be mandatory - #-------------------------------------------------------------------------------------------------------- - def validate_category_account(self, credit_account): - if not self.doc.tds_category: - msgprint("Please select TDS Category") - raise Exception - - if not self.doc.supplier_account: - self.doc.supplier_account = credit_account - elif self.doc.supplier_account and self.doc.supplier_account != credit_account: - msgprint("Supplier Account is not matching with the account mentioned in the table. Please select proper Supplier Account and click on 'Get TDS' button.") - raise Exception - + if self.doc.tds_applicable == 'Yes': + self.doc.total_credit = flt(self.doc.total_credit) + flt(self.doc.ded_amount) - #-------------------------------------------------------------------------------------------------------- - # If TDS is not applicable , all related fields should blank - #-------------------------------------------------------------------------------------------------------- - def set_fields_null(self): - self.doc.ded_amount = 0 - self.doc.rate = 0 - self.doc.tax_code = '' - self.doc.tds_category = '' - self.doc.supplier_account = '' - - #-------------------------------------------------------------------------------------------------------- - # Get TDS amount - #-------------------------------------------------------------------------------------------------------- - def get_tds(self): - if cstr(self.doc.is_opening) != 'Yes': - if self.doc.total_debit > 0: - self.get_tds_category_account() - if self.doc.supplier_account and self.doc.tds_category: - get_obj('TDS Control').get_tds_amount(self) + self.doc.difference = flt(self.doc.total_debit) - flt(self.doc.total_credit) + + def get_against_account(self): + # Debit = Credit + debit, credit = 0.0, 0.0 + debit_list, credit_list = [], [] + for d in getlist(self.doclist, 'entries'): + debit += flt(d.debit) + credit += flt(d.credit) + if flt(d.debit)>0 and (d.account not in debit_list): debit_list.append(d.account) + if flt(d.credit)>0 and (d.account not in credit_list): credit_list.append(d.account) - - #-------------------------------------------------------------------------------------------------------- - # Insert new row to balance total debit and total credit - #-------------------------------------------------------------------------------------------------------- - def get_balance(self): - if not getlist(self.doclist,'entries'): - msgprint("Please enter atleast 1 entry in 'GL Entries' table") - else: - flag, self.doc.total_debit, self.doc.total_credit = 0,0,0 - diff = flt(self.doc.difference) - - # If any row without amount, set the diff on that row - for d in getlist(self.doclist,'entries'): - if (d.credit==0 or d.credit is None) and (d.debit==0 or d.debit is None) and (flt(diff) != 0): - if diff>0: - d.credit = flt(diff) - elif diff<0: - d.debit = flt(diff) - flag = 1 - - # Set the diff in a new row - if flag == 0 and (flt(diff) != 0): - jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist) - if diff>0: - jd.credit = flt(diff) - elif diff<0: - jd.debit = flt(diff) - - # Set the total debit, total credit and difference - for d in getlist(self.doclist,'entries'): - self.doc.total_debit += flt(d.debit) - self.doc.total_credit += flt(d.credit) + self.doc.total_debit = debit + if self.doc.tds_applicable == 'Yes': + self.doc.total_credit = credit + flt(self.doc.ded_amount) + else: + self.doc.total_credit = credit - if self.doc.tds_applicable == 'Yes': - self.doc.total_credit = flt(self.doc.total_credit) + flt(self.doc.ded_amount) + if abs(self.doc.total_debit-self.doc.total_credit) > 0.001: + msgprint("Debit must be equal to Credit. The difference is %s" % (self.doc.total_debit-self.doc.total_credit)) + raise Exception + + # update against account + for d in getlist(self.doclist, 'entries'): + if flt(d.debit) > 0: d.against_account = ', '.join(credit_list) + if flt(d.credit) > 0: d.against_account = ', '.join(debit_list) - self.doc.difference = flt(self.doc.total_debit) - flt(self.doc.total_credit) - - #-------------------------------------------------------------------------------------------------------- - # Set against account - #-------------------------------------------------------------------------------------------------------- - def get_against_account(self): - # Debit = Credit - debit, credit = 0.0, 0.0 - debit_list, credit_list = [], [] - for d in getlist(self.doclist, 'entries'): - debit += flt(d.debit) - credit += flt(d.credit) - if flt(d.debit)>0 and (d.account not in debit_list): debit_list.append(d.account) - if flt(d.credit)>0 and (d.account not in credit_list): credit_list.append(d.account) + def set_aging_date(self): + if self.doc.is_opening != 'Yes': + self.doc.aging_date = self.doc.posting_date + else: + # check account type whether supplier or customer + exists = '' + for d in getlist(self.doclist, 'entries'): + exists = sql("select name from tabAccount where account_type in ('Supplier', 'Customer') and name = '%s'" % d.account) + if exists: + break - self.doc.total_debit = debit - if self.doc.tds_applicable == 'Yes': - self.doc.total_credit = credit + flt(self.doc.ded_amount) - else: - self.doc.total_credit = credit + # If cus/supp aging dt is mandatory + if exists and not self.doc.aging_date: + msgprint("Aging Date is mandatory for opening entry") + raise Exception + # otherwise aging dt = posting dt + else: + self.doc.aging_date = self.doc.posting_date - if abs(self.doc.total_debit-self.doc.total_credit) > 0.001: - msgprint("Debit must be equal to Credit. The difference is %s" % (self.doc.total_debit-self.doc.total_credit)) - raise Exception - - # update against account - for d in getlist(self.doclist, 'entries'): - if flt(d.debit) > 0: d.against_account = ', '.join(credit_list) - if flt(d.credit) > 0: d.against_account = ', '.join(debit_list) + def set_print_format_fields(self): + for d in getlist(self.doclist, 'entries'): + #msgprint(self.doc.company) + chk_type = sql("select master_type, account_type from `tabAccount` where name='%s'" % d.account) + master_type, acc_type = chk_type and cstr(chk_type[0][0]) or '', chk_type and cstr(chk_type[0][1]) or '' + if master_type in ['Supplier', 'Customer']: + if not self.doc.pay_to_recd_from: + self.doc.pay_to_recd_from = get_value(master_type, ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name') + + if acc_type == 'Bank or Cash': + dcc = TransactionBase().get_company_currency(self.doc.company) + amt = cint(d.debit) and d.debit or d.credit + self.doc.total_amount = dcc +' '+ cstr(amt) + self.doc.total_amount_in_words = get_obj('Sales Common').get_total_in_words(dcc, cstr(amt)) + + def get_values(self): + cond = (flt(self.doc.write_off_amount) > 0) and ' and outstanding_amount <= '+self.doc.write_off_amount or '' + if self.doc.write_off_based_on == 'Accounts Receivable': + return sql("select name, debit_to, outstanding_amount from `tabSales Invoice` where docstatus = 1 and company = '%s' and outstanding_amount > 0 %s" % (self.doc.company, cond)) + elif self.doc.write_off_based_on == 'Accounts Payable': + return sql("select name, credit_to, outstanding_amount from `tabPurchase Invoice` where docstatus = 1 and company = '%s' and outstanding_amount > 0 %s" % (self.doc.company, cond)) - # set aging date - #--------------- - def set_aging_date(self): - if self.doc.is_opening != 'Yes': - self.doc.aging_date = self.doc.posting_date - else: - # check account type whether supplier or customer - exists = '' - for d in getlist(self.doclist, 'entries'): - exists = sql("select name from tabAccount where account_type in ('Supplier', 'Customer') and name = '%s'" % d.account) - if exists: - break + def get_outstanding_invoices(self): + self.doclist = self.doc.clear_table(self.doclist, 'entries') + total = 0 + for d in self.get_values(): + total += flt(d[2]) + jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist) + jd.account = cstr(d[1]) + if self.doc.write_off_based_on == 'Accounts Receivable': + jd.credit = flt(d[2]) + jd.against_invoice = cstr(d[0]) + elif self.doc.write_off_based_on == 'Accounts Payable': + jd.debit = flt(d[2]) + jd.against_voucher = cstr(d[0]) + jd.save(1) + jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist) + if self.doc.write_off_based_on == 'Accounts Receivable': + jd.debit = total + elif self.doc.write_off_based_on == 'Accounts Payable': + jd.credit = total + jd.save(1) - # If cus/supp aging dt is mandatory - if exists and not self.doc.aging_date: - msgprint("Aging Date is mandatory for opening entry") - raise Exception - # otherwise aging dt = posting dt - else: - self.doc.aging_date = self.doc.posting_date + def validate(self): + if not self.doc.is_opening: + self.doc.is_opening='No' + self.validate_debit_credit() + self.get_against_account() + self.validate_cheque_info() + self.create_remarks() + # tds + get_obj('TDS Control').validate_first_entry(self) + self.get_tds_category_account() - # ------------------------ - # set print format fields - # ------------------------ - def set_print_format_fields(self): - for d in getlist(self.doclist, 'entries'): - #msgprint(self.doc.company) - chk_type = sql("select master_type, account_type from `tabAccount` where name='%s'" % d.account) - master_type, acc_type = chk_type and cstr(chk_type[0][0]) or '', chk_type and cstr(chk_type[0][1]) or '' - if master_type in ['Supplier', 'Customer']: - if not self.doc.pay_to_recd_from: - self.doc.pay_to_recd_from = get_value(master_type, ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name') - - if acc_type == 'Bank or Cash': - dcc = TransactionBase().get_company_currency(self.doc.company) - amt = cint(d.debit) and d.debit or d.credit - self.doc.total_amount = dcc +' '+ cstr(amt) - self.doc.total_amount_in_words = get_obj('Sales Common').get_total_in_words(dcc, cstr(amt)) + self.validate_entries_for_advance() + self.set_aging_date() + + self.validate_against_jv() + self.set_print_format_fields() + #FY and Date validation + get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year, \ + self.doc.posting_date, 'Posting Date') - # -------------------------------- - # get outstanding invoices values - # -------------------------------- - def get_values(self): - cond = (flt(self.doc.write_off_amount) > 0) and ' and outstanding_amount <= '+self.doc.write_off_amount or '' - if self.doc.write_off_based_on == 'Accounts Receivable': - return sql("select name, debit_to, outstanding_amount from `tabSales Invoice` where docstatus = 1 and company = '%s' and outstanding_amount > 0 %s" % (self.doc.company, cond)) - elif self.doc.write_off_based_on == 'Accounts Payable': - return sql("select name, credit_to, outstanding_amount from `tabPurchase Invoice` where docstatus = 1 and company = '%s' and outstanding_amount > 0 %s" % (self.doc.company, cond)) + def validate_debit_credit(self): + for d in getlist(self.doclist, 'entries'): + if d.debit and d.credit: + msgprint("You cannot credit and debit same account at the same time.", + raise_exception=1) + def on_update(self): + pass + + def on_submit(self): + if self.doc.voucher_type in ['Bank Voucher', 'Contra Voucher', 'Journal Entry']: + self.check_credit_days() + self.check_account_against_entries() + get_obj(dt='GL Control').make_gl_entries(self.doc, self.doclist) - # ------------------------- - # get outstanding invoices - # ------------------------- - def get_outstanding_invoices(self): - self.doclist = self.doc.clear_table(self.doclist, 'entries') - total = 0 - for d in self.get_values(): - total += flt(d[2]) - jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist) - jd.account = cstr(d[1]) - if self.doc.write_off_based_on == 'Accounts Receivable': - jd.credit = flt(d[2]) - jd.against_invoice = cstr(d[0]) - elif self.doc.write_off_based_on == 'Accounts Payable': - jd.debit = flt(d[2]) - jd.against_voucher = cstr(d[0]) - jd.save(1) - jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist) - if self.doc.write_off_based_on == 'Accounts Receivable': - jd.debit = total - elif self.doc.write_off_based_on == 'Accounts Payable': - jd.credit = total - jd.save(1) + def validate_against_jv(self): + for d in getlist(self.doclist, 'entries'): + if d.against_jv: + if d.against_jv == self.doc.name: + msgprint("You can not enter current voucher in 'Against JV' column") + raise Exception + elif not sql("select name from `tabJournal Voucher Detail` where account = '%s' and docstatus = 1 and parent = '%s'" % (d.account, d.against_jv)): + msgprint("Against JV: "+ d.against_jv + " is not valid. Please check") + raise Exception + + def on_cancel(self): + self.check_tds_payment_voucher() + get_obj(dt='GL Control').make_gl_entries(self.doc, self.doclist, cancel=1) - - #-------------------------------------------------------------------------------------------------------- - # VALIDATE - #-------------------------------------------------------------------------------------------------------- - def validate(self): - if not self.doc.is_opening: - self.doc.is_opening='No' - self.get_against_account() - self.validate_cheque_info() - self.create_remarks() - # tds - get_obj('TDS Control').validate_first_entry(self) - self.get_tds_category_account() - - self.validate_entries_for_advance() - self.set_aging_date() - - self.validate_against_jv() - self.set_print_format_fields() - - #FY and Date validation - get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date') - - #-------------------------------------------------------------------------------------------------------- - # On Update - Update Feed - #-------------------------------------------------------------------------------------------------------- - def on_update(self): - pass - - #-------------------------------------------------------------------------------------------------------- - # On submit - #-------------------------------------------------------------------------------------------------------- - def on_submit(self): - if self.doc.voucher_type in ['Bank Voucher', 'Contra Voucher', 'Journal Entry']: - self.check_credit_days() - self.check_account_against_entries() - get_obj(dt='GL Control').make_gl_entries(self.doc, self.doclist) - - - # validate against jv no - def validate_against_jv(self): - for d in getlist(self.doclist, 'entries'): - if d.against_jv: - if d.against_jv == self.doc.name: - msgprint("You can not enter current voucher in 'Against JV' column") - raise Exception - elif not sql("select name from `tabJournal Voucher Detail` where account = '%s' and docstatus = 1 and parent = '%s'" % (d.account, d.against_jv)): - msgprint("Against JV: "+ d.against_jv + " is not valid. Please check") - raise Exception - - #-------------------------------------------------------------------------------------------------------- - # On cancel reverse gl entry - #-------------------------------------------------------------------------------------------------------- - def on_cancel(self): - self.check_tds_payment_voucher() - get_obj(dt='GL Control').make_gl_entries(self.doc, self.doclist, cancel=1) - - # Check whether tds payment voucher has been created against this voucher - #--------------------------------------------------------------------------- - def check_tds_payment_voucher(self): - tdsp = sql("select parent from `tabTDS Payment Detail` where voucher_no = '%s' and docstatus = 1 and parent not like 'old%'") - if tdsp: - msgprint("TDS Payment voucher '%s' has been made against this voucher. Please cancel the payment voucher to proceed." % (tdsp and tdsp[0][0] or '')) - raise Exception + def check_tds_payment_voucher(self): + tdsp = sql("select parent from `tabTDS Payment Detail` where voucher_no = '%s' and docstatus = 1 and parent not like 'old%'") + if tdsp: + msgprint("TDS Payment voucher '%s' has been made against this voucher. Please cancel the payment voucher to proceed." % (tdsp and tdsp[0][0] or '')) + raise Exception \ No newline at end of file From e070d72fb3406bfb0c2020a25dbca4461baa46ce Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 1 Oct 2012 14:05:35 +0530 Subject: [PATCH 07/11] fetch item description_html in opportunity --- .../doctype/opportunity/opportunity.js | 16 ++-- .../doctype/opportunity/opportunity.py | 77 +++++-------------- erpnext/stock/doctype/item/item.js | 1 + 3 files changed, 25 insertions(+), 69 deletions(-) diff --git a/erpnext/selling/doctype/opportunity/opportunity.js b/erpnext/selling/doctype/opportunity/opportunity.js index 52cb5fd704..1605670a7b 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.js +++ b/erpnext/selling/doctype/opportunity/opportunity.js @@ -59,17 +59,11 @@ cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) { } } -// fetch -// =============================================================== -cur_frm.cscript.set_fetch = function() { - // item - cur_frm.add_fetch('item_code', 'item_name', 'item_name'); - cur_frm.add_fetch('item_code', 'stock_uom', 'uom'); - cur_frm.add_fetch('item_code', 'description', 'description'); - cur_frm.add_fetch('item_code', 'item_group', 'item_group'); - cur_frm.add_fetch('item_code', 'brand', 'brand'); - - // customer +cur_frm.cscript.item_code = function(doc, cdt, cdn) { + var d = locals[cdt][cdn]; + if (d.item_code) { + get_server_fields('get_item_details',d.item_code, 'enquiry_details',doc, cdt,cdn,1); + } } // hide - unhide fields on basis of enquiry_from lead or customer diff --git a/erpnext/selling/doctype/opportunity/opportunity.py b/erpnext/selling/doctype/opportunity/opportunity.py index c3a6fb7596..f3d6a61fac 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.py +++ b/erpnext/selling/doctype/opportunity/opportunity.py @@ -42,13 +42,21 @@ class DocType(TransactionBase): self.fname = 'enq_details' self.tname = 'Opportunity Item' - # Autoname - # ==================================================================================================================== def autoname(self): self.doc.name = make_autoname(self.doc.naming_series+'.####') + + def get_item_details(self, item_code): + item = sql("""select item_name, stock_uom, description_html, description, item_group, brand + from `tabItem` where name = %s""", item_code, as_dict=1) + ret = { + 'item_name': item and item[0]['item_name'] or '', + 'uom': item and item[0]['stock_uom'] or '', + 'description': item and item[0]['description_html'] or item[0]['description'] or '', + 'item_group': item and item[0]['item_group'] or '', + 'brand': item and item[0]['brand'] or '' + } + return ret - #--------Get customer address------- - # ==================================================================================================================== def get_cust_address(self,name): details = sql("select customer_name, address, territory, customer_group from `tabCustomer` where name = '%s' and docstatus != 2" %(name), as_dict = 1) if details: @@ -71,9 +79,7 @@ class DocType(TransactionBase): else: msgprint("Customer : %s does not exist in system." % (name)) raise Exception - - - # ==================================================================================================================== + def get_contact_details(self, arg): arg = eval(arg) contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s'" %(arg['contact_person'],arg['customer']), as_dict = 1) @@ -83,18 +89,14 @@ class DocType(TransactionBase): } return ret - # ==================================================================================================================== def on_update(self): # Add to calendar - #if self.doc.contact_date and self.doc.last_contact_date != self.doc.contact_date: if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date: if self.doc.contact_by: self.add_calendar_event() set(self.doc, 'contact_date_ref',self.doc.contact_date) set(self.doc, 'status', 'Draft') - - # Add to Calendar - # ==================================================================================================================== + def add_calendar_event(self): desc='' user_lst =[] @@ -133,8 +135,6 @@ class DocType(TransactionBase): ch.person = d ch.save(1) - #--------------Validation For Last Contact Date----------------- - # ==================================================================================================================== def set_last_contact_date(self): if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date: if getdate(self.doc.contact_date_ref) < getdate(self.doc.contact_date): @@ -142,16 +142,12 @@ class DocType(TransactionBase): else: msgprint("Contact Date Cannot be before Last Contact Date") raise Exception - - # check if item present in item table - # ==================================================================================================================== + def validate_item_details(self): if not getlist(self.doclist, 'enquiry_details'): msgprint("Please select items for which enquiry needs to be made") raise Exception - - #check if enquiry date in the range of fiscal year selected - #===================================================== + def validate_fiscal_year(self): fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year) ysd=fy and fy[0][0] or "" @@ -166,19 +162,15 @@ class DocType(TransactionBase): elif self.doc.enquiry_from == 'Customer' and not self.doc.customer: msgprint("Customer is mandatory if 'Opportunity From' is selected as Customer", raise_exception=1) - def validate(self): self.validate_fiscal_year() self.set_last_contact_date() self.validate_item_details() self.validate_lead_cust() - - # On Submit Functions - # ==================================================================================================================== + def on_submit(self): set(self.doc, 'status', 'Submitted') - - # ==================================================================================================================== + def on_cancel(self): chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Item` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name) if chk: @@ -187,8 +179,6 @@ class DocType(TransactionBase): else: set(self.doc, 'status', 'Cancelled') - # declare as enquiry lost - #--------------------------- def declare_enquiry_lost(self,arg): chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Item` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name) if chk: @@ -197,33 +187,4 @@ class DocType(TransactionBase): else: set(self.doc, 'status', 'Opportunity Lost') set(self.doc, 'order_lost_reason', arg) - return 'true' - - #---------------------- Add details in follow up table---------------- - # ==================================================================================================================== - def add_in_follow_up(self,message,type): - import datetime - child = addchild( self.doc, 'follow_up', 'Communication Log', 1, self.doclist) - child.date = datetime.datetime.now().date().strftime('%Y-%m-%d') - child.notes = message - child.follow_up_type = type - child.save() - - #-------------------SMS---------------------------------------------- - # ==================================================================================================================== - def send_sms(self): - if not self.doc.sms_message: - msgprint("Please enter message in SMS Section ") - raise Exception - elif not getlist(self.doclist, 'enquiry_sms_detail'): - msgprint("Please mention mobile no. to which sms needs to be sent") - raise Exception - else: - receiver_list = [] - for d in getlist(self.doclist,'enquiry_sms_detail'): - if d.other_mobile_no: - receiver_list.append(d.other_mobile_no) - - if receiver_list: - msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.sms_message)) - self.add_in_follow_up(self.doc.sms_message,'SMS') + return 'true' \ No newline at end of file diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 96c03399f1..bc9d57fac6 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -106,6 +106,7 @@ cur_frm.fields_dict['item_group'].get_query = function(doc,cdt,cdn) { cur_frm.cscript.add_image = function(doc, dt, dn) { if(!doc.file_list) { msgprint('Please attach a file first!'); + return; } var f = doc.file_list.split('\n')[0]; From 835ebe5b58723d91d68af30ebbc80c5c29011d5d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 2 Oct 2012 10:34:31 +0530 Subject: [PATCH 08/11] error fixed in new general ledger --- erpnext/accounts/page/general_ledger/general_ledger.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/page/general_ledger/general_ledger.js b/erpnext/accounts/page/general_ledger/general_ledger.js index eca9dea97a..c8866fcfd5 100644 --- a/erpnext/accounts/page/general_ledger/general_ledger.js +++ b/erpnext/accounts/page/general_ledger/general_ledger.js @@ -102,8 +102,9 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ var default_company = me.filter_inputs.company.get(0).opts.default_value; $filter.empty().add_options([$filter.get(0).opts.default_value].concat( $.map(wn.report_dump.data["Account"], function(ac) { - return (accounts_by_company[company].indexOf(ac.name)!=-1 || - company===default_company) ? ac.name : null; + return (company===default_company || + accounts_by_company[company].indexOf(ac.name)!=-1) ? + ac.name : null; }))); me.filter_inputs.refresh.click(); }); From f7b26b3dae31fd45cce2a370c2931879be75883d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 2 Oct 2012 12:08:32 +0530 Subject: [PATCH 09/11] permission fixes --- .../leave_allocation/leave_allocation.txt | 133 ++++++------ .../leave_application/leave_application.txt | 190 ++++++++---------- erpnext/patches/october_2012/__init__.py | 0 .../patches/october_2012/update_permission.py | 39 ++++ erpnext/patches/patch_list.py | 4 + .../setup/doctype/price_list/price_list.js | 42 ++-- .../sales_and_purchase_return_tool.txt | 158 ++------------- 7 files changed, 234 insertions(+), 332 deletions(-) create mode 100644 erpnext/patches/october_2012/__init__.py create mode 100644 erpnext/patches/october_2012/update_permission.py diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.txt b/erpnext/hr/doctype/leave_allocation/leave_allocation.txt index 9045221092..287dc80b28 100644 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation.txt +++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.txt @@ -3,11 +3,11 @@ # These values are common in all dictionaries { - 'creation': '2012-03-27 14:35:58', - 'docstatus': 0, - 'modified': '2012-03-27 14:45:49', - 'modified_by': u'Administrator', - 'owner': u'Administrator' + u'creation': '2012-05-15 12:14:45', + u'docstatus': 0, + u'modified': '2012-10-02 11:21:31', + u'modified_by': u'Administrator', + u'owner': u'Administrator' }, # These values are common for all DocType @@ -16,21 +16,21 @@ 'autoname': u'LAL/.#####', 'colour': u'White:FFF', 'default_print_format': u'Standard', - 'doctype': 'DocType', + u'doctype': u'DocType', 'is_submittable': 1, 'module': u'HR', - 'name': '__common__', + u'name': u'__common__', 'search_fields': u'employee,employee_name,leave_type,total_leaves_allocated,fiscal_year', 'section_style': u'Simple', 'server_code_error': u' ', 'show_in_menu': 0, - 'version': 1560 + 'version': 1 }, # These values are common for all DocField { - 'doctype': u'DocField', - 'name': '__common__', + u'doctype': u'DocField', + u'name': u'__common__', 'parent': u'Leave Allocation', 'parentfield': u'fields', 'parenttype': u'DocType' @@ -38,8 +38,8 @@ # These values are common for all DocPerm { - 'doctype': u'DocPerm', - 'name': '__common__', + u'doctype': u'DocPerm', + u'name': u'__common__', 'parent': u'Leave Allocation', 'parentfield': u'permissions', 'parenttype': u'DocType', @@ -48,58 +48,13 @@ # DocType, Leave Allocation { - 'doctype': 'DocType', - 'name': u'Leave Allocation' - }, - - # DocPerm - { - 'amend': 1, - 'cancel': 1, - 'create': 1, - 'doctype': u'DocPerm', - 'match': u'owner', - 'permlevel': 0, - 'role': u'HR User', - 'submit': 1, - 'write': 1 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - 'doctype': u'DocPerm', - 'match': u'owner', - 'permlevel': 0, - 'role': u'HR User', - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 1, - 'cancel': 1, - 'create': 1, - 'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'HR Manager', - 'submit': 1, - 'write': 1 - }, - - # DocPerm - { - 'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'HR Manager' + u'doctype': u'DocType', + u'name': u'Leave Allocation' }, # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'column_break0', 'fieldtype': u'Column Break', 'permlevel': 0, @@ -109,7 +64,7 @@ # DocField { 'colour': u'White:FFF', - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'employee', 'fieldtype': u'Link', 'in_filter': 1, @@ -125,7 +80,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'employee_name', 'fieldtype': u'Data', 'in_filter': 1, @@ -137,7 +92,7 @@ # DocField { 'colour': u'White:FFF', - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'leave_type', 'fieldtype': u'Select', 'in_filter': 1, @@ -155,7 +110,7 @@ { 'colour': u'White:FFF', 'default': u'Today', - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'posting_date', 'fieldtype': u'Date', 'hidden': 0, @@ -171,7 +126,7 @@ # DocField { 'colour': u'White:FFF', - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'fiscal_year', 'fieldtype': u'Select', 'in_filter': 1, @@ -188,7 +143,7 @@ # DocField { 'colour': u'White:FFF', - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'description', 'fieldtype': u'Small Text', 'hidden': 0, @@ -201,7 +156,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'column_break1', 'fieldtype': u'Column Break', 'permlevel': 0, @@ -210,7 +165,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'carry_forward', 'fieldtype': u'Check', 'label': u'Carry Forward', @@ -220,7 +175,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'carry_forwarded_leaves', 'fieldtype': u'Currency', 'label': u'Carry Forwarded Leaves', @@ -230,7 +185,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'new_leaves_allocated', 'fieldtype': u'Currency', 'label': u'New Leaves Allocated', @@ -240,7 +195,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'total_leaves_allocated', 'fieldtype': u'Currency', 'label': u'Total Leaves Allocated', @@ -250,7 +205,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'amended_from', 'fieldtype': u'Data', 'hidden': 0, @@ -265,7 +220,7 @@ # DocField { 'description': u'The date at which current entry is corrected in the system.', - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'amendment_date', 'fieldtype': u'Date', 'hidden': 0, @@ -275,5 +230,37 @@ 'oldfieldtype': u'Date', 'permlevel': 1, 'print_hide': 1 + }, + + # DocPerm + { + 'amend': 1, + 'cancel': 1, + 'create': 1, + u'doctype': u'DocPerm', + 'match': u'owner', + 'permlevel': 0, + 'role': u'HR User', + 'submit': 1, + 'write': 1 + }, + + # DocPerm + { + 'amend': 1, + 'cancel': 1, + 'create': 1, + u'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'HR Manager', + 'submit': 1, + 'write': 1 + }, + + # DocPerm + { + u'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'All' } ] \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_application/leave_application.txt b/erpnext/hr/doctype/leave_application/leave_application.txt index b2ce2ab338..c87c746b2f 100644 --- a/erpnext/hr/doctype/leave_application/leave_application.txt +++ b/erpnext/hr/doctype/leave_application/leave_application.txt @@ -3,11 +3,11 @@ # These values are common in all dictionaries { - 'creation': '2012-03-27 14:35:58', - 'docstatus': 0, - 'modified': '2012-03-27 14:45:49', - 'modified_by': u'Administrator', - 'owner': u'Administrator' + u'creation': '2012-05-15 12:14:45', + u'docstatus': 0, + u'modified': '2012-10-02 11:19:44', + u'modified_by': u'Administrator', + u'owner': u'Administrator' }, # These values are common for all DocType @@ -15,23 +15,23 @@ '_last_update': u'1310019491', 'autoname': u'LAP/.#####', 'colour': u'White:FFF', - 'doctype': 'DocType', + u'doctype': u'DocType', 'document_type': u'Transaction', 'is_submittable': 1, 'module': u'HR', - 'name': '__common__', + u'name': u'__common__', 'search_fields': u'employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year', 'section_style': u'Simple', 'show_in_menu': 0, 'subject': u'From %(employee_name)s, %(designation)s', 'tag_fields': u'leave_type', - 'version': 17 + 'version': 1 }, # These values are common for all DocField { - 'doctype': u'DocField', - 'name': '__common__', + u'doctype': u'DocField', + u'name': u'__common__', 'parent': u'Leave Application', 'parentfield': u'fields', 'parenttype': u'DocType' @@ -39,8 +39,8 @@ # These values are common for all DocPerm { - 'doctype': u'DocPerm', - 'name': '__common__', + u'doctype': u'DocPerm', + u'name': u'__common__', 'parent': u'Leave Application', 'parentfield': u'permissions', 'parenttype': u'DocType', @@ -49,85 +49,13 @@ # DocType, Leave Application { - 'doctype': 'DocType', - 'name': u'Leave Application' - }, - - # DocPerm - { - 'amend': 1, - 'cancel': 1, - 'create': 1, - 'doctype': u'DocPerm', - 'match': u'owner', - 'permlevel': 0, - 'submit': 1, - 'write': 1 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - 'doctype': u'DocPerm', - 'match': u'owner', - 'permlevel': 0, - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 1, - 'cancel': 1, - 'create': 1, - 'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'HR User', - 'submit': 1, - 'write': 1 - }, - - # DocPerm - { - 'amend': 1, - 'cancel': 1, - 'create': 1, - 'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'HR Manager', - 'submit': 1, - 'write': 1 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - 'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'HR User', - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - 'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'HR Manager', - 'submit': 0, - 'write': 0 + u'doctype': u'DocType', + u'name': u'Leave Application' }, # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'column_break0', 'fieldtype': u'Column Break', 'permlevel': 0, @@ -136,7 +64,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'employee', 'fieldtype': u'Link', 'in_filter': 1, @@ -149,7 +77,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'employee_name', 'fieldtype': u'Data', 'in_filter': 1, @@ -160,7 +88,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'leave_type', 'fieldtype': u'Select', 'in_filter': 1, @@ -173,7 +101,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'leave_balance', 'fieldtype': u'Currency', 'label': u'Leave Balance', @@ -184,7 +112,7 @@ { 'colour': u'White:FFF', 'default': u'Today', - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'posting_date', 'fieldtype': u'Date', 'label': u'Posting Date', @@ -195,7 +123,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'fiscal_year', 'fieldtype': u'Select', 'in_filter': 1, @@ -208,7 +136,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'column_break1', 'fieldtype': u'Column Break', 'permlevel': 0, @@ -218,7 +146,7 @@ # DocField { 'colour': u'White:FFF', - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'half_day', 'fieldtype': u'Check', 'label': u'Half Day', @@ -229,7 +157,7 @@ # DocField { 'colour': u'White:FFF', - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'from_date', 'fieldtype': u'Date', 'label': u'From Date', @@ -241,7 +169,7 @@ # DocField { 'colour': u'White:FFF', - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'to_date', 'fieldtype': u'Date', 'label': u'To Date', @@ -252,7 +180,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'total_leave_days', 'fieldtype': u'Currency', 'label': u'Total Leave Days', @@ -261,7 +189,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'description', 'fieldtype': u'Small Text', 'label': u'Description', @@ -271,7 +199,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'letter_head', 'fieldtype': u'Link', 'label': u'Letter Head', @@ -281,7 +209,7 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'amended_from', 'fieldtype': u'Data', 'label': u'Amended From', @@ -290,10 +218,68 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'amendment_date', 'fieldtype': u'Date', 'label': u'Amendment Date', 'permlevel': 1 + }, + + # DocPerm + { + 'amend': 0, + 'cancel': 0, + 'create': 0, + u'doctype': u'DocPerm', + 'match': u'owner', + 'permlevel': 0, + 'role': u'Employee', + 'submit': 0, + 'write': 0 + }, + + # DocPerm + { + 'amend': 1, + 'cancel': 1, + 'create': 1, + u'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'HR User', + 'submit': 1, + 'write': 1 + }, + + # DocPerm + { + 'amend': 1, + 'cancel': 1, + 'create': 1, + u'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'HR Manager', + 'submit': 1, + 'write': 1 + }, + + # DocPerm + { + u'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'HR User' + }, + + # DocPerm + { + u'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'HR Manager' + }, + + # DocPerm + { + u'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'Employee' } ] \ No newline at end of file diff --git a/erpnext/patches/october_2012/__init__.py b/erpnext/patches/october_2012/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/patches/october_2012/update_permission.py b/erpnext/patches/october_2012/update_permission.py new file mode 100644 index 0000000000..5686a8ebc5 --- /dev/null +++ b/erpnext/patches/october_2012/update_permission.py @@ -0,0 +1,39 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from __future__ import unicode_literals +def execute(): + import webnotes + webnotes.conn.sql(""" + delete from `tabDocPerm` + where + role in ('Sales User', 'Sales Manager', 'Sales Master Manager', + 'Purchase User', 'Purchase Manager', 'Purchase Master Manager') + and parent = 'Sales and Purchase Return Tool' + """) + + webnotes.conn.sql("""delete from `tabDocPerm` where ifnull(role, '') = ''""") + + if not webnotes.conn.sql("""select name from `tabDocPerm` where parent = 'Leave Application' + and role = 'Employee' and permlevel = 1"""): + from webnotes.model.code import get_obj + from webnotes.model.doc import addchild + leave_app = get_obj('DocType', 'Leave Application', with_children=1) + ch = addchild(leave_app.doc, 'permissions', 'DocPerm') + ch.role = 'Employee' + ch.permlevel = 1 + ch.read = 1 + ch.save() \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 92e48a0bcd..8a38a3642d 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -604,4 +604,8 @@ patch_list = [ 'patch_module': 'patches.september_2012', 'patch_file': 'rebuild_trees', }, + { + 'patch_module': 'patches.october_2012', + 'patch_file': 'update_permission', + }, ] diff --git a/erpnext/setup/doctype/price_list/price_list.js b/erpnext/setup/doctype/price_list/price_list.js index 11993f8c3b..0d903a8147 100644 --- a/erpnext/setup/doctype/price_list/price_list.js +++ b/erpnext/setup/doctype/price_list/price_list.js @@ -19,29 +19,29 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.set_intro("Save this list to begin."); return; } - if(!doc.file_list) { - cur_frm.set_intro('

1. Click on "Download Template" \ - to download the template of all Items.

' - +'

2. Update prices and Currency.

' - +'

3. Save it as a CSV (.csv) file.

' - +'

4. Upload the file.

'); + if (wn.boot.profile.can_create.indexOf(cdt) !== -1) { + if(!doc.file_list) { + cur_frm.set_intro('

1. Click on "Download Template" \ + to download the template of all Items.

' + +'

2. Update prices and Currency.

' + +'

3. Save it as a CSV (.csv) file.

' + +'

4. Upload the file.

'); - cur_frm.add_custom_button('Download Template', function() { - $c_obj_csv(cur_frm.get_doclist(), 'download_template'); - }, 'icon-download') + cur_frm.add_custom_button('Download Template', function() { + $c_obj_csv(cur_frm.get_doclist(), 'download_template'); + }, 'icon-download') - cur_frm.add_custom_button('Upload Price List', function() { - cur_frm.attachments.add_attachment(); - }, 'icon-upload') + cur_frm.add_custom_button('Upload Price List', function() { + cur_frm.attachments.add_attachment(); + }, 'icon-upload'); + } else { + cur_frm.set_intro('To update prices from the attachment, click on "Update Prices". \ + To reset prices, delete the attachment (in the sidebar) and upload again.'); - - } else { - cur_frm.set_intro('To update prices from the attachment, click on "Update Prices". \ - To reset prices, delete the attachment (in the sidebar) and upload again.'); - - // Update Prices - cur_frm.add_custom_button('Update Prices', function() { - cur_frm.call_server('update_prices'); - }, 'icon-refresh') + // Update Prices + cur_frm.add_custom_button('Update Prices', function() { + cur_frm.call_server('update_prices'); + }, 'icon-refresh'); + } } } diff --git a/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.txt b/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.txt index 8bec19e38a..0952f1d305 100644 --- a/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.txt +++ b/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - u'creation': '2012-07-03 13:29:45', + u'creation': '2012-09-19 12:24:41', u'docstatus': 0, - u'modified': '2012-09-17 10:55:11', + u'modified': '2012-10-02 10:40:14', u'modified_by': u'Administrator', u'owner': u'wasim@webnotestech.com' }, @@ -230,45 +230,37 @@ # DocPerm { + 'amend': 0, + 'cancel': 0, 'create': 1, u'doctype': u'DocPerm', 'permlevel': 0, - 'role': u'Accounts Manager', + 'role': u'Material User', + 'submit': 0, 'write': 1 }, - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'All' - }, - # DocPerm { 'amend': 0, 'cancel': 0, - 'create': 0, + 'create': 1, u'doctype': u'DocPerm', - 'permlevel': 1, + 'permlevel': 0, + 'role': u'Material Manager', + 'submit': 0, + 'write': 1 + }, + + # DocPerm + { + 'amend': 0, + 'cancel': 0, + 'create': 1, + u'doctype': u'DocPerm', + 'permlevel': 0, 'role': u'System Manager', 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Accounts Manager' - }, - - # DocPerm - { - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Purchase Manager', 'write': 1 }, @@ -277,25 +269,7 @@ 'create': 1, u'doctype': u'DocPerm', 'permlevel': 0, - 'role': u'Purchase User', - 'write': 1 - }, - - # DocPerm - { - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Sales Manager', - 'write': 1 - }, - - # DocPerm - { - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Sales User', + 'role': u'Accounts Manager', 'write': 1 }, @@ -308,98 +282,10 @@ 'write': 1 }, - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'System Manager', - 'submit': 0, - 'write': 1 - }, - # DocPerm { u'doctype': u'DocPerm', 'permlevel': 1, - 'role': u'Accounts User' - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Sales User' - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Sales Manager' - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Purchase User' - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Purchase Manager' - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Material Manager', - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Material Manager', - 'submit': 0, - 'write': 1 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Material User', - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Material User', - 'submit': 0, - 'write': 1 + 'role': u'All' } ] \ No newline at end of file From 32128e82f3542f095a247d29c5c3697276672e1e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 2 Oct 2012 13:25:20 +0530 Subject: [PATCH 10/11] account on_trash fix --- erpnext/accounts/doctype/account/account.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 79ca322cac..7b71bae83c 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -260,11 +260,8 @@ class DocType: def on_trash(self): # Check balance before trash self.check_balance_before_trash() + self.update_nsm_model() - # rebuild tree - from webnotes.utils.nestedset import update_remove_node - update_remove_node('Account', self.doc.name) - # delete all cancelled gl entry of this account sql("delete from `tabGL Entry` where account = %s and ifnull(is_cancelled, 'No') = 'Yes'", self.doc.name) From 47d8947012d3137e198a129c23cf549fc6abcc5c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 2 Oct 2012 14:22:53 +0530 Subject: [PATCH 11/11] get_field replaced with Meta.get_field --- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 2 +- erpnext/hr/doctype/appraisal/appraisal.js | 2 +- erpnext/hr/doctype/appraisal/appraisal.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 9e0a4ebf39..beff75c5ce 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -30,7 +30,7 @@ wn.require('erpnext/setup/doctype/notification_control/notification_control.js') // On Load // ------- cur_frm.cscript.onload = function(doc,dt,dn) { - if(!doc.customer && doc.debit_to) get_field(dt, 'debit_to', dn).print_hide = 0; + if(!doc.customer && doc.debit_to) Meta.get_field(dt, 'debit_to', dn).print_hide = 0; if (doc.__islocal) { //if(!doc.voucher_date) set_multiple(dt,dn,{voucher_date:get_today()}); if(!doc.due_date) set_multiple(dt,dn,{due_date:get_today()}); diff --git a/erpnext/hr/doctype/appraisal/appraisal.js b/erpnext/hr/doctype/appraisal/appraisal.js index fbd7e02214..1243dc48f3 100644 --- a/erpnext/hr/doctype/appraisal/appraisal.js +++ b/erpnext/hr/doctype/appraisal/appraisal.js @@ -53,7 +53,7 @@ cur_frm.cscript.employee = function(doc,cdt,cdn){ $c_obj(make_doclist(doc.doctype, doc.name),'set_approver','', function(r,rt){ if(r.message){ doc.employee_name = r.message['emp_nm']; - get_field(doc.doctype, 'kra_approver' , doc.name).options = r.message['app_lst']; + Meta.get_field(doc.doctype, 'kra_approver' , doc.name).options = r.message['app_lst']; refresh_many(['kra_approver','employee_name']); } }); diff --git a/erpnext/hr/doctype/appraisal/appraisal.py b/erpnext/hr/doctype/appraisal/appraisal.py index 13d2f3ff69..f4047e7428 100644 --- a/erpnext/hr/doctype/appraisal/appraisal.py +++ b/erpnext/hr/doctype/appraisal/appraisal.py @@ -89,6 +89,7 @@ class DocType: self.validate_fiscal_year() def set_approver(self): + errprint('here') ret={} approver_lst =[] emp_nm = self.get_employee_name()