diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py index eb65604e02..bdc26e46ce 100644 --- a/accounts/doctype/account/account.py +++ b/accounts/doctype/account/account.py @@ -187,7 +187,7 @@ class DocType: sql("""delete from `tabGL Entry` where account = %s and ifnull(is_cancelled, 'No') = 'Yes'""", self.doc.name) - def on_rename(self, new, old): + def on_rename(self, new, old, merge=False): company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr") parts = new.split(" - ") diff --git a/accounts/doctype/c_form/c_form.py b/accounts/doctype/c_form/c_form.py index 9f89ad5d07..25a8c3bfc1 100644 --- a/accounts/doctype/c_form/c_form.py +++ b/accounts/doctype/c_form/c_form.py @@ -17,16 +17,12 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import flt, getdate -from webnotes.model.doc import make_autoname from webnotes.model.bean import getlist class DocType: def __init__(self,d,dl): self.doc, self.doclist = d,dl - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series + '.#####') - def validate(self): """Validate invoice that c-form is applicable and no other c-form is received for that""" diff --git a/accounts/doctype/cost_center/cost_center.py b/accounts/doctype/cost_center/cost_center.py index a7672452aa..4e9b7fd9e7 100644 --- a/accounts/doctype/cost_center/cost_center.py +++ b/accounts/doctype/cost_center/cost_center.py @@ -29,7 +29,7 @@ class DocType(DocTypeNestedSet): def autoname(self): company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s", self.doc.company_name)[0][0] - self.doc.name = self.doc.cost_center_name + ' - ' + company_abbr + self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr def validate_mandatory(self): if not self.doc.group_or_ledger: @@ -87,7 +87,7 @@ class DocType(DocTypeNestedSet): self.validate_mandatory() self.validate_budget_details() - def on_rename(self, new, old): + def on_rename(self, new, old, merge=False): company_abbr = webnotes.conn.get_value("Company", self.doc.company_name, "abbr") parts = new.split(" - ") diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py index f7d4035a58..a5a4f10f34 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.py +++ b/accounts/doctype/journal_voucher/journal_voucher.py @@ -34,11 +34,6 @@ class DocType(AccountsController): self.credit_days_global = -1 self.is_approving_authority = -1 - def autoname(self): - if not self.doc.naming_series: - webnotes.msgprint("""Naming Series is mandatory""", raise_exception=1) - self.doc.name = make_autoname(self.doc.naming_series+'.#####') - def validate(self): if not self.doc.is_opening: self.doc.is_opening='No' diff --git a/accounts/doctype/journal_voucher/test_journal_voucher.py b/accounts/doctype/journal_voucher/test_journal_voucher.py index 7cfeb595d8..feb1e2ca5a 100644 --- a/accounts/doctype/journal_voucher/test_journal_voucher.py +++ b/accounts/doctype/journal_voucher/test_journal_voucher.py @@ -122,119 +122,4 @@ test_records = [ "parentfield": "entries", "cost_center": "_Test Cost Center - _TC" }], -] - - - - - - -# -# -# import webnotes.model -# from webnotes.utils import nowdate, flt, add_days -# from accounts.utils import get_fiscal_year, get_balance_on -# -# company = webnotes.conn.get_default("company") -# abbr = webnotes.conn.get_value("Company", company, "abbr") -# -# data = { -# "expense_account": { -# "doctype": "Account", -# "account_name": "Test Expense", -# "parent_account": "Direct Expenses - %s" % abbr, -# "company": company, -# "debit_or_credit": "Debit", -# "is_pl_account": "Yes", -# "group_or_ledger": "Ledger" -# }, -# "supplier_account": { -# "doctype": "Account", -# "account_name": "Test Supplier", -# "parent_account": "Accounts Payable - %s" % abbr, -# "company": company, -# "debit_or_credit": "Credit", -# "is_pl_account": "No", -# "group_or_ledger": "Ledger" -# }, -# "test_cost_center": { -# "doctype": "Cost Center", -# "cost_center_name": "Test Cost Center", -# "parent_cost_center": "Root - %s" % abbr, -# "company_name": company, -# "group_or_ledger": "Ledger", -# "company_abbr": abbr -# }, -# "journal_voucher": [ -# { -# "doctype": "Journal Voucher", -# "voucher_type": "Journal Entry", -# "naming_series": "JV", -# "posting_date": nowdate(), -# "remark": "Test Journal Voucher", -# "fiscal_year": get_fiscal_year(nowdate())[0], -# "company": company -# }, -# { -# "doctype": "Journal Voucher Detail", -# "parentfield": "entries", -# "account": "Test Expense - %s" % abbr, -# "debit": 5000, -# "cost_center": "Test Cost Center - %s" % abbr, -# }, -# { -# "doctype": "Journal Voucher Detail", -# "parentfield": "entries", -# "account": "Test Supplier - %s" % abbr, -# "credit": 5000, -# }, -# ] -# } -# -# def get_name(s): -# return s + " - " + abbr -# -# class TestJournalVoucher(unittest.TestCase): -# def setUp(self): -# webnotes.conn.begin() -# -# # create a dummy account -# webnotes.model.insert([data["expense_account"]]) -# webnotes.model.insert([data["supplier_account"]]) -# webnotes.model.insert([data["test_cost_center"]]) -# -# def tearDown(self): -# webnotes.conn.rollback() -# -# def test_save_journal_voucher(self): -# expense_ac_balance = get_balance_on(get_name("Test Expense"), nowdate()) -# supplier_ac_balance = get_balance_on(get_name("Test Supplier"), nowdate()) -# -# dl = webnotes.model.insert(data["journal_voucher"]) -# dl.submit() -# dl.load_from_db() -# -# # test submitted jv -# self.assertTrue(webnotes.conn.exists("Journal Voucher", dl.doclist[0].name)) -# for d in dl.doclist[1:]: -# self.assertEquals(webnotes.conn.get_value("Journal Voucher Detail", -# d.name, "parent"), dl.doclist[0].name) -# -# # test gl entry -# gle = webnotes.conn.sql("""select account, debit, credit -# from `tabGL Entry` where voucher_no = %s order by account""", -# dl.doclist[0].name) -# -# self.assertEquals((gle[0][0], flt(gle[0][1]), flt(gle[0][2])), -# ('Test Expense - %s' % abbr, 5000.0, 0.0)) -# self.assertEquals((gle[1][0], flt(gle[1][1]), flt(gle[1][2])), -# ('Test Supplier - %s' % abbr, 0.0, 5000.0)) -# -# # check balance as on today -# self.assertEqual(get_balance_on(get_name("Test Expense"), nowdate()), -# expense_ac_balance + 5000) -# self.assertEqual(get_balance_on(get_name("Test Supplier"), nowdate()), -# supplier_ac_balance + 5000) -# -# # check previous balance -# self.assertEqual(get_balance_on(get_name("Test Expense"), add_days(nowdate(), -1)), 0) \ No newline at end of file +] \ No newline at end of file diff --git a/accounts/doctype/pos_setting/pos_setting.txt b/accounts/doctype/pos_setting/pos_setting.txt index 80cb1ecdc9..788af9ee06 100755 --- a/accounts/doctype/pos_setting/pos_setting.txt +++ b/accounts/doctype/pos_setting/pos_setting.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-04-30 12:58:25", + "creation": "2013-05-09 13:16:11", "docstatus": 0, - "modified": "2013-05-03 14:36:24", + "modified": "2013-05-23 12:52:09", "modified_by": "Administrator", "owner": "Administrator" }, @@ -213,6 +213,14 @@ "options": "link:Print Heading" }, { + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "role": "System Manager", + "write": 1 + }, + { + "cancel": 1, "create": 1, "doctype": "DocPerm", "role": "Accounts Manager", diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index 50d5d43d80..c53b6d94fc 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -464,15 +464,17 @@ class DocType(BuyingController): # if auto inventory accounting enabled and stock item, # then do stock related gl entries # expense will be booked in sales invoice - stock_item_and_auto_inventory_accounting = True + valuation_amt = (flt(item.amount, self.precision.item.amount) + + flt(item.item_tax_amount, self.precision.item.item_tax_amount) + + flt(item.rm_supp_cost, self.precision.item.rm_supp_cost)) + gl_entries.append( self.get_gl_dict({ "account": stock_account, "against": self.doc.credit_to, - "debit": flt(item.valuation_rate) * flt(item.conversion_factor) \ - * flt(item.qty), + "debit": valuation_amt, "remarks": self.doc.remarks or "Accounting Entry for Stock" }) ) diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.txt b/accounts/doctype/purchase_invoice/purchase_invoice.txt index 43d2c790fc..283c612371 100755 --- a/accounts/doctype/purchase_invoice/purchase_invoice.txt +++ b/accounts/doctype/purchase_invoice/purchase_invoice.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-04-09 10:18:10", + "creation": "2013-05-07 13:50:30", "docstatus": 0, - "modified": "2013-03-22 18:17:14", + "modified": "2013-05-13 11:12:56", "modified_by": "Administrator", "owner": "Administrator" }, @@ -30,7 +30,9 @@ "parent": "Purchase Invoice", "parentfield": "permissions", "parenttype": "DocType", - "read": 1 + "permlevel": 0, + "read": 1, + "report": 1 }, { "doctype": "DocType", @@ -41,6 +43,7 @@ "fieldname": "column_break0", "fieldtype": "Column Break", "oldfieldtype": "Column Break", + "read_only": 0, "width": "50%" }, { @@ -54,6 +57,7 @@ "oldfieldtype": "Select", "options": "BILL\nBILLJ", "print_hide": 1, + "read_only": 0, "report_hide": 0, "reqd": 1 }, @@ -68,6 +72,7 @@ "oldfieldtype": "Link", "options": "Account", "print_hide": 1, + "read_only": 0, "reqd": 1, "search_index": 1 }, @@ -80,7 +85,8 @@ "oldfieldname": "supplier", "oldfieldtype": "Link", "options": "Supplier", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -131,6 +137,7 @@ "fieldname": "column_break1", "fieldtype": "Column Break", "oldfieldtype": "Column Break", + "read_only": 0, "reqd": 0, "width": "50%" }, @@ -146,6 +153,7 @@ "oldfieldname": "posting_date", "oldfieldtype": "Date", "print_hide": 1, + "read_only": 0, "reqd": 1, "search_index": 1 }, @@ -159,6 +167,7 @@ "oldfieldname": "bill_no", "oldfieldtype": "Data", "print_hide": 1, + "read_only": 0, "reqd": 1, "search_index": 1 }, @@ -171,6 +180,7 @@ "oldfieldname": "bill_date", "oldfieldtype": "Date", "print_hide": 1, + "read_only": 0, "reqd": 0, "search_index": 1 }, @@ -179,7 +189,8 @@ "fieldname": "items", "fieldtype": "Section Break", "label": "Items", - "oldfieldtype": "Section Break" + "oldfieldtype": "Section Break", + "read_only": 0 }, { "allow_on_submit": 1, @@ -189,25 +200,29 @@ "label": "Entries", "oldfieldname": "entries", "oldfieldtype": "Table", - "options": "Purchase Invoice Item" + "options": "Purchase Invoice Item", + "read_only": 0 }, { "doctype": "DocField", "fieldname": "section_break0", - "fieldtype": "Section Break" + "fieldtype": "Section Break", + "read_only": 0 }, { "doctype": "DocField", "fieldname": "recalculate", "fieldtype": "Button", "label": "Recalculate", - "oldfieldtype": "Button" + "oldfieldtype": "Button", + "read_only": 0 }, { "doctype": "DocField", "fieldname": "section_break_17", "fieldtype": "Section Break", - "options": "Simple" + "options": "Simple", + "read_only": 0 }, { "description": "Select Items from Purchase Order", @@ -218,7 +233,8 @@ "oldfieldname": "purchase_order_main", "oldfieldtype": "Link", "options": "Purchase Order", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "description": "Select Items from Purchase Receipt", @@ -229,7 +245,8 @@ "oldfieldname": "purchase_receipt_main", "oldfieldtype": "Link", "options": "Purchase Receipt", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -237,13 +254,15 @@ "fieldtype": "Button", "label": "Get Items", "oldfieldtype": "Button", - "options": "pull_details" + "options": "pull_details", + "read_only": 0 }, { "doctype": "DocField", "fieldname": "currency_price_list", "fieldtype": "Section Break", - "label": "Currency & Price List" + "label": "Currency & Price List", + "read_only": 0 }, { "doctype": "DocField", @@ -253,7 +272,8 @@ "oldfieldname": "currency", "oldfieldtype": "Select", "options": "Currency", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "default": "1", @@ -264,12 +284,14 @@ "label": "Exchange Rate", "oldfieldname": "conversion_rate", "oldfieldtype": "Currency", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", "fieldname": "column_break2", - "fieldtype": "Column Break" + "fieldtype": "Column Break", + "read_only": 0 }, { "description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)", @@ -278,7 +300,8 @@ "fieldtype": "Link", "label": "Price List", "options": "Price List", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "depends_on": "price_list_name", @@ -287,7 +310,8 @@ "fieldtype": "Link", "label": "Price List Currency", "options": "Currency", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "depends_on": "price_list_name", @@ -295,7 +319,8 @@ "fieldname": "plc_conversion_rate", "fieldtype": "Float", "label": "Price List Exchange Rate", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "description": "Add / Edit Taxes and Charges", @@ -303,7 +328,8 @@ "fieldname": "taxes", "fieldtype": "Section Break", "label": "Taxes", - "oldfieldtype": "Section Break" + "oldfieldtype": "Section Break", + "read_only": 0 }, { "doctype": "DocField", @@ -313,7 +339,8 @@ "oldfieldname": "purchase_other_charges", "oldfieldtype": "Link", "options": "Purchase Taxes and Charges Master", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -322,7 +349,8 @@ "label": "Get Tax Detail", "oldfieldtype": "Button", "options": "get_purchase_tax_details", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -331,7 +359,8 @@ "label": "Purchase Taxes and Charges", "oldfieldname": "purchase_tax_details", "oldfieldtype": "Table", - "options": "Purchase Taxes and Charges" + "options": "Purchase Taxes and Charges", + "read_only": 0 }, { "doctype": "DocField", @@ -339,7 +368,8 @@ "fieldtype": "Button", "label": "Calculate Tax", "oldfieldtype": "Button", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -347,7 +377,8 @@ "fieldtype": "HTML", "label": "Tax Calculation", "oldfieldtype": "HTML", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -364,7 +395,8 @@ "doctype": "DocField", "fieldname": "contact_section", "fieldtype": "Section Break", - "label": "Contact Info" + "label": "Contact Info", + "read_only": 0 }, { "depends_on": "eval:doc.supplier", @@ -372,12 +404,14 @@ "fieldname": "supplier_address", "fieldtype": "Link", "label": "Supplier Address", - "options": "Address" + "options": "Address", + "read_only": 0 }, { "doctype": "DocField", "fieldname": "col_break23", "fieldtype": "Column Break", + "read_only": 0, "width": "50%" }, { @@ -387,14 +421,16 @@ "fieldtype": "Link", "label": "Contact Person", "options": "Contact", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", "fieldname": "totals", "fieldtype": "Section Break", "label": "Totals", - "oldfieldtype": "Section Break" + "oldfieldtype": "Section Break", + "read_only": 0 }, { "doctype": "DocField", @@ -497,6 +533,7 @@ "fieldtype": "Column Break", "oldfieldtype": "Column Break", "print_hide": 1, + "read_only": 0, "width": "50%" }, { @@ -562,7 +599,8 @@ "label": "Write Off Amount", "no_copy": 1, "options": "Company:company:default_currency", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "depends_on": "eval:flt(doc.write_off_amount)!=0", @@ -572,7 +610,8 @@ "label": "Write Off Account", "no_copy": 1, "options": "Account", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "depends_on": "eval:flt(doc.write_off_amount)!=0", @@ -581,8 +620,9 @@ "fieldtype": "Link", "label": "Write Off Cost Center", "no_copy": 1, - "options": "Account", - "print_hide": 1 + "options": "Cost Center", + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -594,6 +634,7 @@ "oldfieldname": "against_expense_account", "oldfieldtype": "Small Text", "print_hide": 1, + "read_only": 0, "report_hide": 0 }, { @@ -602,7 +643,8 @@ "fieldtype": "Section Break", "label": "Advances", "oldfieldtype": "Section Break", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -611,7 +653,8 @@ "label": "Get Advances Paid", "oldfieldtype": "Button", "options": "get_advances", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -622,7 +665,8 @@ "oldfieldname": "advance_allocation_details", "oldfieldtype": "Table", "options": "Purchase Invoice Advance", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -630,7 +674,8 @@ "fieldtype": "Section Break", "label": "More Info", "oldfieldtype": "Section Break", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "default": "No", @@ -644,6 +689,7 @@ "oldfieldtype": "Select", "options": "No\nYes", "print_hide": 1, + "read_only": 0, "search_index": 1 }, { @@ -655,6 +701,7 @@ "oldfieldname": "aging_date", "oldfieldtype": "Date", "print_hide": 1, + "read_only": 0, "search_index": 0 }, { @@ -680,6 +727,7 @@ "oldfieldtype": "Link", "options": "Print Heading", "print_hide": 1, + "read_only": 0, "report_hide": 1 }, { @@ -692,6 +740,7 @@ "oldfieldname": "due_date", "oldfieldtype": "Date", "print_hide": 0, + "read_only": 0, "search_index": 1 }, { @@ -701,12 +750,14 @@ "label": "Mode of Payment", "oldfieldname": "mode_of_payment", "oldfieldtype": "Select", - "options": "link:Mode of Payment" + "options": "link:Mode of Payment", + "read_only": 0 }, { "doctype": "DocField", "fieldname": "column_break_63", - "fieldtype": "Column Break" + "fieldtype": "Column Break", + "read_only": 0 }, { "doctype": "DocField", @@ -718,6 +769,7 @@ "oldfieldtype": "Link", "options": "Company", "print_hide": 1, + "read_only": 0, "search_index": 1 }, { @@ -730,6 +782,7 @@ "oldfieldtype": "Select", "options": "link:Fiscal Year", "print_hide": 1, + "read_only": 0, "search_index": 1 }, { @@ -753,81 +806,53 @@ "oldfieldname": "remarks", "oldfieldtype": "Text", "print_hide": 1, + "read_only": 0, "reqd": 0 }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "match": "", - "permlevel": 1, - "report": 0, - "role": "Accounts Manager", - "submit": 0, - "write": 0 - }, { "amend": 1, "cancel": 1, "create": 1, "doctype": "DocPerm", - "permlevel": 0, - "report": 1, - "role": "Accounts Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "match": "", - "permlevel": 1, - "report": 0, - "role": "Accounts User", - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "match": "", - "permlevel": 1, - "role": "Purchase User", - "submit": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "doctype": "DocPerm", - "match": "", - "permlevel": 0, - "report": 1, - "role": "Purchase User", - "submit": 0, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "doctype": "DocPerm", - "permlevel": 0, - "report": 1, "role": "Accounts User", "submit": 1, "write": 1 }, { + "amend": 0, + "cancel": 0, + "create": 1, + "doctype": "DocPerm", + "role": "Purchase User", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, "doctype": "DocPerm", "match": "supplier", - "permlevel": 0, - "report": 1, - "role": "Supplier" + "role": "Supplier", + "submit": 0, + "write": 0 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "role": "Accounts Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "doctype": "DocPerm", + "role": "Auditor", + "submit": 0, + "write": 0 } ] \ No newline at end of file diff --git a/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt b/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt index e33ab7c569..8df4306f57 100755 --- a/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt +++ b/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-04-10 08:35:38", + "creation": "2013-04-19 11:00:07", "docstatus": 0, - "modified": "2013-04-17 14:05:20", + "modified": "2013-05-22 12:01:56", "modified_by": "Administrator", "owner": "Administrator" }, @@ -224,6 +224,7 @@ "fieldtype": "Link", "in_filter": 1, "label": "Pur Order", + "no_copy": 1, "oldfieldname": "purchase_order", "oldfieldtype": "Link", "options": "Purchase Order", @@ -238,6 +239,7 @@ "hidden": 1, "in_filter": 1, "label": "Purchase Order Item", + "no_copy": 1, "oldfieldname": "po_detail", "oldfieldtype": "Data", "print_hide": 1, @@ -250,6 +252,7 @@ "fieldtype": "Link", "in_filter": 1, "label": "Pur Receipt", + "no_copy": 1, "oldfieldname": "purchase_receipt", "oldfieldtype": "Link", "options": "Purchase Receipt", @@ -264,6 +267,7 @@ "hidden": 1, "in_filter": 1, "label": "PR Detail", + "no_copy": 1, "oldfieldname": "pr_detail", "oldfieldtype": "Data", "print_hide": 1, diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 87f73c19ab..6871b1e90f 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -30,7 +30,6 @@ from webnotes import _, msgprint month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12} - from controllers.selling_controller import SellingController class DocType(SellingController): @@ -40,9 +39,6 @@ class DocType(SellingController): self.tname = 'Sales Invoice Item' self.fname = 'entries' - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series+ '.#####') - def validate(self): super(DocType, self).validate() self.fetch_missing_values() @@ -78,9 +74,11 @@ class DocType(SellingController): self.set_aging_date() self.set_against_income_account() self.validate_c_form() + self.validate_rate_with_refdoc() self.validate_time_logs_are_submitted() self.validate_recurring_invoice() + def on_submit(self): if cint(self.doc.is_pos) == 1: if cint(self.doc.update_stock) == 1: @@ -195,11 +193,11 @@ class DocType(SellingController): self.doc.fields[fieldname] = pos.get(fieldname) # set pos values in items - for doc in self.doclist.get({"parentfield": "entries"}): - if doc.fields.get('item_code'): - for fieldname, val in self.apply_pos_settings(doc.fields).items(): - if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)): - doc.fields[fieldname] = val + for item in self.doclist.get({"parentfield": "entries"}): + if item.fields.get('item_code'): + for fieldname, val in self.apply_pos_settings(item.fields).items(): + if (not for_validate) or (for_validate and not item.fields.get(fieldname)): + item.fields[fieldname] = val # fetch terms if self.doc.tc_name and not self.doc.terms: @@ -217,8 +215,9 @@ class DocType(SellingController): if self.doc.customer: acc_head = webnotes.conn.sql("""select name from `tabAccount` where (name = %s or (master_name = %s and master_type = 'customer')) - and docstatus != 2""", - (cstr(self.doc.customer) + " - " + self.get_company_abbr(), self.doc.customer)) + and docstatus != 2 and company = %s""", + (cstr(self.doc.customer) + " - " + self.get_company_abbr(), + self.doc.customer, self.doc.company)) if acc_head and acc_head[0][0]: return acc_head[0][0] @@ -555,6 +554,21 @@ class DocType(SellingController): webnotes.conn.set(self.doc, 'c_form_no', '') + def validate_rate_with_refdoc(self): + """Validate values with reference document with previous document""" + for d in self.doclist.get({"parentfield": "entries"}): + if d.so_detail: + self.check_value("Sales Order", d.sales_order, d.so_detail, + d.export_rate, d.item_code) + if d.dn_detail: + self.check_value("Delivery Note", d.delivery_note, d.dn_detail, + d.export_rate, d.item_code) + + def check_value(self, ref_dt, ref_dn, ref_item_dn, val, item_code): + ref_val = webnotes.conn.get_value(ref_dt + " Item", ref_item_dn, "export_rate") + if flt(ref_val, 2) != flt(val, 2): + msgprint(_("Rate is not matching with ") + ref_dt + ": " + ref_dn + + _(" for item: ") + item_code, raise_exception=True) def update_current_stock(self): for d in getlist(self.doclist, 'entries'): diff --git a/accounts/doctype/sales_invoice_item/sales_invoice_item.txt b/accounts/doctype/sales_invoice_item/sales_invoice_item.txt index 2a6384d762..89c86f8219 100644 --- a/accounts/doctype/sales_invoice_item/sales_invoice_item.txt +++ b/accounts/doctype/sales_invoice_item/sales_invoice_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-04-10 08:35:44", + "creation": "2013-04-19 11:00:07", "docstatus": 0, - "modified": "2013-04-17 14:05:20", + "modified": "2013-05-22 12:06:15", "modified_by": "Administrator", "owner": "Administrator" }, @@ -305,6 +305,7 @@ "fieldtype": "Link", "in_filter": 1, "label": "Sales Order", + "no_copy": 1, "oldfieldname": "sales_order", "oldfieldtype": "Link", "options": "Sales Order", @@ -319,6 +320,7 @@ "hidden": 1, "in_filter": 1, "label": "SO Detail ", + "no_copy": 1, "oldfieldname": "so_detail", "oldfieldtype": "Data", "print_hide": 1, @@ -331,6 +333,7 @@ "fieldtype": "Link", "in_filter": 1, "label": "Delivery Note", + "no_copy": 1, "oldfieldname": "delivery_note", "oldfieldtype": "Link", "options": "Delivery Note", @@ -345,6 +348,7 @@ "hidden": 1, "in_filter": 1, "label": "DN Detail", + "no_copy": 1, "oldfieldname": "dn_detail", "oldfieldtype": "Data", "print_hide": 1, diff --git a/accounts/report/sales_register/sales_register.py b/accounts/report/sales_register/sales_register.py index b15097457d..3946f0033d 100644 --- a/accounts/report/sales_register/sales_register.py +++ b/accounts/report/sales_register/sales_register.py @@ -36,7 +36,7 @@ def execute(filters=None): # invoice details sales_order = ", ".join(invoice_so_dn_map.get(inv.name, {}).get("sales_order", [])) delivery_note = ", ".join(invoice_so_dn_map.get(inv.name, {}).get("delivery_note", [])) - # webnotes.errprint(customer_map.get(inv.customer, [])) + row = [inv.name, inv.posting_date, inv.customer, inv.debit_to, account_map.get(inv.debit_to), customer_map.get(inv.customer), inv.project_name, inv.remarks, sales_order, delivery_note] diff --git a/buying/doctype/purchase_order_item/purchase_order_item.txt b/buying/doctype/purchase_order_item/purchase_order_item.txt index cd00f87253..01a144a143 100755 --- a/buying/doctype/purchase_order_item/purchase_order_item.txt +++ b/buying/doctype/purchase_order_item/purchase_order_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-02-22 01:27:42", + "creation": "2013-03-07 11:42:55", "docstatus": 0, - "modified": "2013-03-07 07:03:27", + "modified": "2013-05-22 11:59:52", "modified_by": "Administrator", "owner": "Administrator" }, @@ -36,6 +36,7 @@ "oldfieldname": "schedule_date", "oldfieldtype": "Date", "print_hide": 1, + "read_only": 0, "reqd": 1, "search_index": 1 }, @@ -49,6 +50,7 @@ "oldfieldtype": "Link", "options": "Item", "print_hide": 0, + "read_only": 0, "reqd": 1, "search_index": 1 }, @@ -72,6 +74,7 @@ "oldfieldname": "item_name", "oldfieldtype": "Data", "print_hide": 1, + "read_only": 0, "reqd": 1, "search_index": 1 }, @@ -83,6 +86,7 @@ "oldfieldname": "description", "oldfieldtype": "Small Text", "print_width": "300px", + "read_only": 0, "reqd": 1, "width": "300px" }, @@ -95,6 +99,7 @@ "oldfieldname": "qty", "oldfieldtype": "Currency", "print_width": "60px", + "read_only": 0, "reqd": 1, "width": "60px" }, @@ -108,6 +113,7 @@ "options": "UOM", "print_hide": 0, "print_width": "100px", + "read_only": 0, "reqd": 1, "width": "100px" }, @@ -117,14 +123,16 @@ "fieldtype": "Currency", "label": "Ref Rate ", "options": "currency", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", "fieldname": "discount_rate", "fieldtype": "Float", "label": "Discount %", - "print_hide": 0 + "print_hide": 0, + "read_only": 0 }, { "doctype": "DocField", @@ -135,7 +143,8 @@ "oldfieldname": "import_rate", "oldfieldtype": "Currency", "options": "currency", - "print_hide": 0 + "print_hide": 0, + "read_only": 0 }, { "doctype": "DocField", @@ -153,7 +162,8 @@ "fieldtype": "Currency", "label": "Ref Rate*", "options": "Company:company:default_currency", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "default": "0.00", @@ -166,6 +176,7 @@ "options": "Company:company:default_currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "reqd": 1, "width": "100px" }, @@ -192,6 +203,7 @@ "oldfieldtype": "Link", "options": "Warehouse", "print_hide": 1, + "read_only": 0, "reqd": 0 }, { @@ -202,6 +214,7 @@ "label": "Project Name", "options": "Project", "print_hide": 1, + "read_only": 0, "report_hide": 0 }, { @@ -214,6 +227,7 @@ "oldfieldtype": "Currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "reqd": 1, "width": "100px" }, @@ -237,7 +251,7 @@ "fieldtype": "Data", "hidden": 1, "label": "Prevdoc DocType", - "no_copy": 0, + "no_copy": 1, "oldfieldname": "prevdoc_doctype", "oldfieldtype": "Data", "print_hide": 1, @@ -250,7 +264,7 @@ "hidden": 0, "in_filter": 1, "label": "Material Request No", - "no_copy": 0, + "no_copy": 1, "oldfieldname": "prevdoc_docname", "oldfieldtype": "Link", "options": "Material Request", @@ -267,6 +281,7 @@ "hidden": 1, "in_filter": 1, "label": "Material Request Date", + "no_copy": 1, "oldfieldname": "prevdoc_date", "oldfieldtype": "Date", "print_hide": 1, @@ -280,7 +295,7 @@ "hidden": 1, "in_filter": 1, "label": "Material Request Detail No", - "no_copy": 0, + "no_copy": 1, "oldfieldname": "prevdoc_detail_docname", "oldfieldtype": "Data", "print_hide": 1, @@ -294,6 +309,7 @@ "hidden": 1, "in_filter": 0, "label": "Supplier Quotation", + "no_copy": 1, "options": "Supplier Quotation", "read_only": 1, "search_index": 0 @@ -304,6 +320,7 @@ "fieldtype": "Link", "hidden": 1, "label": "Supplier Quotation Item", + "no_copy": 1, "options": "Supplier Quotation Item", "read_only": 1 }, @@ -395,6 +412,7 @@ "no_copy": 1, "oldfieldname": "page_break", "oldfieldtype": "Check", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 } ] \ No newline at end of file diff --git a/buying/doctype/quality_inspection/quality_inspection.py b/buying/doctype/quality_inspection/quality_inspection.py index 336aabee8d..48a9a7a6f5 100644 --- a/buying/doctype/quality_inspection/quality_inspection.py +++ b/buying/doctype/quality_inspection/quality_inspection.py @@ -17,28 +17,16 @@ from __future__ import unicode_literals import webnotes -from webnotes.model import db_exists -from webnotes.model.doc import addchild, make_autoname -from webnotes.model.bean import copy_doclist - -sql = webnotes.conn.sql - - +from webnotes.model.doc import addchild class DocType: def __init__(self, doc, doclist=[]): self.doc = doc self.doclist = doclist - # Autoname - # --------- - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series+'.#####') - - def get_item_specification_details(self): self.doclist = self.doc.clear_table(self.doclist, 'qa_specification_details') - specification = sql("select specification, value from `tabItem Quality Inspection Parameter` \ + specification = webnotes.conn.sql("select specification, value from `tabItem Quality Inspection Parameter` \ where parent = '%s' order by idx" % (self.doc.item_code)) for d in specification: child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', self.doclist) @@ -48,13 +36,13 @@ class DocType: def on_submit(self): if self.doc.purchase_receipt_no: - sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '%s', t2.modified = '%s' \ + webnotes.conn.sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '%s', t2.modified = '%s' \ where t1.parent = '%s' and t1.item_code = '%s' and t1.parent = t2.name" \ % (self.doc.name, self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code)) def on_cancel(self): if self.doc.purchase_receipt_no: - sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '', t2.modified = '%s' \ + webnotes.conn.sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '', t2.modified = '%s' \ where t1.parent = '%s' and t1.item_code = '%s' and t1.parent = t2.name" \ % (self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code)) diff --git a/buying/doctype/quality_inspection/quality_inspection.txt b/buying/doctype/quality_inspection/quality_inspection.txt index e8650e0554..60ede7093e 100644 --- a/buying/doctype/quality_inspection/quality_inspection.txt +++ b/buying/doctype/quality_inspection/quality_inspection.txt @@ -1,13 +1,13 @@ [ { - "creation": "2013-01-10 16:34:11", + "creation": "2013-04-30 13:13:03", "docstatus": 0, - "modified": "2013-01-22 14:57:21", + "modified": "2013-05-09 14:34:10", "modified_by": "Administrator", "owner": "Administrator" }, { - "autoname": "QAI/.######", + "autoname": "naming_series:", "doctype": "DocType", "is_submittable": 1, "module": "Buying", diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py index 0137504b30..d41b86c32c 100644 --- a/buying/doctype/supplier/supplier.py +++ b/buying/doctype/supplier/supplier.py @@ -168,7 +168,7 @@ class DocType(TransactionBase): self.delete_supplier_communication() self.delete_supplier_account() - def on_rename(self, new, old): + def on_rename(self, new, old, merge=False): #update supplier_name if not naming series if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name': update_fields = [ @@ -186,7 +186,7 @@ class DocType(TransactionBase): for account in webnotes.conn.sql("""select name, account_name from tabAccount where master_name=%s and master_type='Supplier'""", old, as_dict=1): if account.account_name != new: - webnotes.rename_doc("Account", account.name, new) + webnotes.rename_doc("Account", account.name, new, merge=merge) #update master_name in doctype account webnotes.conn.sql("""update `tabAccount` set master_name = %s, diff --git a/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt b/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt index 53fa9f8d95..6b24d2f86f 100644 --- a/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt +++ b/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-02-22 01:27:43", + "creation": "2013-03-07 11:42:56", "docstatus": 0, - "modified": "2013-03-07 07:03:32", + "modified": "2013-05-22 12:02:28", "modified_by": "Administrator", "owner": "Administrator" }, @@ -35,6 +35,7 @@ "oldfieldtype": "Link", "options": "Item", "print_hide": 0, + "read_only": 0, "reqd": 1, "search_index": 1 }, @@ -58,6 +59,7 @@ "oldfieldname": "item_name", "oldfieldtype": "Data", "print_hide": 1, + "read_only": 0, "reqd": 1, "search_index": 1 }, @@ -69,6 +71,7 @@ "oldfieldname": "description", "oldfieldtype": "Small Text", "print_width": "300px", + "read_only": 0, "reqd": 1, "width": "300px" }, @@ -81,6 +84,7 @@ "oldfieldname": "qty", "oldfieldtype": "Currency", "print_width": "60px", + "read_only": 0, "reqd": 1, "width": "60px" }, @@ -94,6 +98,7 @@ "options": "UOM", "print_hide": 0, "print_width": "100px", + "read_only": 0, "reqd": 1, "width": "100px" }, @@ -103,14 +108,16 @@ "fieldtype": "Currency", "label": "Ref Rate ", "options": "currency", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", "fieldname": "discount_rate", "fieldtype": "Float", "label": "Discount %", - "print_hide": 0 + "print_hide": 0, + "read_only": 0 }, { "doctype": "DocField", @@ -121,7 +128,8 @@ "oldfieldname": "import_rate", "oldfieldtype": "Currency", "options": "currency", - "print_hide": 0 + "print_hide": 0, + "read_only": 0 }, { "doctype": "DocField", @@ -139,7 +147,8 @@ "fieldtype": "Currency", "label": "Ref Rate*", "options": "Company:company:default_currency", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "default": "0.00", @@ -152,6 +161,7 @@ "options": "Company:company:default_currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "reqd": 1, "width": "100px" }, @@ -178,6 +188,7 @@ "oldfieldtype": "Link", "options": "Warehouse", "print_hide": 1, + "read_only": 0, "reqd": 0 }, { @@ -188,6 +199,7 @@ "label": "Project Name", "options": "Project", "print_hide": 1, + "read_only": 0, "report_hide": 0 }, { @@ -196,7 +208,7 @@ "fieldtype": "Data", "hidden": 1, "label": "Prevdoc DocType", - "no_copy": 0, + "no_copy": 1, "oldfieldname": "prevdoc_doctype", "oldfieldtype": "Data", "print_hide": 1, @@ -209,7 +221,7 @@ "hidden": 0, "in_filter": 1, "label": "Material Request No", - "no_copy": 0, + "no_copy": 1, "oldfieldname": "prevdoc_docname", "oldfieldtype": "Link", "options": "Material Request", @@ -226,6 +238,7 @@ "hidden": 1, "in_filter": 1, "label": "Material Request Date", + "no_copy": 1, "oldfieldname": "prevdoc_date", "oldfieldtype": "Date", "print_hide": 1, @@ -239,7 +252,7 @@ "hidden": 1, "in_filter": 1, "label": "Material Request Detail No", - "no_copy": 0, + "no_copy": 1, "oldfieldname": "prevdoc_detail_docname", "oldfieldtype": "Data", "print_hide": 1, @@ -295,6 +308,7 @@ "no_copy": 1, "oldfieldname": "page_break", "oldfieldtype": "Check", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 } ] \ No newline at end of file diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js index e7532dda2e..2070fd4e33 100644 --- a/buying/page/buying_home/buying_home.js +++ b/buying/page/buying_home/buying_home.js @@ -111,6 +111,10 @@ wn.module_page["Buying"] = [ "label":wn._("Purchase In Transit"), route: "query-report/Purchase In Transit", }, + { + "label":wn._("Requested Items To Be Ordered"), + route: "query-report/Requested Items To Be Ordered", + }, ] } ] diff --git a/buying/report/requested_items_to_be_ordered/__init__.py b/buying/report/requested_items_to_be_ordered/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt b/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt new file mode 100644 index 0000000000..49c747854a --- /dev/null +++ b/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt @@ -0,0 +1,23 @@ +[ + { + "creation": "2013-05-13 16:10:02", + "docstatus": 0, + "modified": "2013-05-13 16:21:07", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.ordered_qty as \"Ordered Qty:Float:100\", \n\t(mr_item.qty - ifnull(mr_item.ordered_qty, 0)) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand ifnull(mr_item.ordered_qty, 0) < ifnull(mr_item.qty, 0)\norder by mr.transaction_date asc", + "ref_doctype": "Purchase Order", + "report_name": "Requested Items To Be Ordered", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Requested Items To Be Ordered" + } +] \ No newline at end of file diff --git a/config.json b/config.json index e2c22bc031..40b526ce6a 100644 --- a/config.json +++ b/config.json @@ -115,7 +115,7 @@ "ticket": { "no_cache": true, "template": "app/website/templates/pages/ticket", - "get_website_args": "support.doctype.support_ticket.support_ticket.get_website_args" + "args_method": "support.doctype.support_ticket.support_ticket.get_website_args" }, "tickets": { "template": "app/website/templates/pages/tickets" @@ -123,6 +123,10 @@ "writers": { "template": "app/website/templates/pages/writers", "args_method": "website.helpers.blog.get_writers_args" + }, + "profile": { + "no_cache": true, + "template": "app/website/templates/pages/profile" } }, "generators": { diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index 9e181bc8fe..3deda0284b 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -367,9 +367,13 @@ class BuyingController(StockController): if d.item_code and d.qty: # if no item code, which is sometimes the case in purchase invoice, # then it is not possible to track valuation against it - d.valuation_rate = (flt(d.purchase_rate or d.rate) - + (flt(d.item_tax_amount) + flt(d.rm_supp_cost)) / flt(d.qty) - ) / flt(d.conversion_factor) + d.valuation_rate = flt(((flt(d.purchase_rate, self.precision.item.purchase_rate) or + flt(d.rate, self.precision.item.rate)) + + (flt(d.item_tax_amount, self.precision.item.item_tax_amount) + + flt(d.rm_supp_cost, self.precision.item.rm_supp_cost)) / + flt(d.qty, self.precision.item.qty)) / + flt(d.conversion_factor, self.precision.item.conversion_factor), + self.precision.item.valuation_rate) else: d.valuation_rate = 0.0 diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js index 38c0026965..910c1b1602 100644 --- a/home/page/latest_updates/latest_updates.js +++ b/home/page/latest_updates/latest_updates.js @@ -1,4 +1,6 @@ erpnext.updates = [ + ["17th May", ["Patch: Set Conversion Factor for purchase invoice item in all old records. And repost JV to book Stock Received But Not Billed account, if Auto Inventory Integration enabed." + ]], ["2nd May", ["Buying: Warehouse must belong to same company as transaction", "Price List: Added Currency Field. One price list can have only one currency", "Item: Naming can now be by series or item code", diff --git a/hr/doctype/attendance/attendance.py b/hr/doctype/attendance/attendance.py index 67af429dd0..ac41acf815 100644 --- a/hr/doctype/attendance/attendance.py +++ b/hr/doctype/attendance/attendance.py @@ -18,7 +18,6 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import getdate, nowdate -from webnotes.model.doc import make_autoname from webnotes import msgprint, _ sql = webnotes.conn.sql @@ -28,9 +27,6 @@ class DocType: self.doc = doc self.doclist = doclist - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series+'.#####') - def get_emp_name(self): return { "employee_name": webnotes.conn.get_value("Employee", diff --git a/hr/doctype/employee/employee.py b/hr/doctype/employee/employee.py index 87fe9a45e9..036980326c 100644 --- a/hr/doctype/employee/employee.py +++ b/hr/doctype/employee/employee.py @@ -36,7 +36,7 @@ class DocType: if ret[0][0]=='Naming Series': self.doc.name = make_autoname(self.doc.naming_series + '.####') elif ret[0][0]=='Employee Number': - self.doc.name = make_autoname(self.doc.employee_number) + self.doc.name = self.doc.employee_number self.doc.employee = self.doc.name @@ -80,7 +80,7 @@ class DocType: if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole where parent=%s""", self.doc.user_id): from webnotes.profile import add_role - add_role(self.doc.user_id, "HR User") + add_role(self.doc.user_id, "Employee") profile_wrapper = webnotes.bean("Profile", self.doc.user_id) diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py index 6e39751b71..7c47d6a09e 100755 --- a/hr/doctype/leave_application/leave_application.py +++ b/hr/doctype/leave_application/leave_application.py @@ -335,15 +335,22 @@ def add_holidays(events, start, end, employee, company): def query_for_permitted_employees(doctype, txt, searchfield, start, page_len, filters): txt = "%" + cstr(txt) + "%" - return webnotes.conn.sql("""select name, employee_name from `tabEmployee` emp + if "Leave Approver" in webnotes.user.get_roles(): + condition = """and (exists(select ela.name from `tabEmployee Leave Approver` ela + where ela.parent=`tabEmployee`.name and ela.leave_approver= "%s") or + not exists(select ela.name from `tabEmployee Leave Approver` ela + where ela.parent=`tabEmployee`.name) + or user_id = "%s")""" % (webnotes.session.user, webnotes.session.user) + else: + from webnotes.widgets.reportview import build_match_conditions + condition = build_match_conditions("Employee") + condition = ("and " + condition) if condition else "" + + return webnotes.conn.sql("""select name, employee_name from `tabEmployee` where status = 'Active' and docstatus < 2 and - (`%s` like %s or employee_name like %s) and - (exists(select ela.name from `tabEmployee Leave Approver` ela - where ela.parent=emp.name and ela.leave_approver=%s) or - not exists(select ela.name from `tabEmployee Leave Approver` ela where ela.parent=emp.name) - or user_id = %s) + (`%s` like %s or employee_name like %s) %s order by case when name like %s then 0 else 1 end, case when employee_name like %s then 0 else 1 end, - name limit %s, %s""" % tuple([searchfield] + ["%s"]*8), - (txt, txt, webnotes.session.user, webnotes.session.user, txt, txt, start, page_len)) + name limit %s, %s""" % tuple([searchfield] + ["%s"]*2 + [condition] + ["%s"]*4), + (txt, txt, txt, txt, start, page_len)) diff --git a/hr/doctype/upload_attendance/upload_attendance.js b/hr/doctype/upload_attendance/upload_attendance.js index 35a00ed69d..4e5b47fe00 100644 --- a/hr/doctype/upload_attendance/upload_attendance.js +++ b/hr/doctype/upload_attendance/upload_attendance.js @@ -75,7 +75,6 @@ erpnext.hr.AttendanceControlPanel = wn.ui.form.Controller.extend({ r.messages = ["

