diff --git a/patches/february_2013/p09_timesheets.py b/patches/february_2013/p09_timesheets.py index 2242d6b6291..609dba33bcd 100644 --- a/patches/february_2013/p09_timesheets.py +++ b/patches/february_2013/p09_timesheets.py @@ -49,7 +49,7 @@ def execute(): for key in custom_map["Timesheet Detail"]: tl.doc.fields[key] = tsd.fields.get(key) - tl.make_obj() + tl.make_controller() tl.controller.set_status() tl.controller.calculate_total_hours() tl.doc.insert() diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index 64783a0c601..54a293f6eaa 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -190,33 +190,23 @@ class DocType: self.doc.letter_head = header def set_default_accounts(self): - if not self.doc.receivables_group and webnotes.conn.exists('Account', - 'Accounts Receivable - ' + self.doc.abbr): - webnotes.conn.set(self.doc, 'receivables_group', 'Accounts Receivable - ' + - self.doc.abbr) - - if not self.doc.payables_group and webnotes.conn.exists('Account', - 'Accounts Payable - ' + self.doc.abbr): - webnotes.conn.set(self.doc, 'payables_group', 'Accounts Payable - ' + self.doc.abbr) - - if not self.doc.stock_received_but_not_billed and webnotes.conn.exists("Account", - "Stock Received But Not Billed - " + self.doc.abbr): - webnotes.conn.set(self.doc, "stock_received_but_not_billed", - "Stock Received But Not Billed - " + self.doc.abbr) - - if not self.doc.stock_adjustment_account and webnotes.conn.exists("Account", - "Stock Adjustment - " + self.doc.abbr): - webnotes.conn.set(self.doc, "stock_adjustment_account", "Stock Adjustment - " + - self.doc.abbr) - - if not self.doc.expenses_included_in_valuation and webnotes.conn.exists("Account", - "Expenses Included In Valuation - " + self.doc.abbr): - webnotes.conn.set(self.doc, "expenses_included_in_valuation", - "Expenses Included In Valuation - " + self.doc.abbr) + accounts = { + "receivables_group": "Accounts Receivable", + "payables_group": "Accounts Payable", + "stock_received_but_not_billed": "Stock Received But Not Billed", + "stock_in_hand_account": "Stock In Hand", + "stock_adjustment_account": "Stock Adjustment", + "expenses_included_in_valuation": "Expenses Included In Valuation" + } + for a in accounts: + account_name = accounts[a] + " - " + self.doc.abbr + if not self.doc.fields[a] and webnotes.conn.exists("Account", account_name): + webnotes.conn.set(self.doc, account_name) + if not self.doc.stock_adjustment_cost_center: webnotes.conn.set(self.doc, "stock_adjustment_cost_center", self.doc.cost_center) - + # Create default cost center # --------------------------------------------------- def create_default_cost_center(self): @@ -249,8 +239,7 @@ class DocType: where company=%s and docstatus<2 limit 1""", self.doc.name): self.create_default_accounts() - if not webnotes.conn.sql("""select name from `tabCost Center` - where cost_center_name = 'All Units' and company_name = %s""", self.doc.name): + if not self.doc.cost_center: self.create_default_cost_center() self.set_default_accounts() diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 3cde2e20c94..3492931451a 100644 --- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -119,4 +119,13 @@ class DocType(DocListController): def scrub_posting_time(self): if not self.doc.posting_time or self.doc.posting_time == '00:0': self.doc.posting_time = '00:00' - \ No newline at end of file + + def on_doctype_update(self): + webnotes.msgprint(webnotes.conn.sql("""show index from `tabStock Ledger Entry` + where Key_name="posting_sort_index" """)) + if not webnotes.conn.sql("""show index from `tabStock Ledger Entry` + where Key_name="posting_sort_index" """): + webnotes.conn.commit() + webnotes.conn.sql("""alter table `tabStock Ledger Entry` + add index posting_sort_index(posting_date, posting_time, name)""") + webnotes.conn.begin() \ No newline at end of file diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt b/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt index 6bcd7587330..674104dfeba 100644 --- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt +++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-29 19:25:42", "docstatus": 0, - "modified": "2013-03-25 16:04:59", + "modified": "2013-06-28 12:39:07", "modified_by": "Administrator", "owner": "Administrator" }, diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py index 49e8b155475..8e5698c4e27 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -45,9 +45,12 @@ class DocType(StockController): return data = json.loads(self.doc.reconciliation_json) + + # strip out extra columns (if any) + data = [row[:4] for row in data] + if self.head_row not in data: - msgprint(_("""Hey! You seem to be using the wrong template. \ - Click on 'Download Template' button to get the correct template."""), + msgprint(_("""Wrong Template: Unable to find head row."""), raise_exception=1) # remove the help part and save the json diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py index 264e459e564..758bd31eb0e 100644 --- a/stock/doctype/warehouse/warehouse.py +++ b/stock/doctype/warehouse/warehouse.py @@ -42,7 +42,7 @@ class DocType: bin_wrapper.ignore_permissions = 1 bin_wrapper.insert() - bin_obj = bin_wrapper.make_obj() + bin_obj = bin_wrapper.make_controller() else: bin_obj = get_obj('Bin', bin) return bin_obj