From 7ff69e10bfac9e034f14d80247a5b0c9dcb92b40 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 27 Apr 2012 18:27:06 +0530 Subject: [PATCH 01/10] repost stock for entries where posting time goes wrong --- .../patches/april_2012/repost_stock_for_posting_time.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 erpnext/patches/april_2012/repost_stock_for_posting_time.py diff --git a/erpnext/patches/april_2012/repost_stock_for_posting_time.py b/erpnext/patches/april_2012/repost_stock_for_posting_time.py new file mode 100644 index 0000000000..258a622be9 --- /dev/null +++ b/erpnext/patches/april_2012/repost_stock_for_posting_time.py @@ -0,0 +1,9 @@ +def execute(): + import webnotes + from webnotes.model.code import get_obj + + bins = sql("select distinct t2.name from `tabStock Ledger Entry` t1, tabBin t2 where t1.posting_time > '00:00:00' and t1.posting_time < '00:01:00' and t1.item_code = t2.item_code and t1.warehouse = t2.warehouse") + sql("update `tabStock Ledger Entry` set posting_time = '00:00:00' where posting_time > '00:00:00' and posting_time < '00:01:00'") + + for d in bins: + get_obj('Bin', d[0]).update_entries_after(posting_date = '2000-01-01', posting_time = '12:01') From fc51f995c82df41ca792482979a9b49d83be11c3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 30 Apr 2012 11:43:16 +0530 Subject: [PATCH 02/10] fixes in bin --- erpnext/stock/doctype/bin/bin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py index 2b680e525d..24c47fc84c 100644 --- a/erpnext/stock/doctype/bin/bin.py +++ b/erpnext/stock/doctype/bin/bin.py @@ -325,7 +325,7 @@ class DocType: where name=%s""", (cqty, flt(val_rate), cstr(self.fcfs_bal), stock_val, sle['name'])) # update the bin - if sll: + if sll or not prev_sle: sql("update `tabBin` set valuation_rate=%s, actual_qty=%s, stock_value = %s where name=%s", \ (flt(val_rate), cqty, flt(stock_val), self.doc.name)) From 3e8f35c09e40ae211f69cc2c8fa97133ebcdaec4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 30 Apr 2012 11:47:45 +0530 Subject: [PATCH 03/10] fixes in bin --- erpnext/stock/doctype/bin/bin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py index 24c47fc84c..1c2b53e5e5 100644 --- a/erpnext/stock/doctype/bin/bin.py +++ b/erpnext/stock/doctype/bin/bin.py @@ -270,7 +270,7 @@ class DocType: # if no prev sle, start from the first one (for repost) if not prev_sle: - cqty, cval, val_rate, self.fcfs_bal = 0, 0, 0, [] + cqty, cval, val_rate, stock_val, self.fcfs_bal = 0, 0, 0, 0, [] # normal else: From d4c5a9e2c42df6c134b8cee09152dea2bd9e4f4a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 30 Apr 2012 11:50:34 +0530 Subject: [PATCH 04/10] fixes in bin --- erpnext/stock/doctype/bin/bin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py index 1c2b53e5e5..da9eafd961 100644 --- a/erpnext/stock/doctype/bin/bin.py +++ b/erpnext/stock/doctype/bin/bin.py @@ -326,7 +326,7 @@ class DocType: # update the bin if sll or not prev_sle: - sql("update `tabBin` set valuation_rate=%s, actual_qty=%s, stock_value = %s where name=%s", \ + sql("update `tabBin` set valuation_rate=%s, actual_qty=%s, stock_value = %s, projected_qty = (actual_qty + indented_qty + ordered_qty + planned_qty - reserved_qty) where name=%s", \ (flt(val_rate), cqty, flt(stock_val), self.doc.name)) From d1ac71c3e72721eb59a063aecca9fa77cc4a42f1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 30 Apr 2012 11:53:58 +0530 Subject: [PATCH 05/10] patch list updated --- erpnext/patches/patch_list.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 65448859d2..f7b82f3ff6 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -252,5 +252,10 @@ patch_list = [ 'patch_file': 'serial_no_fixes', 'description': 'fixes for sle creation while import' }, + { + 'patch_module': 'patches.april_2012', + 'patch_file': 'repost_stock_for_posting_time', + 'description': 'repost stock for posting time 00:00:seconds' + }, ] From 28b9551acf838964cbb2551cd133a20c307a3c34 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 30 Apr 2012 11:55:25 +0530 Subject: [PATCH 06/10] fixes in patch --- erpnext/patches/april_2012/repost_stock_for_posting_time.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/patches/april_2012/repost_stock_for_posting_time.py b/erpnext/patches/april_2012/repost_stock_for_posting_time.py index 258a622be9..095449ab5d 100644 --- a/erpnext/patches/april_2012/repost_stock_for_posting_time.py +++ b/erpnext/patches/april_2012/repost_stock_for_posting_time.py @@ -2,8 +2,8 @@ def execute(): import webnotes from webnotes.model.code import get_obj - bins = sql("select distinct t2.name from `tabStock Ledger Entry` t1, tabBin t2 where t1.posting_time > '00:00:00' and t1.posting_time < '00:01:00' and t1.item_code = t2.item_code and t1.warehouse = t2.warehouse") - sql("update `tabStock Ledger Entry` set posting_time = '00:00:00' where posting_time > '00:00:00' and posting_time < '00:01:00'") + bins = webnotes.conn.sql("select distinct t2.name from `tabStock Ledger Entry` t1, tabBin t2 where t1.posting_time > '00:00:00' and t1.posting_time < '00:01:00' and t1.item_code = t2.item_code and t1.warehouse = t2.warehouse") + webnotes.conn.sql("update `tabStock Ledger Entry` set posting_time = '00:00:00' where posting_time > '00:00:00' and posting_time < '00:01:00'") for d in bins: get_obj('Bin', d[0]).update_entries_after(posting_date = '2000-01-01', posting_time = '12:01') From 41cc32790f6faad95ec01261217f46b87ec189a2 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 30 Apr 2012 14:36:18 +0530 Subject: [PATCH 07/10] Fixed issie in auto notification --- erpnext/hr/doctype/expense_voucher/expense_voucher.js | 3 ++- erpnext/hr/doctype/expense_voucher/expense_voucher.py | 7 +++++-- erpnext/selling/doctype/sales_order/sales_order.py | 3 ++- .../doctype/notification_control/notification_control.py | 2 +- erpnext/utilities/transaction_base.py | 6 ++++++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/erpnext/hr/doctype/expense_voucher/expense_voucher.js b/erpnext/hr/doctype/expense_voucher/expense_voucher.js index 2e03567751..dac5543536 100644 --- a/erpnext/hr/doctype/expense_voucher/expense_voucher.js +++ b/erpnext/hr/doctype/expense_voucher/expense_voucher.js @@ -248,7 +248,8 @@ $import(Notification Control) cur_frm.cscript.on_submit = function(doc, cdt, cdn) { var args = { type: 'Expense Voucher', - doctype: 'Expense Voucher' + doctype: 'Expense Voucher', + send_to: doc.exp_approver } cur_frm.cscript.notify(doc, args); } diff --git a/erpnext/hr/doctype/expense_voucher/expense_voucher.py b/erpnext/hr/doctype/expense_voucher/expense_voucher.py index b349100300..a29682cf6c 100644 --- a/erpnext/hr/doctype/expense_voucher/expense_voucher.py +++ b/erpnext/hr/doctype/expense_voucher/expense_voucher.py @@ -98,8 +98,6 @@ class DocType: set(self.doc, 'remark', self.doc.remark) set(self.doc, 'approval_status', 'Rejected') - # on approval notification - #get_obj('Notification Control').notify_contact('Expense Voucher Rejected', self.doc.doctype, self.doc.name, self.doc.email_id, self.doc.employee_name) return cstr('Rejected') @@ -157,3 +155,8 @@ class DocType: def on_cancel(self): set(self.doc, 'approval_status', 'Cancelled') + + + def get_formatted_message(self, args): + """ get formatted message for auto notification""" + return get_obj('Notification Control').get_formatted_message(args) diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index c886ec38b6..ca248b73a6 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -90,7 +90,8 @@ class DocType(TransactionBase): # ------------------------------------- def get_comm_rate(self, sales_partner): return get_obj('Sales Common').get_comm_rate(sales_partner, self) - + + # Clear Sales Order Details Table # -------------------------------- def clear_sales_order_details(self): diff --git a/erpnext/setup/doctype/notification_control/notification_control.py b/erpnext/setup/doctype/notification_control/notification_control.py index 61f558765f..fabd7d8dd9 100644 --- a/erpnext/setup/doctype/notification_control/notification_control.py +++ b/erpnext/setup/doctype/notification_control/notification_control.py @@ -23,7 +23,7 @@ from webnotes.model.code import get_obj from webnotes import msgprint sql = webnotes.conn.sql - + # ----------------------------------------------------------------------------------------- # Notification control class DocType: diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 032b52faa6..41fec67b56 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -18,6 +18,7 @@ import webnotes from webnotes.utils import load_json, cint, cstr, flt, get_defaults from webnotes.model.doc import Document, addchild, removechild, getchildren from webnotes.model.doclist import getlist, copy_doclist +from webnotes.model.code import get_obj from webnotes import msgprint class TransactionBase: @@ -225,3 +226,8 @@ class TransactionBase: ret = webnotes.conn.sql("select default_currency from tabCompany where name = '%s'" %(name)) dcc = ret and ret[0][0] or get_defaults()['currency'] return dcc + + + def get_formatted_message(self, args): + """ get formatted message for auto notification""" + return get_obj('Notification Control').get_formatted_message(args) From 228d03ec018a156e360028ec7a9ca486129caad3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 30 Apr 2012 16:59:39 +0530 Subject: [PATCH 08/10] posting time fix --- .../stock/doctype/stock_ledger_entry/stock_ledger_entry.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 0417f6bae9..c435e86990 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -99,6 +99,12 @@ class DocType: you entered posting time correctly, please contact ERPNext support team.") raise Exception + def scrub_posting_time(self): + if not self.doc.posting_time or self.doc.posting_time == '12:0': + self.doc.posting_time = '00:00' + if len(self.doc.posting_time.split(':')) > 2: + self.doc.posting_time = '00:00' + def validate(self): self.validate_mandatory() @@ -106,3 +112,4 @@ class DocType: self.validate_item() self.actual_amt_check() self.check_stock_frozen_date() + self.scrub_posting_time() From 41c62727c78703813d4bcddb0d70115a0085d548 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 1 May 2012 10:45:47 +0530 Subject: [PATCH 09/10] fixes in validattion of debit to account with customer in sales invoice --- .../receivable_voucher/receivable_voucher.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py index 446a116c99..2d1db216b8 100644 --- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py +++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py @@ -313,15 +313,13 @@ class DocType(TransactionBase): # Validates Debit To Account and Customer Matches # ------------------------------------------------ def validate_debit_to_acc(self): - if self.doc.customer and not cint(self.doc.is_pos): - acc_head = webnotes.conn.sql("select name from `tabAccount` where name = %s and docstatus != 2", (cstr(self.doc.customer) + " - " + self.get_company_abbr())) - if acc_head and acc_head[0][0]: - if not cstr(acc_head[0][0]) == cstr(self.doc.debit_to): - msgprint("Debit To %s do not match with Customer %s for Company %s i.e. %s" %(self.doc.debit_to,self.doc.customer,self.doc.company,cstr(acc_head[0][0]))) - raise Exception, "Validation Error " - if not acc_head: - msgprint("%s does not have an Account Head in %s. You must first create it from the Customer Master" % (self.doc.customer, self.doc.company)) - raise Exception, "Validation Error " + if self.doc.customer and self.doc.debit_to and not cint(self.doc.is_pos): + acc_head = sql("select master_name from `tabAccount` where name = %s and docstatus != 2", self.doc.debit_to) + + if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.customer)) or \ + (not acc_head and (self.doc.debit_to != cstr(self.doc.customer) + " - " + self.get_company_abbr())): + msgprint("Debit To: %s do not match with Customer: %s for Company: %s.\n If both correctly entered, please select Master Type \ + and Master Name in account master." %(self.doc.debit_to, self.doc.customer,self.doc.company), raise_exception=1) # Validate Debit To Account From 1e335f3272ead746a7bb9f10e05a161a2c079289 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 1 May 2012 10:53:50 +0530 Subject: [PATCH 10/10] fixes in validattion of debit to account with customer in sales invoice --- .../accounts/doctype/receivable_voucher/receivable_voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py index 2d1db216b8..54ed7514a0 100644 --- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py +++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py @@ -314,7 +314,7 @@ class DocType(TransactionBase): # ------------------------------------------------ def validate_debit_to_acc(self): if self.doc.customer and self.doc.debit_to and not cint(self.doc.is_pos): - acc_head = sql("select master_name from `tabAccount` where name = %s and docstatus != 2", self.doc.debit_to) + acc_head = webnotes.conn.sql("select master_name from `tabAccount` where name = %s and docstatus != 2", self.doc.debit_to) if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.customer)) or \ (not acc_head and (self.doc.debit_to != cstr(self.doc.customer) + " - " + self.get_company_abbr())):