Import Successful!

"]. concat(r.messages) } - console.log(r.messages); $.each(r.messages, function(i, v) { var $p = $('

').html(v).appendTo($log_wrapper); diff --git a/hr/doctype/upload_attendance/upload_attendance.py b/hr/doctype/upload_attendance/upload_attendance.py index e48cbefb69..ee4234a279 100644 --- a/hr/doctype/upload_attendance/upload_attendance.py +++ b/hr/doctype/upload_attendance/upload_attendance.py @@ -100,7 +100,6 @@ def get_naming_series(): def upload(): from webnotes.utils.datautils import read_csv_content_from_uploaded_file from webnotes.modules import scrub - from core.page.data_import_tool.data_import_tool import check_record, import_doc rows = read_csv_content_from_uploaded_file() if not rows: @@ -112,6 +111,9 @@ def upload(): ret = [] error = False + from webnotes.utils.datautils import check_record, import_doc + doctype_dl = webnotes.get_doctype("Attendance") + for i, row in enumerate(rows[5:]): if not row: continue row_idx = i + 5 @@ -121,7 +123,7 @@ def upload(): d["docstatus"] = webnotes.conn.get_value("Attendance", d.name, "docstatus") try: - check_record(d) + check_record(d, doctype_dl=doctype_dl) ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True)) except Exception, e: error = True diff --git a/hr/page/hr_home/hr_home.js b/hr/page/hr_home/hr_home.js index b2cce73f15..e35a80849b 100644 --- a/hr/page/hr_home/hr_home.js +++ b/hr/page/hr_home/hr_home.js @@ -177,6 +177,14 @@ wn.module_page["HR"] = [ "label":wn._("Employee Information"), route: "Report2/Employee/Employee Information" }, + { + "label":wn._("Monthly Salary Register"), + route: "query-report/Monthly Salary Register" + }, + { + "label":wn._("Monthly Attendance Sheet"), + route: "query-report/Monthly Attendance Sheet" + }, ] } ]; diff --git a/hr/report/monthly_attendance_sheet/__init__.py b/hr/report/monthly_attendance_sheet/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js new file mode 100644 index 0000000000..6dc8d78ea5 --- /dev/null +++ b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js @@ -0,0 +1,32 @@ +wn.query_reports["Monthly Attendance Sheet"] = { + "filters": [ + { + "fieldname":"month", + "label": "Month", + "fieldtype": "Select", + "options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec", + "default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", + "Dec"][wn.datetime.str_to_obj(wn.datetime.get_today()).getMonth()], + }, + { + "fieldname":"fiscal_year", + "label": "Fiscal Year", + "fieldtype": "Link", + "options": "Fiscal Year", + "default": sys_defaults.fiscal_year, + }, + { + "fieldname":"employee", + "label": "Employee", + "fieldtype": "Link", + "options": "Employee" + }, + { + "fieldname":"company", + "label": "Company", + "fieldtype": "Link", + "options": "Company", + "default": sys_defaults.company + } + ] +} \ No newline at end of file diff --git a/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py new file mode 100644 index 0000000000..42a977025a --- /dev/null +++ b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py @@ -0,0 +1,107 @@ +# 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 +import webnotes +from webnotes.utils import cstr, cint +from webnotes import msgprint, _ + +def execute(filters=None): + if not filters: filters = {} + + conditions, filters = get_conditions(filters) + columns = get_columns(filters) + att_map = get_attendance_list(conditions, filters) + emp_map = get_employee_details() + + data = [] + for emp in sorted(att_map): + emp_det = emp_map.get(emp) + row = [emp, emp_det.employee_name, emp_det.branch, emp_det.department, emp_det.designation, + emp_det.company] + + total_p = total_a = 0.0 + for day in range(filters["total_days_in_month"]): + status = att_map.get(emp).get(day + 1, "Absent") + status_map = {"Present": "P", "Absent": "A", "Half Day": "HD"} + row.append(status_map[status]) + + if status == "Present": + total_p += 1 + elif status == "Absent": + total_a += 1 + elif status == "Half Day": + total_p += 0.5 + total_a += 0.5 + + row += [total_p, total_a] + + data.append(row) + + return columns, data + +def get_columns(filters): + columns = [ + "Employee:Link/Employee:120", "Employee Name::140", "Branch:Link/Branch:120", + "Department:Link/Department:120", "Designation:Link/Designation:120", + "Company:Link/Company:120" + ] + + for day in range(filters["total_days_in_month"]): + columns.append(cstr(day+1) +"::20") + + columns += ["Total Present:Float:80", "Total Absent:Float:80"] + return columns + +def get_attendance_list(conditions, filters): + attendance_list = webnotes.conn.sql("""select employee, day(att_date) as day_of_month, + status from tabAttendance where docstatus = 1 %s order by employee, att_date""" % + conditions, filters, as_dict=1) + + att_map = {} + for d in attendance_list: + att_map.setdefault(d.employee, webnotes._dict()).setdefault(d.day_of_month, "") + att_map[d.employee][d.day_of_month] = d.status + + return att_map + +def get_conditions(filters): + if not (filters.get("month") and filters.get("fiscal_year")): + msgprint(_("Please select month and year"), raise_exception=1) + + filters["month"] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", + "Dec"].index(filters["month"]) + 1 + + from calendar import monthrange + filters["total_days_in_month"] = monthrange(cint(filters["fiscal_year"].split("-")[-1]), + filters["month"])[1] + + conditions = " and month(att_date) = %(month)s and fiscal_year = %(fiscal_year)s" + + if filters.get("company"): conditions += " and company = %(company)s" + if filters.get("employee"): conditions += " and employee = %(employee)s" + + return conditions, filters + +def get_employee_details(): + employee = webnotes.conn.sql("""select name, employee_name, designation, department, + branch, company from tabEmployee where docstatus < 2 and status = 'Active'""", as_dict=1) + + emp_map = {} + for emp in employee: + emp_map[emp.name] = emp + + return emp_map \ No newline at end of file diff --git a/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt new file mode 100644 index 0000000000..3c53aae8e4 --- /dev/null +++ b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-05-13 14:04:03", + "docstatus": 0, + "modified": "2013-05-13 14:32:42", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 0, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Attendance", + "report_name": "Monthly Attendance Sheet", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Monthly Attendance Sheet" + } +] \ No newline at end of file diff --git a/hr/report/monthly_salary_register/__init__.py b/hr/report/monthly_salary_register/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/hr/report/monthly_salary_register/monthly_salary_register.js b/hr/report/monthly_salary_register/monthly_salary_register.js new file mode 100644 index 0000000000..da881378ff --- /dev/null +++ b/hr/report/monthly_salary_register/monthly_salary_register.js @@ -0,0 +1,32 @@ +wn.query_reports["Monthly Salary Register"] = { + "filters": [ + { + "fieldname":"month", + "label": "Month", + "fieldtype": "Select", + "options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec", + "default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", + "Dec"][wn.datetime.str_to_obj(wn.datetime.get_today()).getMonth()], + }, + { + "fieldname":"fiscal_year", + "label": "Fiscal Year", + "fieldtype": "Link", + "options": "Fiscal Year", + "default": sys_defaults.fiscal_year, + }, + { + "fieldname":"employee", + "label": "Employee", + "fieldtype": "Link", + "options": "Employee" + }, + { + "fieldname":"company", + "label": "Company", + "fieldtype": "Link", + "options": "Company", + "default": sys_defaults.company + } + ] +} \ No newline at end of file diff --git a/hr/report/monthly_salary_register/monthly_salary_register.py b/hr/report/monthly_salary_register/monthly_salary_register.py new file mode 100644 index 0000000000..cc25dc3e32 --- /dev/null +++ b/hr/report/monthly_salary_register/monthly_salary_register.py @@ -0,0 +1,119 @@ +# 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 +import webnotes +from webnotes.utils import flt, cstr +from webnotes import msgprint, _ + +def execute(filters=None): + if not filters: filters = {} + + salary_slips = get_salary_slips(filters) + columns, earning_types, ded_types = get_columns(salary_slips) + ss_earning_map = get_ss_earning_map(salary_slips) + ss_ded_map = get_ss_ded_map(salary_slips) + + data = [] + for ss in salary_slips: + row = [ss.employee, ss.employee_name, ss.branch, ss.department, ss.designation, + ss.company, ss.month, ss.leave_withut_pay, ss.payment_days] + + for e in earning_types: + row.append(ss_earning_map.get(ss.name, {}).get(e)) + + row += [ss.arrear_amount, ss.leave_encashment_amount, ss.gross_pay] + + for d in ded_types: + row.append(ss_ded_map.get(ss.name, {}).get(d)) + + row += [ss.total_deduction, ss.net_pay] + + data.append(row) + + return columns, data + +def get_columns(salary_slips): + columns = [ + "Employee:Link/Employee:120", "Employee Name::140", "Branch:Link/Branch:120", + "Department:Link/Department:120", "Designation:Link/Designation:120", + "Company:Link/Company:120", "Month::80", "Leave Without pay:Float:130", + "Payment Days:Float:120" + ] + + earning_types = webnotes.conn.sql_list("""select distinct e_type from `tabSalary Slip Earning` + where ifnull(e_modified_amount, 0) != 0 and parent in (%s)""" % + (', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips])) + + ded_types = webnotes.conn.sql_list("""select distinct d_type from `tabSalary Slip Deduction` + where ifnull(d_modified_amount, 0) != 0 and parent in (%s)""" % + (', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips])) + + columns = columns + [(e + ":Link/Earning Type:120") for e in earning_types] + \ + ["Arrear Amount:Currency:120", "Leave Encashment Amount:Currency:150", + "Gross Pay:Currency:120"] + [(d + ":Link/Deduction Type:120") for d in ded_types] + \ + ["Total Deduction:Currency:120", "Net Pay:Currency:120"] + + return columns, earning_types, ded_types + +def get_salary_slips(filters): + conditions, filters = get_conditions(filters) + salary_slips = webnotes.conn.sql("""select * from `tabSalary Slip` where docstatus = 1 %s""" % + conditions, filters, as_dict=1) + + if not salary_slips: + msgprint(_("No salary slip found for month: ") + cstr(filters.get("month")) + + _(" and year: ") + cstr(filters.get("fiscal_year")), raise_exception=1) + + return salary_slips + +def get_conditions(filters): + conditions = "" + if filters.get("month"): + month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", + "Dec"].index(filters["month"]) + 1 + filters["month"] = month + conditions += " and month = %(month)s" + + if filters.get("fiscal_year"): conditions += " and fiscal_year = %(fiscal_year)s" + if filters.get("company"): conditions += " and company = %(company)s" + if filters.get("employee"): conditions += " and employee = %(employee)s" + + return conditions, filters + +def get_ss_earning_map(salary_slips): + ss_earnings = webnotes.conn.sql("""select parent, e_type, e_modified_amount + from `tabSalary Slip Earning` where parent in (%s)""" % + (', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]), as_dict=1) + + ss_earning_map = {} + for d in ss_earnings: + ss_earning_map.setdefault(d.parent, webnotes._dict()).setdefault(d.e_type, []) + ss_earning_map[d.parent][d.e_type] = flt(d.e_modified_amount) + + return ss_earning_map + +def get_ss_ded_map(salary_slips): + ss_deductions = webnotes.conn.sql("""select parent, d_type, d_modified_amount + from `tabSalary Slip Deduction` where parent in (%s)""" % + (', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]), as_dict=1) + + ss_ded_map = {} + for d in ss_deductions: + ss_ded_map.setdefault(d.parent, webnotes._dict()).setdefault(d.d_type, []) + ss_ded_map[d.parent][d.e_type] = flt(d.d_modified_amount) + + return ss_ded_map \ No newline at end of file diff --git a/hr/report/monthly_salary_register/monthly_salary_register.txt b/hr/report/monthly_salary_register/monthly_salary_register.txt new file mode 100644 index 0000000000..b0d5880eaf --- /dev/null +++ b/hr/report/monthly_salary_register/monthly_salary_register.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-05-07 18:09:42", + "docstatus": 0, + "modified": "2013-05-07 18:09:42", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Salary Slip", + "report_name": "Monthly Salary Register", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Monthly Salary Register" + } +] \ No newline at end of file diff --git a/manufacturing/doctype/bom/bom.py b/manufacturing/doctype/bom/bom.py index 5f42f4da5d..5a1d47fd4e 100644 --- a/manufacturing/doctype/bom/bom.py +++ b/manufacturing/doctype/bom/bom.py @@ -34,7 +34,8 @@ class DocType: last_name = sql("""select max(name) from `tabBOM` where name like "BOM/%s/%%" """ % cstr(self.doc.item).replace('"', '\\"')) if last_name: - idx = cint(cstr(last_name[0][0]).split('/')[-1]) + 1 + idx = cint(cstr(last_name[0][0]).split('/')[-1].split('-')[0]) + 1 + else: idx = 1 self.doc.name = 'BOM/' + self.doc.item + ('/%.3i' % idx) diff --git a/manufacturing/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py index a0498e063f..c76a87f6b8 100644 --- a/manufacturing/doctype/production_order/production_order.py +++ b/manufacturing/doctype/production_order/production_order.py @@ -18,9 +18,6 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import cstr, flt, now, nowdate -from webnotes.model import db_exists -from webnotes.model.doc import make_autoname -from webnotes.model.bean import copy_doclist from webnotes.model.code import get_obj from webnotes import msgprint diff --git a/patches/april_2013/p05_update_file_data.py b/patches/april_2013/p05_update_file_data.py index 787991251e..39449a6252 100644 --- a/patches/april_2013/p05_update_file_data.py +++ b/patches/april_2013/p05_update_file_data.py @@ -9,10 +9,9 @@ def execute(): for doctype in webnotes.conn.sql_list("""select parent from tabDocField where fieldname='file_list'"""): - update_file_list(doctype, singles) - - webnotes.conn.sql("""delete from tabDocField where fieldname='file_list' - and parent=%s""", doctype) + # the other scenario is handled in p07_update_file_data_2 + if doctype in singles: + update_file_list(doctype, singles) # export_to_files([["DocType", doctype]]) diff --git a/patches/april_2013/p07_update_file_data_2.py b/patches/april_2013/p07_update_file_data_2.py index 2405e80d65..0cb44d0c20 100644 --- a/patches/april_2013/p07_update_file_data_2.py +++ b/patches/april_2013/p07_update_file_data_2.py @@ -13,6 +13,4 @@ def execute(): webnotes.conn.sql("""delete from `tabCustom Field` where fieldname='file_list' and parent=%s""", doctype) - webnotes.conn.sql("""delete from `tabDocField` where fieldname='file_list' - and parent=%s""", doctype) \ No newline at end of file diff --git a/patches/august_2012/change_profile_permission.py b/patches/august_2012/change_profile_permission.py index 27169d8792..7e945d5d9a 100644 --- a/patches/august_2012/change_profile_permission.py +++ b/patches/august_2012/change_profile_permission.py @@ -31,5 +31,4 @@ def execute(): webnotes.conn.commit() webnotes.conn.begin() - import webnotes.model.sync - webnotes.model.sync.sync('core', 'profile') \ No newline at end of file + webnotes.reload_doc('core', 'doctype', 'profile') \ No newline at end of file diff --git a/patches/august_2012/changed_blog_date_format.py b/patches/august_2012/changed_blog_date_format.py deleted file mode 100644 index df51977be5..0000000000 --- a/patches/august_2012/changed_blog_date_format.py +++ /dev/null @@ -1,5 +0,0 @@ -from __future__ import unicode_literals -def execute(): - import webnotes - from webnotes.model.bean import Bean - Bean("Website Settings", "Website Settings").save() \ No newline at end of file diff --git a/patches/august_2012/report_supplier_quotations.py b/patches/august_2012/report_supplier_quotations.py deleted file mode 100644 index 8eaf707c4c..0000000000 --- a/patches/august_2012/report_supplier_quotations.py +++ /dev/null @@ -1,4 +0,0 @@ -from __future__ import unicode_literals -def execute(): - from webnotes.modules import reload_doc - reload_doc("buying", "report", "supplier_quotations") diff --git a/patches/february_2013/p03_material_request.py b/patches/february_2013/p03_material_request.py index 66b2bf6cbb..f0373bdffb 100644 --- a/patches/february_2013/p03_material_request.py +++ b/patches/february_2013/p03_material_request.py @@ -23,3 +23,7 @@ def execute(): os.system("rm -rf app/hr/doctype/holiday_block_list_allow") os.system("rm -rf app/hr/doctype/holiday_block_list_date") + for dt in ("Purchase Request", "Purchase Request Item"): + if webnotes.conn.exists("DocType", dt): + webnotes.delete_doc("DocType", dt) + \ No newline at end of file diff --git a/patches/july_2012/address_contact_perms.py b/patches/july_2012/address_contact_perms.py index 5b79f22937..882cf728a5 100644 --- a/patches/july_2012/address_contact_perms.py +++ b/patches/july_2012/address_contact_perms.py @@ -6,7 +6,6 @@ def execute(): where parent in ('Address', 'Contact')""") webnotes.conn.commit() - import webnotes.model.sync - webnotes.model.sync.sync('utilities', 'address') - webnotes.model.sync.sync('utilities', 'contact') + webnotes.reload_doc('utilities', 'doctype', 'address') + webnotes.reload_doc('utilities', 'doctype', 'contact') webnotes.conn.begin() \ No newline at end of file diff --git a/patches/july_2012/blog_guest_permission.py b/patches/july_2012/blog_guest_permission.py deleted file mode 100644 index bc42a9d05c..0000000000 --- a/patches/july_2012/blog_guest_permission.py +++ /dev/null @@ -1,12 +0,0 @@ -from __future__ import unicode_literals -def execute(): - """allocate read write permission to guest for doctype 'Blog'""" - import webnotes - webnotes.conn.sql("""delete from `tabDocPerm` where parent = 'Blog'""") - - webnotes.conn.commit() - - import webnotes.model.sync - webnotes.model.sync.sync('website', 'blog', 1) - - webnotes.conn.begin() diff --git a/patches/july_2012/project_patch_repeat.py b/patches/july_2012/project_patch_repeat.py index bd52522938..b1386614c4 100644 --- a/patches/july_2012/project_patch_repeat.py +++ b/patches/july_2012/project_patch_repeat.py @@ -12,8 +12,6 @@ def execute(): and ifnull(t1.project_name, '') = ''""") webnotes.conn.commit() - from webnotes.model.sync import sync - sync("buying", "purchase_order") - sync("buying", "purchase_request") - sync("accounts", "purchase_invoice") + webnotes.reload_doc("buying", "doctype", "purchase_order") + webnotes.reload_doc("accounts", "doctype", "purchase_invoice") webnotes.conn.begin() \ No newline at end of file diff --git a/patches/july_2012/supplier_quotation.py b/patches/july_2012/supplier_quotation.py index 49fa14dc9b..0a1ab35ef9 100644 --- a/patches/july_2012/supplier_quotation.py +++ b/patches/july_2012/supplier_quotation.py @@ -1,13 +1,12 @@ from __future__ import unicode_literals +import webnotes + def execute(): """sync supplier quotatoin and create supplier quotation mappers""" - from webnotes.model.sync import sync - sync('buying', 'supplier_quotation') - sync('buying', 'supplier_quotation_item') - sync('buying', 'purchase_request') - sync('buying', 'purchase_request_item') - sync('buying', 'purchase_order') - sync('buying', 'purchase_order_item') + webnotes.reload_doc('buying', 'doctype', 'supplier_quotation') + webnotes.reload_doc('buying', 'doctype', 'supplier_quotation_item') + webnotes.reload_doc('buying', 'doctype', 'purchase_order') + webnotes.reload_doc('buying', 'doctype', 'purchase_order_item') from webnotes.modules import reload_doc reload_doc('buying', 'DocType Mapper', 'Material Request-Supplier Quotation') diff --git a/patches/june_2012/cms2.py b/patches/june_2012/cms2.py index 414af73c00..17b7d23cc1 100644 --- a/patches/june_2012/cms2.py +++ b/patches/june_2012/cms2.py @@ -1,14 +1,11 @@ from __future__ import unicode_literals def execute(): import webnotes - import webnotes.model.sync # sync doctypes required for the patch - webnotes.model.sync.sync('website', 'web_cache') - webnotes.model.sync.sync('website', 'web_page') - webnotes.model.sync.sync('website', 'blog') - webnotes.model.sync.sync('website', 'website_settings') - webnotes.model.sync.sync('stock', 'item') + webnotes.reload_doc('website', 'doctype', 'web_page') + webnotes.reload_doc('website', 'doctype', 'website_settings') + webnotes.reload_doc('stock', 'doctype', 'item') cleanup() diff --git a/patches/june_2012/copy_uom_for_pur_inv_item.py b/patches/june_2012/copy_uom_for_pur_inv_item.py index b374249942..a22146c6a3 100644 --- a/patches/june_2012/copy_uom_for_pur_inv_item.py +++ b/patches/june_2012/copy_uom_for_pur_inv_item.py @@ -2,11 +2,9 @@ from __future__ import unicode_literals def execute(): import webnotes - # perform sync - import webnotes.model.sync - webnotes.model.sync.sync('buying', 'purchase_order_item') - webnotes.model.sync.sync('accounts', 'purchase_invoice_item') - webnotes.model.sync.sync('stock', 'purchase_receipt_item') + webnotes.reload_doc('buying', 'doctype', 'purchase_order_item') + webnotes.reload_doc('accounts', 'doctype', 'purchase_invoice_item') + webnotes.reload_doc('stock', 'doctype', 'purchase_receipt_item') webnotes.conn.sql("update `tabPurchase Invoice Item` t1, `tabPurchase Order Item` t2 set t1.uom = t2.uom where ifnull(t1.po_detail, '') != '' and t1.po_detail = t2.name") webnotes.conn.sql("update `tabPurchase Invoice Item` t1, `tabPurchase Receipt Item` t2 set t1.uom = t2.uom where ifnull(t1.pr_detail, '') != '' and t1.pr_detail = t2.name") \ No newline at end of file diff --git a/patches/june_2012/reports_list_permission.py b/patches/june_2012/reports_list_permission.py index a02f4fa37f..e34eb5ae46 100644 --- a/patches/june_2012/reports_list_permission.py +++ b/patches/june_2012/reports_list_permission.py @@ -8,8 +8,7 @@ def execute(): webnotes.conn.commit() - import webnotes.model.sync - webnotes.model.sync.sync('core', 'search_criteria') - webnotes.model.sync.sync('core', 'report') + webnotes.reload_doc('core', 'doctype', 'search_criteria') + webnotes.reload_doc('core', 'doctype', 'report') webnotes.conn.begin() \ No newline at end of file diff --git a/patches/june_2012/set_recurring_type.py b/patches/june_2012/set_recurring_type.py index 79dd286fbc..7fb416ed7e 100644 --- a/patches/june_2012/set_recurring_type.py +++ b/patches/june_2012/set_recurring_type.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals def execute(): import webnotes - from webnotes.model.sync import sync - sync('accounts', 'sales_invoice') + webnotes.reload_doc('accounts', 'doctype', 'sales_invoice') webnotes.conn.sql("update `tabSales Invoice` set recurring_type = 'Monthly' where ifnull(convert_into_recurring_invoice, 0) = 1") \ No newline at end of file diff --git a/patches/june_2012/support_ticket_autoreply.py b/patches/june_2012/support_ticket_autoreply.py index 9fb0534bdd..32e095665c 100644 --- a/patches/june_2012/support_ticket_autoreply.py +++ b/patches/june_2012/support_ticket_autoreply.py @@ -4,9 +4,8 @@ def execute(): import webnotes import webnotes.utils - import webnotes.model.sync webnotes.conn.commit() - webnotes.model.sync.sync('setup', 'email_settings') + webnotes.reload_doc('setup', 'doctype', 'email_settings') webnotes.conn.begin() sync_support_mails = webnotes.utils.cint(webnotes.conn.get_value('Email Settings', diff --git a/patches/mar_2012/clean_property_setter.py b/patches/mar_2012/clean_property_setter.py index 08a0a94e1f..a9c7b81f36 100644 --- a/patches/mar_2012/clean_property_setter.py +++ b/patches/mar_2012/clean_property_setter.py @@ -12,8 +12,7 @@ def execute(): clean_docfield_properties() def change_property_setter_fieldnames(): - import webnotes.model.sync - webnotes.model.sync.sync('core', 'property_setter') + webnotes.reload_doc('core', 'doctype', 'property_setter') docfield_list = webnotes.conn.sql("""\ SELECT name, fieldname FROM `tabDocField`""", as_list=1) custom_field_list = webnotes.conn.sql("""\ diff --git a/patches/mar_2012/create_custom_fields.py b/patches/mar_2012/create_custom_fields.py index d4c1a13453..a91c765e5f 100644 --- a/patches/mar_2012/create_custom_fields.py +++ b/patches/mar_2012/create_custom_fields.py @@ -94,8 +94,7 @@ from webnotes.model.code import get_obj from webnotes.model.doc import Document def execute(): - import webnotes.model.sync - webnotes.model.sync.sync('core', 'custom_field') + webnotes.reload_doc('core', 'doctype', 'custom_field') for f in field_list: res = webnotes.conn.sql("""SELECT name FROM `tabCustom Field` WHERE dt=%s AND fieldname=%s""", (f[0], f[1])) diff --git a/patches/may_2012/cleanup_notification_control.py b/patches/may_2012/cleanup_notification_control.py index 25a704e198..1a7730ba5b 100644 --- a/patches/may_2012/cleanup_notification_control.py +++ b/patches/may_2012/cleanup_notification_control.py @@ -25,5 +25,4 @@ def execute(): webnotes.conn.commit() webnotes.conn.begin() - import webnotes.model.sync - webnotes.model.sync.sync('setup', 'notification_control') \ No newline at end of file + webnotes.reload_doc('setup', 'doctype', 'notification_control') \ No newline at end of file diff --git a/patches/may_2012/cs_server_readonly.py b/patches/may_2012/cs_server_readonly.py index b68060682c..51a9b760cf 100644 --- a/patches/may_2012/cs_server_readonly.py +++ b/patches/may_2012/cs_server_readonly.py @@ -27,5 +27,4 @@ def execute(): doc.save() webnotes.conn.commit() webnotes.conn.begin() - import webnotes.model.sync - webnotes.model.sync.sync('core', 'custom_script') \ No newline at end of file + webnotes.reload_doc('core', 'doctype', 'custom_script') \ No newline at end of file diff --git a/patches/may_2012/profile_perm_patch.py b/patches/may_2012/profile_perm_patch.py index 4423fdb15d..29fa9c05be 100644 --- a/patches/may_2012/profile_perm_patch.py +++ b/patches/may_2012/profile_perm_patch.py @@ -19,5 +19,4 @@ def execute(): doc.save() webnotes.conn.commit() webnotes.conn.begin() - import webnotes.model.sync - webnotes.model.sync.sync('core', 'profile') \ No newline at end of file + webnotes.reload_doc('core', 'doctype', 'profile') \ No newline at end of file diff --git a/patches/may_2012/remove_communication_log.py b/patches/may_2012/remove_communication_log.py index e44e673701..b6e7e7d276 100644 --- a/patches/may_2012/remove_communication_log.py +++ b/patches/may_2012/remove_communication_log.py @@ -1,8 +1,7 @@ from __future__ import unicode_literals def execute(): import webnotes - import webnotes.model.sync - webnotes.model.sync.sync('support', 'communication') + webnotes.reload_doc('support', 'doctype', 'communication') webnotes.conn.commit() webnotes.conn.begin() diff --git a/patches/may_2012/std_pf_readonly.py b/patches/may_2012/std_pf_readonly.py index 83b581325c..9fbbfe9a3c 100644 --- a/patches/may_2012/std_pf_readonly.py +++ b/patches/may_2012/std_pf_readonly.py @@ -27,5 +27,4 @@ def execute(): doc.save() webnotes.conn.commit() webnotes.conn.begin() - import webnotes.model.sync - webnotes.model.sync.sync('core', 'print_format') \ No newline at end of file + webnotes.reload_doc('core', 'doctype', 'print_format') \ No newline at end of file diff --git a/patches/may_2013/__init__.py b/patches/may_2013/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/patches/may_2013/p01_conversion_factor_and_aii.py b/patches/may_2013/p01_conversion_factor_and_aii.py new file mode 100644 index 0000000000..2fd0d369a5 --- /dev/null +++ b/patches/may_2013/p01_conversion_factor_and_aii.py @@ -0,0 +1,26 @@ +import webnotes +from webnotes.utils import cint +from accounts.utils import create_stock_in_hand_jv + +def execute(): + webnotes.conn.auto_commit_on_many_writes = True + + aii_enabled = cint(webnotes.conn.get_value("Global Defaults", None, + "auto_inventory_accounting")) + + if aii_enabled: + create_stock_in_hand_jv(reverse = True) + + webnotes.conn.sql("""update `tabPurchase Invoice Item` pi_item + set conversion_factor = (select ifnull(if(conversion_factor=0, 1, conversion_factor), 1) + from `tabUOM Conversion Detail` + where parent = pi_item.item_code and uom = pi_item.uom limit 1 + ) + where ifnull(conversion_factor, 0)=0""") + + if aii_enabled: + create_stock_in_hand_jv() + + webnotes.conn.auto_commit_on_many_writes = False + + \ No newline at end of file diff --git a/patches/may_2013/p02_update_valuation_rate.py b/patches/may_2013/p02_update_valuation_rate.py new file mode 100644 index 0000000000..280473ccef --- /dev/null +++ b/patches/may_2013/p02_update_valuation_rate.py @@ -0,0 +1,47 @@ +# 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 +import webnotes +def execute(): + from stock.stock_ledger import update_entries_after + item_warehouse = [] + # update valuation_rate in transaction + doctypes = {"Purchase Receipt": "purchase_receipt_details", "Purchase Invoice": "entries"} + + for dt in doctypes: + for d in webnotes.conn.sql("""select name from `tab%s` + where modified >= '2013-05-09' and docstatus=1""" % dt): + rec = webnotes.get_obj(dt, d[0]) + rec.update_valuation_rate(doctypes[dt]) + + for item in rec.doclist.get({"parentfield": doctypes[dt]}): + webnotes.conn.sql("""update `tab%s Item` set valuation_rate = %s + where name = %s"""% (dt, '%s', '%s'), tuple([item.valuation_rate, item.name])) + + if dt == "Purchase Receipt": + webnotes.conn.sql("""update `tabStock Ledger Entry` set incoming_rate = %s + where voucher_detail_no = %s""", (item.valuation_rate, item.name)) + if [item.item_code, item.warehouse] not in item_warehouse: + item_warehouse.append([item.item_code, item.warehouse]) + + for d in item_warehouse: + try: + update_entries_after({"item_code": d[0], "warehouse": d[1], + "posting_date": "2013-01-01", "posting_time": "00:05:00"}) + webnotes.conn.commit() + except: + pass \ No newline at end of file diff --git a/patches/may_2013/p03_update_support_ticket.py b/patches/may_2013/p03_update_support_ticket.py new file mode 100644 index 0000000000..7dc5854b44 --- /dev/null +++ b/patches/may_2013/p03_update_support_ticket.py @@ -0,0 +1,27 @@ +# 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 +import webnotes +def execute(): + webnotes.reload_doc("support", "doctype", "support_ticket") + webnotes.reload_doc("core", "doctype", "communication") + for d in webnotes.conn.sql("""select name, raised_by from `tabSupport Ticket` + where docstatus < 2""", as_dict=True): + tic = webnotes.get_obj("Support Ticket", d.name) + tic.set_lead_contact(d.raised_by) + webnotes.conn.sql("""update `tabSupport Ticket` set lead = %s, contact = %s, company = %s + where name = %s""", (tic.doc.lead, tic.doc.contact, tic.doc.company, d.name)) \ No newline at end of file diff --git a/patches/september_2012/reload_gross_profit.py b/patches/may_2013/p04_reorder_level.py similarity index 78% rename from patches/september_2012/reload_gross_profit.py rename to patches/may_2013/p04_reorder_level.py index 0a3f9efed7..8f4d669bc5 100644 --- a/patches/september_2012/reload_gross_profit.py +++ b/patches/may_2013/p04_reorder_level.py @@ -15,7 +15,9 @@ # along with this program. If not, see . from __future__ import unicode_literals +import webnotes def execute(): - # reload gross profit report - from webnotes.modules import reload_doc - reload_doc('selling', 'search_criteria', 'gross_profit') \ No newline at end of file + webnotes.reload_doc("Setup", "DocType", "Global Defaults") + + if webnotes.conn.exists({"doctype": "Item", "email_notify": 1}): + webnotes.conn.set_value("Global Defaults", None, "reorder_email_notify", 1) \ No newline at end of file diff --git a/patches/may_2013/p05_update_cancelled_gl_entries.py b/patches/may_2013/p05_update_cancelled_gl_entries.py new file mode 100644 index 0000000000..59eed7e66f --- /dev/null +++ b/patches/may_2013/p05_update_cancelled_gl_entries.py @@ -0,0 +1,29 @@ +# 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 +import webnotes +from webnotes.utils import cint + +def execute(): + aii_enabled = cint(webnotes.conn.get_value("Global Defaults", None, + "auto_inventory_accounting")) + + if aii_enabled: + webnotes.conn.sql("""update `tabGL Entry` gle set is_cancelled = 'Yes' + where voucher_type = 'Delivery Note' + and exists(select name from `tabDelivery Note` + where name = gle.voucher_no and docstatus = 2)""") \ No newline at end of file diff --git a/patches/may_2013/repost_stock_for_no_posting_time.py b/patches/may_2013/repost_stock_for_no_posting_time.py new file mode 100644 index 0000000000..489511c53e --- /dev/null +++ b/patches/may_2013/repost_stock_for_no_posting_time.py @@ -0,0 +1,34 @@ +# 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 + from stock.stock_ledger import update_entries_after + + res = webnotes.conn.sql("""select distinct item_code, warehouse from `tabStock Ledger Entry` + where posting_time = '00:00'""") + + i=0 + for d in res: + try: + update_entries_after({ "item_code": d[0], "warehouse": d[1] }) + except: + pass + i += 1 + if i%20 == 0: + webnotes.conn.sql("commit") + webnotes.conn.sql("start transaction") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index ed1c8462cd..ea61a04dc3 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -74,15 +74,12 @@ patch_list = [ "patches.july_2012.auth_table", "patches.july_2012.remove_event_role_owner_match", "patches.july_2012.deprecate_bulk_rename", - "patches.july_2012.blog_guest_permission", "patches.july_2012.bin_permission", "patches.july_2012.project_patch_repeat", "patches.july_2012.repost_stock_due_to_wrong_packing_list", "patches.july_2012.supplier_quotation", - "patches.august_2012.report_supplier_quotations", "patches.august_2012.task_allocated_to_assigned", "patches.august_2012.change_profile_permission", - "patches.august_2012.changed_blog_date_format", "patches.august_2012.repost_billed_amt", "patches.august_2012.remove_cash_flow_statement", "patches.september_2012.stock_report_permissions_for_accounts", @@ -93,7 +90,6 @@ patch_list = [ "patches.september_2012.plot_patch", "patches.september_2012.event_permission", "patches.september_2012.repost_stock", - "patches.september_2012.reload_gross_profit", "patches.september_2012.rebuild_trees", "patches.september_2012.deprecate_account_balance", "patches.september_2012.profile_delete_permission", @@ -250,4 +246,10 @@ patch_list = [ "patches.april_2013.p07_update_file_data_2", "patches.april_2013.rebuild_sales_browser", "patches.april_2013.p08_price_list_country", + "patches.may_2013.repost_stock_for_no_posting_time", + "patches.may_2013.p01_conversion_factor_and_aii", + "patches.may_2013.p02_update_valuation_rate", + "patches.may_2013.p03_update_support_ticket", + "patches.may_2013.p04_reorder_level", + "patches.may_2013.p05_update_cancelled_gl_entries", ] \ No newline at end of file diff --git a/projects/doctype/time_log/time_log.js b/projects/doctype/time_log/time_log.js index a6023320f1..22f9610b8f 100644 --- a/projects/doctype/time_log/time_log.js +++ b/projects/doctype/time_log/time_log.js @@ -1,5 +1,9 @@ -$.extend(cur_frm.cscript, { - refresh: function(doc) { - +wn.provide("erpnext.projects"); + +erpnext.projects.TimeLog = wn.ui.form.Controller.extend({ + setup: function() { + this.frm.set_query("task", erpnext.queries.task); } -}); \ No newline at end of file +}); + +cur_frm.cscript = new erpnext.projects.TimeLog({frm: cur_frm}); \ No newline at end of file diff --git a/projects/utils.py b/projects/utils.py index 7a45b08d9d..e37a21c2c4 100644 --- a/projects/utils.py +++ b/projects/utils.py @@ -5,4 +5,25 @@ import webnotes @webnotes.whitelist() def get_time_log_list(doctype, txt, searchfield, start, page_len, filters): - return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"]) \ No newline at end of file + return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"]) + +@webnotes.whitelist() +def query_task(doctype, txt, searchfield, start, page_len, filters): + from webnotes.widgets.reportview import build_match_conditions + + search_string = "%%%s%%" % txt + order_by_string = "%s%%" % txt + match_conditions = build_match_conditions("Task") + match_conditions = ("and" + match_conditions) if match_conditions else "" + + return webnotes.conn.sql("""select name, subject from `tabTask` + where (`%s` like %s or `subject` like %s) %s + order by + case when `subject` like %s then 0 else 1 end, + case when `%s` like %s then 0 else 1 end, + `%s`, + subject + limit %s, %s""" % + (searchfield, "%s", "%s", match_conditions, "%s", + searchfield, "%s", searchfield, "%s", "%s"), + (search_string, search_string, order_by_string, order_by_string, start, page_len)) \ No newline at end of file diff --git a/public/js/complete_setup.js b/public/js/complete_setup.js index f5d06722c6..f0b21c8516 100644 --- a/public/js/complete_setup.js +++ b/public/js/complete_setup.js @@ -40,7 +40,7 @@ $.extend(erpnext.complete_setup, { {fieldname:'country', label: 'Country', reqd:1, options: "", fieldtype: 'Select'}, {fieldname:'currency', label: 'Default Currency', reqd:1, - options: "Currency", fieldtype: 'Link'}, + options: "", fieldtype: 'Select'}, {fieldname:'timezone', label: 'Time Zone', reqd:1, options: "", fieldtype: 'Select'}, {fieldname:'industry', label: 'Industry', reqd:1, @@ -55,11 +55,17 @@ $.extend(erpnext.complete_setup, { } wn.call({ - method:"webnotes.country_info.get_all", + method:"webnotes.country_info.get_country_timezone_info", callback: function(data) { - erpnext.country_info = data.message; + erpnext.country_info = data.message.country_info; + erpnext.all_timezones = data.message.all_timezones; d.get_input("country").empty() - .add_options([""].concat(keys(data.message).sort())); + .add_options([""].concat(keys(erpnext.country_info).sort())); + d.get_input("currency").empty() + .add_options(wn.utils.unique([""].concat($.map(erpnext.country_info, + function(opts, country) { return opts.currency; }))).sort()); + d.get_input("timezone").empty() + .add_options([""].concat(erpnext.all_timezones)); } }) @@ -82,19 +88,15 @@ $.extend(erpnext.complete_setup, { var country = d.fields_dict.country.input.value; var $timezone = $(d.fields_dict.timezone.input); $timezone.empty(); + // add country specific timezones first if(country){ - var timezone_list = erpnext.country_info[country].timezones; - if(timezone_list.length==0) { - timezone_list = $.map(erpnext.country_info, function(m) { - return m.timezones - }); - } - $timezone.empty().add_options(timezone_list); - - console.log(d.get_input("currency")) + var timezone_list = erpnext.country_info[country].timezones || []; + $timezone.add_options(timezone_list.sort()); d.get_input("currency").val(erpnext.country_info[country].currency); } + // add all timezones at the end, so that user has the option to change it to any timezone + $timezone.add_options([""].concat(erpnext.all_timezones)); }; @@ -127,5 +129,5 @@ $.extend(erpnext.complete_setup, { 'Finance', 'Food and Beverage', 'Government', 'Healthcare', 'Hospitality', 'Information Technology', 'Insurance', 'Machinery', 'Manufacturing', 'Media', 'Not For Profit', 'Recreation', 'Retail', 'Shipping', 'Technology', - 'Telecommunications', 'Transportation', 'Trading', 'Utilities', 'Other'], + 'Telecommunications', 'Transportation', 'Trading', 'Utilities', 'Other'], }); \ No newline at end of file diff --git a/public/js/queries.js b/public/js/queries.js index 9809cd980d..24ddc13590 100644 --- a/public/js/queries.js +++ b/public/js/queries.js @@ -160,4 +160,8 @@ erpnext.queries.bom = function(opts) { : "") + " LIMIT 50" -} \ No newline at end of file +} + +erpnext.queries.task = function() { + return { query: "projects.utils.query_task" }; +}; \ No newline at end of file diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index 7e16341a4a..6f54ef9641 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -216,7 +216,7 @@ class DocType(TransactionBase): if self.doc.lead_name: sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name) - def on_rename(self, new, old): + def on_rename(self, new, old, merge=False): #update customer_name if not naming series if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name': update_fields = [ @@ -244,7 +244,7 @@ class DocType(TransactionBase): for account in webnotes.conn.sql("""select name, account_name from tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1): if account.account_name != new: - webnotes.rename_doc("Account", account.name, new) + webnotes.rename_doc("Account", account.name, new, merge=merge) #update master_name in doctype account webnotes.conn.sql("""update `tabAccount` set master_name = %s, diff --git a/selling/doctype/customer/test_customer.py b/selling/doctype/customer/test_customer.py index 551b03f0be..806585f1e1 100644 --- a/selling/doctype/customer/test_customer.py +++ b/selling/doctype/customer/test_customer.py @@ -1,4 +1,60 @@ +from __future__ import unicode_literals +import webnotes +import unittest + +class TestCustomer(unittest.TestCase): + def test_rename(self): + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"), + (("_Test Customer 1",),)) + + webnotes.rename_doc("Customer", "_Test Customer 1", "_Test Customer 1 Renamed") + + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1 Renamed"), + (("_Test Customer 1 Renamed",),)) + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"), ()) + + def test_merge(self): + from webnotes.test_runner import make_test_records + make_test_records("Sales Invoice") + + # clear transactions for new name + webnotes.conn.sql("""delete from `tabSales Invoice` where customer='_Test Customer 1'""") + + # check if they exist + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"), + (("_Test Customer",),)) + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"), + (("_Test Customer 1",),)) + self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"), + (("_Test Customer - _TC",),)) + self.assertEqual(webnotes.conn.exists("Account", "_Test Customer 1 - _TC"), + (("_Test Customer 1 - _TC",),)) + + # check if transactions exists + self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where customer='_Test Customer'""", )[0][0], 0) + self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where debit_to='_Test Customer - _TC'""", )[0][0], 0) + + webnotes.rename_doc("Customer", "_Test Customer", "_Test Customer 1", merge=True) + + # check that no transaction exists for old name + self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where customer='_Test Customer 1'""", )[0][0], 0) + self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where debit_to='_Test Customer 1 - _TC'""", )[0][0], 0) + + # check that transactions exist for new name + self.assertEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where customer='_Test Customer'""", )[0][0], 0) + self.assertEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where debit_to='_Test Customer - _TC'""", )[0][0], 0) + + # check that old name doesn't exist + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"), ()) + self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"), ()) + test_records = [ [{ "doctype": "Customer", @@ -7,5 +63,13 @@ test_records = [ "customer_group": "_Test Customer Group", "territory": "_Test Territory", "company": "_Test Company" + }], + [{ + "doctype": "Customer", + "customer_name": "_Test Customer 1", + "customer_type": "Individual", + "customer_group": "_Test Customer Group", + "territory": "_Test Territory", + "company": "_Test Company" }] ] \ No newline at end of file diff --git a/selling/doctype/installation_note/installation_note.py b/selling/doctype/installation_note/installation_note.py index b0e1d966d9..ea20d51d64 100644 --- a/selling/doctype/installation_note/installation_note.py +++ b/selling/doctype/installation_note/installation_note.py @@ -18,9 +18,7 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import cstr, getdate -from webnotes.model import db_exists -from webnotes.model.doc import make_autoname -from webnotes.model.bean import getlist, copy_doclist +from webnotes.model.bean import getlist from webnotes.model.code import get_obj from webnotes import msgprint from stock.utils import get_valid_serial_nos @@ -37,9 +35,6 @@ class DocType(TransactionBase): self.tname = 'Installation Note Item' self.fname = 'installed_item_details' - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series+'.#####') - def validate(self): self.validate_fiscal_year() self.validate_installation_date() diff --git a/selling/doctype/installation_note/installation_note.txt b/selling/doctype/installation_note/installation_note.txt index 52917e0b01..9dd851d583 100644 --- a/selling/doctype/installation_note/installation_note.txt +++ b/selling/doctype/installation_note/installation_note.txt @@ -1,13 +1,13 @@ [ { - "creation": "2013-01-10 16:34:18", + "creation": "2013-04-30 13:13:06", "docstatus": 0, - "modified": "2013-01-22 14:56:02", + "modified": "2013-05-09 14:43:28", "modified_by": "Administrator", "owner": "Administrator" }, { - "autoname": "IN/.####", + "autoname": "naming_series:", "doctype": "DocType", "is_submittable": 1, "module": "Selling", @@ -33,6 +33,7 @@ "permlevel": 0, "read": 1, "report": 1, + "role": "Sales User", "submit": 1, "write": 1 }, @@ -302,15 +303,6 @@ "options": "Installation Note Item" }, { - "doctype": "DocPerm", - "role": "System Manager" - }, - { - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "doctype": "DocPerm", - "role": "Sales Manager" + "doctype": "DocPerm" } ] \ No newline at end of file diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index 0d306748c5..c94aafa08a 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -104,7 +104,17 @@ cur_frm.cscript['Create Customer'] = function(){ 'from_to_list':"[['Lead', 'Customer']]" }, function(r,rt) { - loaddoc("Customer", n); + wn.model.with_doctype("Customer", function() { + var customer = wn.model.get_doc("Customer", n); + var customer_copy = $.extend({}, customer); + + var updated = wn.model.set_default_values(customer_copy); + $.each(updated, function(i, f) { + if(!customer[f]) customer[f] = customer_copy[f]; + }); + + loaddoc("Customer", n); + }); } ); } diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt index feda14c591..4115be833b 100644 --- a/selling/doctype/quotation/quotation.txt +++ b/selling/doctype/quotation/quotation.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-04-03 09:10:44", + "creation": "2013-05-22 12:10:46", "docstatus": 0, - "modified": "2013-04-03 09:58:02", + "modified": "2013-05-22 16:54:07", "modified_by": "Administrator", "owner": "Administrator" }, @@ -833,12 +833,11 @@ "width": "100px" }, { - "description": "Keep a track on communications regarding this Quotation. This will help you remember earlier communications in case the Customer comes back again", "doctype": "DocField", "fieldname": "communication_history", "fieldtype": "Section Break", - "label": "Communication History", "oldfieldtype": "Section Break", + "options": "Simple", "print_hide": 1, "read_only": 0 }, @@ -869,28 +868,23 @@ "cancel": 1, "create": 1, "doctype": "DocPerm", - "role": "Sales Manager", + "role": "Sales User", "submit": 1, "write": 1 }, + { + "doctype": "DocPerm", + "role": "Customer" + }, { "amend": 1, "cancel": 1, "create": 1, "doctype": "DocPerm", - "role": "Sales User", + "role": "Sales Manager", "submit": 1, "write": 1 }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "role": "Customer", - "submit": 0, - "write": 0 - }, { "amend": 1, "cancel": 1, diff --git a/selling/doctype/quotation_item/quotation_item.txt b/selling/doctype/quotation_item/quotation_item.txt index dccc503764..bcb9281cb9 100644 --- a/selling/doctype/quotation_item/quotation_item.txt +++ b/selling/doctype/quotation_item/quotation_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-02-22 01:27:52", + "creation": "2013-03-07 11:42:57", "docstatus": 0, - "modified": "2013-03-07 07:03:29", + "modified": "2013-05-22 12:08:32", "modified_by": "Administrator", "owner": "Administrator" }, @@ -37,6 +37,7 @@ "options": "Item", "print_hide": 0, "print_width": "150px", + "read_only": 0, "reqd": 1, "search_index": 1, "width": "150px" @@ -60,6 +61,7 @@ "oldfieldtype": "Data", "print_hide": 1, "print_width": "150px", + "read_only": 0, "reqd": 1, "search_index": 1, "width": "150px" @@ -73,6 +75,7 @@ "oldfieldtype": "Small Text", "print_hide": 0, "print_width": "300px", + "read_only": 0, "reqd": 1, "width": "300px" }, @@ -87,6 +90,7 @@ "oldfieldtype": "Currency", "print_hide": 0, "print_width": "100px", + "read_only": 0, "reqd": 1, "search_index": 0, "width": "100px" @@ -115,6 +119,7 @@ "options": "currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "reqd": 0, "width": "100px" }, @@ -128,6 +133,7 @@ "oldfieldtype": "Float", "print_hide": 1, "print_width": "100px", + "read_only": 0, "width": "100px" }, { @@ -142,6 +148,7 @@ "options": "currency", "print_hide": 0, "print_width": "100px", + "read_only": 0, "reqd": 0, "search_index": 0, "width": "100px" @@ -188,6 +195,7 @@ "options": "Company:company:default_currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "reqd": 0, "search_index": 0, "width": "100px" @@ -291,6 +299,7 @@ "oldfieldname": "page_break", "oldfieldtype": "Check", "print_hide": 1, + "read_only": 0, "report_hide": 1 } ] \ No newline at end of file diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py index 6a52e5a0fa..c8db1f919f 100644 --- a/selling/doctype/sales_order/sales_order.py +++ b/selling/doctype/sales_order/sales_order.py @@ -217,7 +217,10 @@ class DocType(SellingController): self.validate_proj_cust() self.validate_po() #self.validate_reference_value() - self.validate_for_items() + + if self.doc.docstatus == 1: + self.validate_for_items() + sales_com_obj = get_obj(dt = 'Sales Common') sales_com_obj.check_active_sales_items(self) sales_com_obj.check_conversion_rate(self) diff --git a/selling/doctype/sales_order_item/sales_order_item.txt b/selling/doctype/sales_order_item/sales_order_item.txt index fff2d080f3..c65ac0d938 100644 --- a/selling/doctype/sales_order_item/sales_order_item.txt +++ b/selling/doctype/sales_order_item/sales_order_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-02-22 01:27:52", + "creation": "2013-03-07 11:42:58", "docstatus": 0, - "modified": "2013-03-07 07:03:30", + "modified": "2013-05-22 12:09:03", "modified_by": "Administrator", "owner": "Administrator" }, @@ -35,6 +35,7 @@ "oldfieldtype": "Link", "options": "Item", "print_width": "150px", + "read_only": 0, "reqd": 1, "search_index": 1, "width": "150px" @@ -57,6 +58,7 @@ "oldfieldtype": "Data", "print_hide": 1, "print_width": "150", + "read_only": 0, "reqd": 1, "width": "150" }, @@ -69,6 +71,7 @@ "oldfieldname": "description", "oldfieldtype": "Small Text", "print_width": "300px", + "read_only": 0, "reqd": 1, "search_index": 1, "width": "300px" @@ -82,6 +85,7 @@ "oldfieldname": "qty", "oldfieldtype": "Currency", "print_width": "100px", + "read_only": 0, "reqd": 1, "width": "100px" }, @@ -109,6 +113,7 @@ "options": "currency", "print_hide": 1, "print_width": "70px", + "read_only": 0, "reqd": 0, "width": "70px" }, @@ -122,6 +127,7 @@ "oldfieldtype": "Float", "print_hide": 1, "print_width": "70px", + "read_only": 0, "width": "70px" }, { @@ -134,6 +140,7 @@ "oldfieldtype": "Currency", "options": "currency", "print_width": "100px", + "read_only": 0, "reqd": 0, "width": "100px" }, @@ -176,6 +183,7 @@ "options": "Company:company:default_currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "reqd": 0, "width": "100px" }, @@ -206,6 +214,7 @@ "options": "Warehouse", "print_hide": 1, "print_width": "150px", + "read_only": 0, "reqd": 0, "width": "150px" }, @@ -329,6 +338,7 @@ "hidden": 0, "in_filter": 1, "label": "Quotation No.", + "no_copy": 1, "oldfieldname": "prevdoc_docname", "oldfieldtype": "Link", "options": "Quotation", @@ -345,6 +355,7 @@ "oldfieldname": "page_break", "oldfieldtype": "Check", "print_hide": 1, + "read_only": 0, "report_hide": 1 }, { diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index 78be5380b2..9863d7d28b 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -16,6 +16,7 @@ from __future__ import unicode_literals import webnotes +from webnotes import _, msgprint from webnotes.utils import cstr from webnotes.model.doc import Document @@ -287,7 +288,10 @@ class DocType: where doctype='Global Defaults' and field='default_company' and value=%s""", self.doc.name) - def on_rename(self,newdn,olddn): + def on_rename(self,newdn,olddn, merge=False): + if merge: + msgprint(_("Sorry. Companies cannot be merged"), raise_exception=True) + webnotes.conn.sql("""update `tabCompany` set company_name=%s where name=%s""", (newdn, olddn)) diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt index 853bb57705..175ca9414b 100644 --- a/setup/doctype/global_defaults/global_defaults.txt +++ b/setup/doctype/global_defaults/global_defaults.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-04-01 15:05:24", + "creation": "2013-05-02 17:53:24", "docstatus": 0, - "modified": "2013-05-02 15:05:21", + "modified": "2013-05-22 15:57:26", "modified_by": "Administrator", "owner": "Administrator" }, @@ -27,6 +27,8 @@ "permlevel": 0 }, { + "amend": 0, + "cancel": 0, "create": 1, "doctype": "DocPerm", "name": "__common__", @@ -170,7 +172,8 @@ "fieldname": "item_naming_by", "fieldtype": "Select", "label": "Item Naming By", - "options": "Item Code\nNaming Series" + "options": "Item Code\nNaming Series", + "read_only": 0 }, { "doctype": "DocField", @@ -212,14 +215,6 @@ "label": "Allow Negative Stock", "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "default_warehouse_type", - "fieldtype": "Link", - "label": "Default Warehouse Type", - "options": "Warehouse Type", - "read_only": 0 - }, { "doctype": "DocField", "fieldname": "auto_indent", @@ -227,6 +222,21 @@ "label": "Raise Material Request when stock reaches re-order level", "read_only": 0 }, + { + "doctype": "DocField", + "fieldname": "reorder_email_notify", + "fieldtype": "Check", + "label": "Notify by Email on creation of automatic Material Request" + }, + { + "default": "Hourly", + "doctype": "DocField", + "fieldname": "reorder_level_checking_frequency", + "fieldtype": "Select", + "hidden": 1, + "label": "Reorder Level Checking Frequency", + "options": "Hourly\nDaily" + }, { "default": "1", "doctype": "DocField", @@ -235,6 +245,14 @@ "read_only": 0, "width": "50%" }, + { + "doctype": "DocField", + "fieldname": "default_warehouse_type", + "fieldtype": "Link", + "label": "Default Warehouse Type", + "options": "Warehouse Type", + "read_only": 0 + }, { "description": "Percentage you are allowed to receive or deliver more against the quantity ordered.

For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units

", "doctype": "DocField", @@ -274,7 +292,8 @@ "fieldtype": "Check", "label": "Auto Inventory Accounting", "no_copy": 0, - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "description": "Accounting entry frozen up to this date, nobody can do / modify entry except authorized person", @@ -507,11 +526,6 @@ "label": "SMS Sender Name", "read_only": 0 }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm" - }, { "doctype": "DocPerm" } diff --git a/setup/doctype/item_group/item_group.py b/setup/doctype/item_group/item_group.py index 1445f3999f..1ff3d4a939 100644 --- a/setup/doctype/item_group/item_group.py +++ b/setup/doctype/item_group/item_group.py @@ -81,3 +81,4 @@ class DocType(DocTypeNestedSet): if self.doc.slideshow: from website.helpers.slideshow import get_slideshow get_slideshow(self) + \ No newline at end of file diff --git a/setup/doctype/price_list/price_list.py b/setup/doctype/price_list/price_list.py index ae49bf868d..5c03a3a853 100644 --- a/setup/doctype/price_list/price_list.py +++ b/setup/doctype/price_list/price_list.py @@ -33,3 +33,6 @@ class DocType: msgprint(_("""Please check "Valid For All Countries" or \ enter atlease one row in the "Countries" table."""), raise_exception=True) + def on_trash(self): + webnotes.conn.sql("""delete from `tabItem Price` where price_list_name = %s""", + self.doc.name) \ No newline at end of file diff --git a/setup/page/setup/setup.js b/setup/page/setup/setup.js index b47f6f28d1..1ebd7307a6 100644 --- a/setup/page/setup/setup.js +++ b/setup/page/setup/setup.js @@ -193,21 +193,8 @@ wn.module_page["Setup"] = [ ] }, { - title: wn._("Backups"), - icon: "icon-cloud-upload", - right: true, - items: [ - { - "route":"Form/Backup Manager", - doctype:"Backup Manager", - label: wn._("Backup Manager"), - "description":wn._("Sync backups with remote tools like Dropbox etc.") - }, - ] - }, - { - title: wn._("Update Manager"), - icon: "icon-magnet", + title: wn._("Administration"), + icon: "icon-rocket", right: true, items: [ { @@ -215,6 +202,18 @@ wn.module_page["Setup"] = [ label: wn._("Update This Application"), "description":wn._("Apply latest updates and patches to this app") }, + { + "route":"Form/Backup Manager", + doctype:"Backup Manager", + label: wn._("Backup Manager"), + "description":wn._("Sync backups with remote tools like Dropbox etc.") + }, + { + "route":"List/Scheduler Log", + doctype:"Scheduler Log", + label: wn._("Scheduler Error Log"), + "description":wn._("Get a list of errors encountered by the Scheduler") + }, ] }, ] diff --git a/startup/schedule_handlers.py b/startup/schedule_handlers.py index 0799817206..cc0d1f4fea 100644 --- a/startup/schedule_handlers.py +++ b/startup/schedule_handlers.py @@ -55,6 +55,10 @@ def execute_daily(): from setup.doctype.backup_manager.backup_manager import take_backups_daily take_backups_daily() + # check reorder level + from stock.utils import reorder_item + run_fn(reorder_item) + def execute_weekly(): from setup.doctype.backup_manager.backup_manager import take_backups_weekly take_backups_weekly() diff --git a/startup/website.py b/startup/website.py index be8eba6def..5e6c3118c2 100644 --- a/startup/website.py +++ b/startup/website.py @@ -1,5 +1,5 @@ import webnotes, conf, os -from webnotes.utils import cint, cstr +from webnotes.utils import cint, cstr, encode def get_templates_path(): return os.path.join(os.path.dirname(conf.__file__), "app", "website", "templates") @@ -72,7 +72,7 @@ def update_template_args(page_name, args): args[k] = cint(args.get(k) or 0) args.url = quote(str(get_request_site_address(full_address=True)), str("")) - args.encoded_title = quote(str(args.title or ""), str("")) + args.encoded_title = quote(encode(args.title or ""), str("")) return args \ No newline at end of file diff --git a/stock/doctype/bin/bin.py b/stock/doctype/bin/bin.py index 2d98c2634f..61baafafa2 100644 --- a/stock/doctype/bin/bin.py +++ b/stock/doctype/bin/bin.py @@ -77,10 +77,6 @@ class DocType: self.doc.save() - if (flt(args.get("actual_qty")) < 0 or flt(args.get("reserved_qty")) > 0) \ - and args.get("is_cancelled") == 'No' and args.get("is_amended")=='No': - self.reorder_item(args.get("voucher_type"), args.get("voucher_no"), args.get("company")) - def get_first_sle(self): sle = sql(""" select * from `tabStock Ledger Entry` @@ -90,82 +86,4 @@ class DocType: order by timestamp(posting_date, posting_time) asc, name asc limit 1 """, (self.doc.item_code, self.doc.warehouse), as_dict=1) - return sle and sle[0] or None - - def reorder_item(self,doc_type,doc_name, company): - """ Reorder item if stock reaches reorder level""" - if not hasattr(webnotes, "auto_indent"): - webnotes.auto_indent = webnotes.conn.get_value('Global Defaults', None, 'auto_indent') - - if webnotes.auto_indent: - #check if re-order is required - item_reorder = webnotes.conn.get("Item Reorder", - {"parent": self.doc.item_code, "warehouse": self.doc.warehouse}) - if item_reorder: - reorder_level = item_reorder.warehouse_reorder_level - reorder_qty = item_reorder.warehouse_reorder_qty - material_request_type = item_reorder.material_request_type or "Purchase" - else: - reorder_level, reorder_qty = webnotes.conn.get_value("Item", self.doc.item_code, - ["re_order_level", "re_order_qty"]) - material_request_type = "Purchase" - - if flt(reorder_qty) and flt(self.doc.projected_qty) < flt(reorder_level): - self.create_material_request(doc_type, doc_name, reorder_level, reorder_qty, - company, material_request_type) - - def create_material_request(self, doc_type, doc_name, reorder_level, reorder_qty, company, - material_request_type="Purchase"): - """ Create indent on reaching reorder level """ - defaults = webnotes.defaults.get_defaults() - item = webnotes.doc("Item", self.doc.item_code) - - mr = webnotes.bean([{ - "doctype": "Material Request", - "company": company or defaults.company, - "fiscal_year": defaults.fiscal_year, - "transaction_date": nowdate(), - "material_request_type": material_request_type, - "remark": _("This is an auto generated Material Request.") + \ - _("It was raised because the (actual + ordered + indented - reserved) quantity reaches re-order level when the following record was created") + \ - ": " + _(doc_type) + " " + doc_name - }, { - "doctype": "Material Request Item", - "parenttype": "Material Request", - "parentfield": "indent_details", - "item_code": self.doc.item_code, - "schedule_date": add_days(nowdate(),cint(item.lead_time_days)), - "uom": self.doc.stock_uom, - "warehouse": self.doc.warehouse, - "item_name": item.item_name, - "description": item.description, - "item_group": item.item_group, - "qty": reorder_qty, - "brand": item.brand, - }]) - mr.insert() - mr.submit() - - msgprint("""Item: %s is to be re-ordered. Material Request %s raised. - It was generated from %s: %s""" % - (self.doc.item_code, mr.doc.name, doc_type, doc_name)) - - if(item.email_notify): - self.send_email_notification(doc_type, doc_name, mr) - - def send_email_notification(self, doc_type, doc_name, bean): - """ Notify user about auto creation of indent""" - - from webnotes.utils.email_lib import sendmail - email_list=[d[0] for d in sql("""select distinct r.parent from tabUserRole r, tabProfile p - where p.name = r.parent and p.enabled = 1 and p.docstatus < 2 - and r.role in ('Purchase Manager','Material Manager') - and p.name not in ('Administrator', 'All', 'Guest')""")] - - msg="""A new Material Request has been raised for Item: %s and Warehouse: %s \ - on %s due to %s: %s. See %s: %s """ % (self.doc.item_code, self.doc.warehouse, - formatdate(), doc_type, doc_name, bean.doc.doctype, - get_url_to_form(bean.doc.doctype, bean.doc.name)) - - sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg) - + return sle and sle[0] or None \ No newline at end of file diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py index 15e24ef293..6ffd960000 100644 --- a/stock/doctype/delivery_note/delivery_note.py +++ b/stock/doctype/delivery_note/delivery_note.py @@ -419,4 +419,4 @@ class DocType(SellingController): if gl_entries: from accounts.general_ledger import make_gl_entries - make_gl_entries(gl_entries) \ No newline at end of file + make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2)) \ No newline at end of file diff --git a/stock/doctype/delivery_note_item/delivery_note_item.txt b/stock/doctype/delivery_note_item/delivery_note_item.txt index 1073f0cdc2..f90ba69f53 100644 --- a/stock/doctype/delivery_note_item/delivery_note_item.txt +++ b/stock/doctype/delivery_note_item/delivery_note_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-04-01 10:49:21", + "creation": "2013-04-22 13:15:44", "docstatus": 0, - "modified": "2013-04-17 17:20:58", + "modified": "2013-05-22 12:05:32", "modified_by": "Administrator", "owner": "Administrator" }, @@ -340,6 +340,7 @@ "hidden": 1, "in_filter": 1, "label": "Document Type", + "no_copy": 1, "oldfieldname": "prevdoc_doctype", "oldfieldtype": "Data", "print_hide": 1, @@ -371,6 +372,7 @@ "hidden": 1, "in_filter": 1, "label": "Against Document Date", + "no_copy": 1, "oldfieldname": "prevdoc_date", "oldfieldtype": "Date", "print_hide": 1, @@ -383,6 +385,7 @@ "hidden": 1, "in_filter": 1, "label": "Against Document Detail No", + "no_copy": 1, "oldfieldname": "prevdoc_detail_docname", "oldfieldtype": "Data", "print_hide": 1, diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index fde532c96c..d743a98005 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -51,6 +51,7 @@ class DocType(DocListController): self.validate_barcode() self.check_non_asset_warehouse() self.cant_change() + self.validate_item_type_for_reorder() if self.doc.name: self.old_page_name = webnotes.conn.get_value('Item', self.doc.name, 'page_name') @@ -201,6 +202,13 @@ class DocType(DocListController): webnotes.msgprint(_("As there are existing stock transactions for this \ item, you can not change the values of 'Has Serial No', \ 'Is Stock Item' and 'Valuation Method'"), raise_exception=1) + + def validate_item_type_for_reorder(self): + if self.doc.re_order_level or len(self.doclist.get({"parentfield": "item_reorder", + "material_request_type": "Purchase"})): + if not self.doc.is_purchase_item: + webnotes.msgprint(_("""To set reorder level, item must be Purchase Item"""), + raise_exception=1) def check_if_sle_exists(self): sle = webnotes.conn.sql("""select name from `tabStock Ledger Entry` @@ -272,7 +280,7 @@ class DocType(DocListController): from webnotes.webutils import clear_cache clear_cache(self.doc.page_name) - def on_rename(self,newdn,olddn): + def on_rename(self,newdn,olddn, merge=False): webnotes.conn.sql("update tabItem set item_code = %s where name = %s", (newdn, olddn)) if self.doc.page_name: from webnotes.webutils import clear_cache diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt index c799029d95..9e0a2fb24e 100644 --- a/stock/doctype/item/item.txt +++ b/stock/doctype/item/item.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-03 10:45:46", "docstatus": 0, - "modified": "2013-05-07 15:58:58", + "modified": "2013-05-22 15:48:27", "modified_by": "Administrator", "owner": "Administrator" }, @@ -363,21 +363,6 @@ "label": "Re-Order Qty", "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "column_break_31", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "description": "Send an email to users of role \"Material Manager\" and \"Purchase Manager\" when re-order level is crossed.", - "doctype": "DocField", - "fieldname": "email_notify", - "fieldtype": "Check", - "label": "Notify by Email on Re-order", - "read_only": 0 - }, { "doctype": "DocField", "fieldname": "section_break_31", diff --git a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt index 7f4e827aa3..8cef6a3534 100755 --- a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt +++ b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-02-22 01:28:03", + "creation": "2013-03-07 11:42:59", "docstatus": 0, - "modified": "2013-03-07 07:03:28", + "modified": "2013-05-22 12:01:08", "modified_by": "Administrator", "owner": "Administrator" }, @@ -35,6 +35,7 @@ "oldfieldtype": "Link", "options": "Item", "print_width": "100px", + "read_only": 0, "reqd": 1, "search_index": 1, "width": "100px" @@ -48,6 +49,7 @@ "oldfieldname": "item_name", "oldfieldtype": "Data", "print_hide": 1, + "read_only": 0, "reqd": 1, "search_index": 0 }, @@ -59,6 +61,7 @@ "oldfieldname": "description", "oldfieldtype": "Text", "print_width": "300px", + "read_only": 0, "reqd": 1, "width": "300px" }, @@ -72,6 +75,7 @@ "oldfieldtype": "Currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "reqd": 1, "width": "100px" }, @@ -84,6 +88,7 @@ "oldfieldname": "qty", "oldfieldtype": "Currency", "print_width": "100px", + "read_only": 0, "width": "100px" }, { @@ -97,6 +102,7 @@ "oldfieldtype": "Currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "search_index": 0, "width": "100px" }, @@ -110,6 +116,7 @@ "options": "UOM", "print_hide": 1, "print_width": "100px", + "read_only": 0, "reqd": 1, "width": "100px" }, @@ -119,14 +126,16 @@ "fieldtype": "Currency", "label": "Ref Rate ", "options": "currency", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", "fieldname": "discount_rate", "fieldtype": "Float", "label": "Discount %", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "default": "0.00", @@ -139,6 +148,7 @@ "options": "currency", "print_hide": 0, "print_width": "100px", + "read_only": 0, "width": "100px" }, { @@ -157,7 +167,8 @@ "fieldtype": "Currency", "label": "Ref Rate*", "options": "Company:company:default_currency", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "default": "0.00", @@ -170,6 +181,7 @@ "options": "Company:company:default_currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "reqd": 1, "width": "100px" }, @@ -184,6 +196,7 @@ "options": "Company:company:default_currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "reqd": 0, "width": "100px" }, @@ -198,6 +211,7 @@ "options": "Warehouse", "print_hide": 1, "print_width": "100px", + "read_only": 0, "width": "100px" }, { @@ -209,6 +223,7 @@ "oldfieldtype": "Currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "reqd": 1, "width": "100px" }, @@ -235,6 +250,7 @@ "oldfieldname": "serial_no", "oldfieldtype": "Text", "print_hide": 0, + "read_only": 0, "report_hide": 0 }, { @@ -242,7 +258,8 @@ "fieldname": "rejected_serial_no", "fieldtype": "Text", "label": "Rejected Serial No", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -252,7 +269,8 @@ "oldfieldname": "batch_no", "oldfieldtype": "Link", "options": "Batch", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -278,6 +296,7 @@ "oldfieldname": "schedule_date", "oldfieldtype": "Date", "print_hide": 1, + "read_only": 0, "report_hide": 0, "reqd": 0 }, @@ -288,7 +307,8 @@ "in_filter": 1, "label": "Project Name", "options": "Project", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -299,7 +319,8 @@ "oldfieldname": "qa_no", "oldfieldtype": "Link", "options": "Quality Inspection", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -336,6 +357,7 @@ "oldfieldtype": "Currency", "print_hide": 1, "print_width": "100px", + "read_only": 0, "width": "100px" }, { @@ -344,9 +366,11 @@ "fieldtype": "Data", "hidden": 1, "label": "Prevdoc Doctype", + "no_copy": 1, "oldfieldname": "prevdoc_doctype", "oldfieldtype": "Data", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 }, { "doctype": "DocField", @@ -355,7 +379,7 @@ "hidden": 0, "in_filter": 1, "label": "PO No", - "no_copy": 0, + "no_copy": 1, "oldfieldname": "prevdoc_docname", "oldfieldtype": "Link", "options": "Purchase Order", @@ -373,6 +397,7 @@ "hidden": 1, "in_filter": 1, "label": "PO Date", + "no_copy": 1, "oldfieldname": "prevdoc_date", "oldfieldtype": "Date", "print_hide": 1, @@ -418,7 +443,7 @@ "hidden": 1, "in_filter": 1, "label": "Purchase Order Item No", - "no_copy": 0, + "no_copy": 1, "oldfieldname": "prevdoc_detail_docname", "oldfieldtype": "Data", "print_hide": 1, @@ -479,6 +504,7 @@ "label": "Page Break", "oldfieldname": "page_break", "oldfieldtype": "Check", - "print_hide": 1 + "print_hide": 1, + "read_only": 0 } ] \ No newline at end of file diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py index bbf55b35e3..09181db0d2 100644 --- a/stock/doctype/serial_no/serial_no.py +++ b/stock/doctype/serial_no/serial_no.py @@ -19,7 +19,7 @@ import webnotes from webnotes.utils import cint, getdate, nowdate import datetime -from webnotes import msgprint +from webnotes import msgprint, _ from controllers.stock_controller import StockController @@ -117,8 +117,11 @@ class DocType(StockController): self.make_stock_ledger_entry(1) self.make_gl_entries() - def on_rename(self, new, old): + def on_rename(self, new, old, merge=False): """rename serial_no text fields""" + if merge: + msgprint(_("Sorry. Serial Nos. cannot be merged"), raise_exception=True) + for dt in webnotes.conn.sql("""select parent from tabDocField where fieldname='serial_no' and fieldtype='Text'"""): @@ -139,7 +142,8 @@ class DocType(StockController): gl_entries = self.get_gl_entries_for_stock(against_stock_account, self.doc.purchase_rate) for entry in gl_entries: - entry["posting_date"] = self.doc.purchase_date + entry["posting_date"] = self.doc.purchase_date or (self.doc.creation and + self.doc.creation.split(' ')[0]) or nowdate() if gl_entries: make_gl_entries(gl_entries, cancel) \ No newline at end of file diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index d08deefa2b..bce0f620d4 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -57,6 +57,7 @@ class DocType(StockController): self.validate_return_reference_doc() self.validate_with_material_request() self.validate_fiscal_year() + self.set_total_amount() def on_submit(self): self.update_serial_no(1) @@ -174,6 +175,9 @@ class DocType(StockController): elif self.doc.purpose != "Material Transfer": self.doc.production_order = None + def set_total_amount(self): + self.doc.total_amount = sum([flt(item.amount) for item in self.doclist.get({"parentfield": "mtn_details"})]) + def make_gl_entries(self): if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")): return @@ -220,7 +224,7 @@ class DocType(StockController): if not flt(d.incoming_rate): d.incoming_rate = self.get_incoming_rate(args) - d.amount = flt(d.qty) * flt(d.incoming_rate) + d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) def get_incoming_rate(self, args): incoming_rate = 0 diff --git a/stock/doctype/stock_entry/stock_entry.txt b/stock/doctype/stock_entry/stock_entry.txt index fef710b513..d88b0b76fd 100644 --- a/stock/doctype/stock_entry/stock_entry.txt +++ b/stock/doctype/stock_entry/stock_entry.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-03-28 15:56:40", + "creation": "2013-04-09 11:43:55", "docstatus": 0, - "modified": "2013-03-29 15:31:42", + "modified": "2013-05-09 13:31:00", "modified_by": "Administrator", "owner": "Administrator" }, @@ -518,6 +518,14 @@ "read_only": 0, "width": "50%" }, + { + "doctype": "DocField", + "fieldname": "total_amount", + "fieldtype": "Currency", + "label": "Total Amount", + "options": "Company:company:default_currency", + "read_only": 1 + }, { "doctype": "DocField", "fieldname": "project_name", @@ -558,6 +566,14 @@ "read_only": 0, "reqd": 1 }, + { + "doctype": "DocField", + "fieldname": "col5", + "fieldtype": "Column Break", + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, { "allow_on_submit": 0, "doctype": "DocField", @@ -576,14 +592,6 @@ "reqd": 1, "search_index": 0 }, - { - "doctype": "DocField", - "fieldname": "col5", - "fieldtype": "Column Break", - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, { "allow_on_submit": 0, "doctype": "DocField", diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js index bfcaf8acc1..75e4ee15b0 100644 --- a/stock/page/stock_home/stock_home.js +++ b/stock/page/stock_home/stock_home.js @@ -201,6 +201,10 @@ wn.module_page["Stock"] = [ "label":wn._("Purchase In Transit"), route: "query-report/Purchase In Transit", }, + { + "label":wn._("Requested Items To Be Transferred"), + route: "query-report/Requested Items To Be Transferred", + }, ] } ] diff --git a/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt b/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt index 45e3a42dee..7a2f6365bf 100644 --- a/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt +++ b/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt @@ -1,16 +1,17 @@ [ { - "creation": "2013-02-21 14:26:49", + "creation": "2013-02-22 18:01:55", "docstatus": 0, - "modified": "2013-02-22 15:53:01", + "modified": "2013-05-13 16:11:27", "modified_by": "Administrator", "owner": "Administrator" }, { + "add_total_row": 1, "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n `tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n `tabPurchase Order`.`project_name` as \"Project\",\n `tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n `tabPurchase Order Item`.qty as \"Qty:Float:100\",\n `tabPurchase Order Item`.received_qty as \"Received Qty:Float:100\", \n (`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.received_qty, 0)) as \"Qty to Receive:Float:100\",\n `tabPurchase Order Item`.item_name as \"Item Name::150\",\n `tabPurchase Order Item`.description as \"Description::200\"\nfrom\n `tabPurchase Order`, `tabPurchase Order Item`\nwhere\n `tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n and `tabPurchase Order`.docstatus = 1\n and `tabPurchase Order`.status != \"Stopped\"\n and ifnull(`tabPurchase Order Item`.received_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc", + "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n\t`tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Order Item`.received_qty as \"Received Qty:Float:100\", \n\t(`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.received_qty, 0)) as \"Qty to Receive:Float:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.received_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc", "ref_doctype": "Purchase Receipt", "report_name": "Purchase Order Items To Be Received", "report_type": "Query Report" diff --git a/stock/report/requested_items_to_be_transferred/__init__.py b/stock/report/requested_items_to_be_transferred/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt b/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt new file mode 100644 index 0000000000..030ed242d8 --- /dev/null +++ b/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt @@ -0,0 +1,23 @@ +[ + { + "creation": "2013-05-13 16:23:05", + "docstatus": 0, + "modified": "2013-05-13 16:25:08", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.ordered_qty as \"Transferred Qty:Float:100\", \n\t(mr_item.qty - ifnull(mr_item.ordered_qty, 0)) as \"Qty to Transfer:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Transfer\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand ifnull(mr_item.ordered_qty, 0) < ifnull(mr_item.qty, 0)\norder by mr.transaction_date asc", + "ref_doctype": "Stock Entry", + "report_name": "Requested Items To Be Transferred", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Requested Items To Be Transferred" + } +] \ No newline at end of file diff --git a/stock/stock_ledger.py b/stock/stock_ledger.py index 2480263c1f..10e490c8e0 100644 --- a/stock/stock_ledger.py +++ b/stock/stock_ledger.py @@ -35,6 +35,9 @@ def update_entries_after(args, verbose=1): "posting_time": "12:00" } """ + global _exceptions + _exceptions = [] + previous_sle = get_sle_before_datetime(args) qty_after_transaction = flt(previous_sle.get("qty_after_transaction")) diff --git a/stock/utils.py b/stock/utils.py index a2541dc69e..5e7e53bb01 100644 --- a/stock/utils.py +++ b/stock/utils.py @@ -17,7 +17,7 @@ import webnotes from webnotes import msgprint, _ import json -from webnotes.utils import flt, cstr +from webnotes.utils import flt, cstr, nowdate, add_days, cint from webnotes.defaults import get_global_default def validate_end_of_life(item_code, end_of_life=None, verbose=1): @@ -194,4 +194,117 @@ def _get_buying_amount(voucher_type, voucher_no, item_row, item_code, warehouse, buying_amount = previous_stock_value - flt(sle.stock_value) return buying_amount - return 0.0 \ No newline at end of file + return 0.0 + + +def reorder_item(): + """ Reorder item if stock reaches reorder level""" + if not hasattr(webnotes, "auto_indent"): + webnotes.auto_indent = webnotes.conn.get_value('Global Defaults', None, 'auto_indent') + + if webnotes.auto_indent: + material_requests = {} + bin_list = webnotes.conn.sql("""select item_code, warehouse, projected_qty + from tabBin where ifnull(item_code, '') != '' and ifnull(warehouse, '') != ''""", + as_dict=True) + for bin in bin_list: + #check if re-order is required + item_reorder = webnotes.conn.get("Item Reorder", + {"parent": bin.item_code, "warehouse": bin.warehouse}) + if item_reorder: + reorder_level = item_reorder.warehouse_reorder_level + reorder_qty = item_reorder.warehouse_reorder_qty + material_request_type = item_reorder.material_request_type or "Purchase" + else: + reorder_level, reorder_qty = webnotes.conn.get_value("Item", bin.item_code, + ["re_order_level", "re_order_qty"]) + material_request_type = "Purchase" + + if reorder_level and flt(bin.projected_qty) < flt(reorder_level): + if flt(reorder_level) - flt(bin.projected_qty) > flt(reorder_qty): + reorder_qty = flt(reorder_level) - flt(bin.projected_qty) + + company = webnotes.conn.get_value("Warehouse", bin.warehouse, "company") or \ + webnotes.defaults.get_defaults()["company"] or \ + webnotes.conn.sql("""select name from tabCompany limit 1""")[0][0] + + material_requests.setdefault(material_request_type, webnotes._dict()).setdefault( + company, []).append(webnotes._dict({ + "item_code": bin.item_code, + "warehouse": bin.warehouse, + "reorder_qty": reorder_qty + }) + ) + + create_material_request(material_requests) + +def create_material_request(material_requests): + """ Create indent on reaching reorder level """ + mr_list = [] + defaults = webnotes.defaults.get_defaults() + for request_type in material_requests: + for company in material_requests[request_type]: + items = material_requests[request_type][company] + if items: + mr = [{ + "doctype": "Material Request", + "company": company, + "fiscal_year": defaults.fiscal_year, + "transaction_date": nowdate(), + "material_request_type": request_type, + "remark": _("This is an auto generated Material Request.") + \ + _("""It was raised because the (actual + ordered + indented - reserved) + quantity reaches re-order level when the following record was created""") + }] + + for d in items: + item = webnotes.doc("Item", d.item_code) + mr.append({ + "doctype": "Material Request Item", + "parenttype": "Material Request", + "parentfield": "indent_details", + "item_code": d.item_code, + "schedule_date": add_days(nowdate(),cint(item.lead_time_days)), + "uom": item.stock_uom, + "warehouse": d.warehouse, + "item_name": item.item_name, + "description": item.description, + "item_group": item.item_group, + "qty": d.reorder_qty, + "brand": item.brand, + }) + + mr_bean = webnotes.bean(mr) + mr_bean.insert() + mr_bean.submit() + mr_list.append(mr_bean) + + if mr_list: + if not hasattr(webnotes, "reorder_email_notify"): + webnotes.reorder_email_notify = webnotes.conn.get_value('Global Defaults', None, + 'reorder_email_notify') + + if(webnotes.reorder_email_notify): + send_email_notification(mr_list) + +def send_email_notification(mr_list): + """ Notify user about auto creation of indent""" + + from webnotes.utils.email_lib import sendmail + email_list = webnotes.conn.sql_list("""select distinct r.parent + from tabUserRole r, tabProfile p + where p.name = r.parent and p.enabled = 1 and p.docstatus < 2 + and r.role in ('Purchase Manager','Material Manager') + and p.name not in ('Administrator', 'All', 'Guest')""") + + msg="""

