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 = ["
').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
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="""" + mr.doc.name + """
Item Code | Warehouse | Qty | UOM |
---|---|---|---|
" + item.item_code + " | " + item.warehouse + " | " + \ + cstr(item.qty) + " | " + cstr(item.uom) + " |
{{ d.label }} | {{ d.description }} |