Following Material Requests has been raised automatically \ + based on item reorder level:

""" + for mr in mr_list: + msg += "

" + mr.doc.name + """

+ """ + for item in mr.doclist.get({"parentfield": "indent_details"}): + msg += "" + msg += "
Item CodeWarehouseQtyUOM
" + item.item_code + "" + item.warehouse + "" + \ + cstr(item.qty) + "" + cstr(item.uom) + "
" + + sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg) \ No newline at end of file diff --git a/support/doctype/support_ticket/get_support_mails.py b/support/doctype/support_ticket/get_support_mails.py index d1fe0dc8da..82ae9a34b6 100644 --- a/support/doctype/support_ticket/get_support_mails.py +++ b/support/doctype/support_ticket/get_support_mails.py @@ -50,7 +50,7 @@ class SupportMailbox(POP3Mailbox): "subject": mail.mail["Subject"], "raised_by": mail.from_email, "content_type": mail.content_type, - "status": "Open" + "status": "Open", }]) ticket.insert() new_ticket = True @@ -58,7 +58,7 @@ class SupportMailbox(POP3Mailbox): mail.save_attachments_in_doc(ticket.doc) make(content=mail.content, sender=mail.from_email, subject = ticket.doc.subject, - doctype="Support Ticket", name=ticket.doc.name, + doctype="Support Ticket", name=ticket.doc.name, lead = ticket.doc.lead, contact=ticket.doc.contact, date=mail.date) if new_ticket and cint(self.email_settings.send_autoreply) and \ diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py index 8a705f41c7..63548d3436 100644 --- a/support/doctype/support_ticket/support_ticket.py +++ b/support/doctype/support_ticket/support_ticket.py @@ -18,7 +18,6 @@ from __future__ import unicode_literals import webnotes from utilities.transaction_base import TransactionBase -from home import update_feed from webnotes.utils import now class DocType(TransactionBase): @@ -44,6 +43,7 @@ class DocType(TransactionBase): def validate(self): self.update_status() + self.set_lead_contact(self.doc.raised_by) if self.doc.status == "Closed": from webnotes.widgets.form.assign_to import clear @@ -51,10 +51,20 @@ class DocType(TransactionBase): def on_communication_sent(self, comm): webnotes.conn.set(self.doc, 'status', 'Waiting for Customer') - if comm.lead and not self.doc.lead: - webnotes.conn.set(self.doc, 'lead', comm.lead) - if comm.contact and not self.doc.contact: - webnotes.conn.set(self.doc, 'contact', comm.contact) + + + def set_lead_contact(self, email_id): + import email.utils + email_id = email.utils.parseaddr(email_id) + if email_id: + if not self.doc.lead: + self.doc.lead = webnotes.conn.get_value("Lead", {"email_id": email_id}) + if not self.doc.contact: + self.doc.contact = webnotes.conn.get_value("Contact", {"email_id": email_id}) + + if not self.doc.company: + self.doc.company = webnotes.conn.get_value("Lead", self.doc.lead, "company") or \ + webnotes.conn.get_default("company") def on_trash(self): webnotes.conn.sql("""update `tabCommunication` set support_ticket=NULL @@ -86,7 +96,7 @@ def get_tickets(): webnotes.session.user, as_dict=1) return tickets -def get_website_args(): +def get_website_args(): bean = webnotes.bean("Support Ticket", webnotes.form_dict.name) if bean.doc.raised_by != webnotes.session.user: return { diff --git a/support/doctype/support_ticket/support_ticket.txt b/support/doctype/support_ticket/support_ticket.txt index 769bb9d701..50e547ece7 100644 --- a/support/doctype/support_ticket/support_ticket.txt +++ b/support/doctype/support_ticket/support_ticket.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-01-31 22:22:27", + "creation": "2013-02-01 10:36:25", "docstatus": 0, - "modified": "2013-01-31 22:17:24", + "modified": "2013-05-21 16:27:46", "modified_by": "Administrator", "owner": "Administrator" }, @@ -23,13 +23,18 @@ "permlevel": 0 }, { + "amend": 0, + "create": 1, "doctype": "DocPerm", "name": "__common__", "parent": "Support Ticket", "parentfield": "permissions", "parenttype": "DocType", + "permlevel": 0, "read": 1, - "submit": 0 + "report": 1, + "submit": 0, + "write": 1 }, { "doctype": "DocType", @@ -191,6 +196,15 @@ "oldfieldtype": "Time", "read_only": 1 }, + { + "doctype": "DocField", + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "print_hide": 1, + "reqd": 0 + }, { "depends_on": "eval:!doc.__islocal", "doctype": "DocField", @@ -237,51 +251,18 @@ "label": "Content Type" }, { - "amend": 0, "cancel": 0, - "create": 1, "doctype": "DocPerm", - "permlevel": 0, - "report": 1, - "role": "Guest", - "write": 1 + "role": "Guest" }, { - "create": 1, + "cancel": 0, "doctype": "DocPerm", - "match": "customer", - "permlevel": 0, - "report": 1, - "role": "Customer", - "write": 1 + "role": "Customer" }, { "cancel": 1, - "create": 1, "doctype": "DocPerm", - "permlevel": 0, - "report": 1, - "role": "Support Team", - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "match": "", - "permlevel": 1, - "report": 1, - "role": "Support Team", - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "match": "", - "permlevel": 2, "role": "Support Team" } ] \ No newline at end of file diff --git a/utilities/doctype/address/address.py b/utilities/doctype/address/address.py index 243bbdd7e3..cfcbea582f 100644 --- a/utilities/doctype/address/address.py +++ b/utilities/doctype/address/address.py @@ -18,6 +18,7 @@ from __future__ import unicode_literals import webnotes from webnotes import msgprint +from webnotes.utils import cstr class DocType: def __init__(self, doc, doclist=[]): @@ -29,7 +30,7 @@ class DocType: self.doc.address_title = self.doc.customer or self.doc.supplier or self.doc.sales_partner if self.doc.address_title: - self.doc.name = self.doc.address_title + "-" + self.doc.address_type + self.doc.name = cstr(self.doc.address_title).strip() + "-" + cstr(self.doc.address_type).strip() else: webnotes.msgprint("""Address Title is mandatory.""", raise_exception=True) diff --git a/utilities/doctype/contact/contact.py b/utilities/doctype/contact/contact.py index bceee7d6a1..a19501f100 100644 --- a/utilities/doctype/contact/contact.py +++ b/utilities/doctype/contact/contact.py @@ -16,7 +16,7 @@ from __future__ import unicode_literals import webnotes - +from webnotes.utils import cstr from utilities.transaction_base import TransactionBase @@ -32,15 +32,16 @@ class DocType(TransactionBase): webnotes.conn.set(self.doc, 'status', 'Replied') def autoname(self): - if self.doc.customer: - self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.customer - elif self.doc.supplier: - self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.supplier - elif self.doc.sales_partner: - self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.sales_partner - else: - self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') - + # concat first and last name + self.doc.name = " ".join(filter(None, + [cstr(self.doc.fields.get(f)).strip() for f in ["first_name", "last_name"]])) + + # concat party name if reqd + for fieldname in ("customer", "supplier", "sales_partner"): + if self.doc.fields.get(fieldname): + self.doc.name = self.doc.name + "-" + cstr(self.doc.fields.get(fieldname)).strip() + break + def validate(self): self.validate_primary_contact() diff --git a/website/doctype/blog_post/blog_post.py b/website/doctype/blog_post/blog_post.py index 05236a1ca2..62cc910860 100644 --- a/website/doctype/blog_post/blog_post.py +++ b/website/doctype/blog_post/blog_post.py @@ -76,10 +76,12 @@ class DocType: self.doc.full_name = get_fullname(self.doc.owner) self.doc.updated = global_date_format(self.doc.published_on) self.doc.content_html = self.doc.content + if self.doc.blogger: self.doc.blogger_info = webnotes.doc("Blogger", self.doc.blogger).fields self.doc.description = self.doc.blog_intro or self.doc.content[:140] + self.doc.meta_description = self.doc.description self.doc.categories = webnotes.conn.sql_list("select name from `tabBlog Category` order by name") diff --git a/website/doctype/web_page/web_page.py b/website/doctype/web_page/web_page.py index d43bcb4e3d..6d0cafaf6a 100644 --- a/website/doctype/web_page/web_page.py +++ b/website/doctype/web_page/web_page.py @@ -44,3 +44,5 @@ class DocType(): if self.doc.slideshow: from website.helpers.slideshow import get_slideshow get_slideshow(self) + + self.doc.meta_description = self.doc.description diff --git a/website/doctype/website_slideshow/website_slideshow.py b/website/doctype/website_slideshow/website_slideshow.py index 928aa9ff9f..86bd2a0433 100644 --- a/website/doctype/website_slideshow/website_slideshow.py +++ b/website/doctype/website_slideshow/website_slideshow.py @@ -5,4 +5,9 @@ import webnotes class DocType: def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file + self.doc, self.doclist = d, dl + + def on_update(self): + # a slide show can be in use and any change in it should get reflected + from webnotes.webutils import clear_cache + clear_cache() \ No newline at end of file diff --git a/website/helpers/blog_feed.py b/website/helpers/blog_feed.py index 41c203e0ad..c79c5cc3bb 100644 --- a/website/helpers/blog_feed.py +++ b/website/helpers/blog_feed.py @@ -49,9 +49,10 @@ rss_item = u""" def generate(): """generate rss feed""" - import webnotes, os + import os, urllib + import webnotes from webnotes.model.doc import Document - from website.helpers.blog import get_blog_content + from webnotes.utils import escape_html host = (os.environ.get('HTTPS') and 'https://' or 'http://') + os.environ.get('HTTP_HOST') @@ -62,7 +63,8 @@ def generate(): order by published_on desc limit 20""", as_dict=1) for blog in blog_list: - blog.link = host + '/' + blog.name + '.html' + blog.link = urllib.quote(host + '/' + blog.name + '.html') + blog.content = escape_html(blog.content or "") items += rss_item % blog diff --git a/website/helpers/product.py b/website/helpers/product.py index d6f16fb753..a107d9b02b 100644 --- a/website/helpers/product.py +++ b/website/helpers/product.py @@ -4,10 +4,9 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cstr +from webnotes.utils import cstr, cint from webnotes.webutils import build_html, delete_page_cache - @webnotes.whitelist(allow_guest=True) def get_product_info(item_code): """get product price / stock info""" @@ -20,10 +19,20 @@ def get_product_info(item_code): in_stock = in_stock[0][0] > 0 and 1 or 0 else: in_stock = -1 + + price = price_list and webnotes.conn.sql("""select ref_rate, ref_currency from + `tabItem Price` where parent=%s and price_list_name=%s""", + (item_code, price_list), as_dict=1) or [] + + price = price and price[0] or None + + if price: + price["ref_currency"] = not cint(webnotes.conn.get_default("hide_currency_symbol")) \ + and (webnotes.conn.get_value("Currency", price.ref_currency, "symbol") or price.ref_currency) \ + or "" + return { - "price": price_list and webnotes.conn.sql("""select ref_rate, ref_currency from - `tabItem Price` where parent=%s and price_list_name=%s""", - (item_code, price_list), as_dict=1) or [], + "price": price, "stock": in_stock } diff --git a/website/helpers/sitemap.py b/website/helpers/sitemap.py index c8b6fd0a53..3956da1a70 100644 --- a/website/helpers/sitemap.py +++ b/website/helpers/sitemap.py @@ -2,6 +2,7 @@ # License: GNU General Public License (v3). For more information see license.txt from __future__ import unicode_literals + frame_xml = """ %s """ @@ -32,10 +33,11 @@ def generate(domain): for p in pages: if count >= max_items: break - page_url = os.path.join(domain, urllib.quote(p[0])) - modified = p[1].strftime('%Y-%m-%d') - site_map += link_xml % (page_url, modified) - count += 1 + if p[0]: + page_url = os.path.join(domain, urllib.quote(p[0])) + modified = p[1].strftime('%Y-%m-%d') + site_map += link_xml % (page_url, modified) + count += 1 if count >= max_items: break diff --git a/website/templates/css/product_page.css b/website/templates/css/product_page.css index 566b6b57aa..71be9ee56b 100644 --- a/website/templates/css/product_page.css +++ b/website/templates/css/product_page.css @@ -7,4 +7,7 @@ font-size: 18px; line-height: 200%; } + .item-price { + margin-top: 20px; + } \ No newline at end of file diff --git a/website/templates/html/product_group.html b/website/templates/html/product_group.html index 042eb3397b..d11e1b0c5e 100644 --- a/website/templates/html/product_group.html +++ b/website/templates/html/product_group.html @@ -12,6 +12,10 @@ {% else %}

{{ name }}

{% endif %} + +{% include 'app/website/templates/html/product_search_box.html' %} +{% include 'app/website/templates/html/product_breadcrumbs.html' %} +
{% if sub_groups %}
diff --git a/website/templates/html/product_page.html b/website/templates/html/product_page.html index abca195bbe..1911af9d0f 100644 --- a/website/templates/html/product_page.html +++ b/website/templates/html/product_page.html @@ -35,23 +35,25 @@ {{ web_long_description or web_short_description or "[No description given]" }}
- {% if obj.doclist.get({"doctype":"Item Website Specification"}) %} +
+
+
+ + {% if obj.doclist.get({"doctype":"Item Website Specification"}) -%} +
+

Specifications

{% for d in obj.doclist.get( - {"doctype":"Item Website Specification"}) %} + {"doctype":"Item Website Specification"}) -%} - {% endfor %} + {%- endfor %}
{{ d.label }} {{ d.description }}
- {% endif %} -
-

Price:

-
-
+ {%- endif %} {% endblock %} \ No newline at end of file diff --git a/website/templates/html/slideshow.html b/website/templates/html/slideshow.html index e0e9038d9f..b26338c5e5 100644 --- a/website/templates/html/slideshow.html +++ b/website/templates/html/slideshow.html @@ -8,7 +8,7 @@ {% if slide.heading or slide.description %} {% endif %} diff --git a/website/templates/js/product_page.js b/website/templates/js/product_page.js index 653cfa3239..69e9cd52fe 100644 --- a/website/templates/js/product_page.js +++ b/website/templates/js/product_page.js @@ -26,8 +26,8 @@ $(document).ready(function() { success: function(data) { if(data.message) { if(data.message.price) { - $("

").html(data.message.price[0].ref_currency + " " - + data.message.price[0].ref_rate).appendTo(".item-price"); + $("

").html(data.message.price.ref_currency + " " + + data.message.price.ref_rate).appendTo(".item-price"); $(".item-price").toggle(true); } if(data.message.stock==0) {