[merge] merge with master

This commit is contained in:
Rushabh Mehta 2013-05-24 16:09:13 +05:30
commit 126f2c62f2
120 changed files with 1431 additions and 712 deletions

View File

@ -187,7 +187,7 @@ class DocType:
sql("""delete from `tabGL Entry` where account = %s and sql("""delete from `tabGL Entry` where account = %s and
ifnull(is_cancelled, 'No') = 'Yes'""", self.doc.name) 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") company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
parts = new.split(" - ") parts = new.split(" - ")

View File

@ -17,16 +17,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils import flt, getdate from webnotes.utils import flt, getdate
from webnotes.model.doc import make_autoname
from webnotes.model.bean import getlist from webnotes.model.bean import getlist
class DocType: class DocType:
def __init__(self,d,dl): def __init__(self,d,dl):
self.doc, self.doclist = d,dl self.doc, self.doclist = d,dl
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series + '.#####')
def validate(self): def validate(self):
"""Validate invoice that c-form is applicable """Validate invoice that c-form is applicable
and no other c-form is received for that""" and no other c-form is received for that"""

View File

@ -29,7 +29,7 @@ class DocType(DocTypeNestedSet):
def autoname(self): def autoname(self):
company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s", company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s",
self.doc.company_name)[0][0] 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): def validate_mandatory(self):
if not self.doc.group_or_ledger: if not self.doc.group_or_ledger:
@ -87,7 +87,7 @@ class DocType(DocTypeNestedSet):
self.validate_mandatory() self.validate_mandatory()
self.validate_budget_details() 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") company_abbr = webnotes.conn.get_value("Company", self.doc.company_name, "abbr")
parts = new.split(" - ") parts = new.split(" - ")

View File

@ -34,11 +34,6 @@ class DocType(AccountsController):
self.credit_days_global = -1 self.credit_days_global = -1
self.is_approving_authority = -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): def validate(self):
if not self.doc.is_opening: if not self.doc.is_opening:
self.doc.is_opening='No' self.doc.is_opening='No'

View File

@ -122,119 +122,4 @@ test_records = [
"parentfield": "entries", "parentfield": "entries",
"cost_center": "_Test Cost Center - _TC" "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)

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-04-30 12:58:25", "creation": "2013-05-09 13:16:11",
"docstatus": 0, "docstatus": 0,
"modified": "2013-05-03 14:36:24", "modified": "2013-05-23 12:52:09",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -213,6 +213,14 @@
"options": "link:Print Heading" "options": "link:Print Heading"
}, },
{ {
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "System Manager",
"write": 1
},
{
"cancel": 1,
"create": 1, "create": 1,
"doctype": "DocPerm", "doctype": "DocPerm",
"role": "Accounts Manager", "role": "Accounts Manager",

View File

@ -464,15 +464,17 @@ class DocType(BuyingController):
# if auto inventory accounting enabled and stock item, # if auto inventory accounting enabled and stock item,
# then do stock related gl entries # then do stock related gl entries
# expense will be booked in sales invoice # expense will be booked in sales invoice
stock_item_and_auto_inventory_accounting = True 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( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
"account": stock_account, "account": stock_account,
"against": self.doc.credit_to, "against": self.doc.credit_to,
"debit": flt(item.valuation_rate) * flt(item.conversion_factor) \ "debit": valuation_amt,
* flt(item.qty),
"remarks": self.doc.remarks or "Accounting Entry for Stock" "remarks": self.doc.remarks or "Accounting Entry for Stock"
}) })
) )

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-04-09 10:18:10", "creation": "2013-05-07 13:50:30",
"docstatus": 0, "docstatus": 0,
"modified": "2013-03-22 18:17:14", "modified": "2013-05-13 11:12:56",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -30,7 +30,9 @@
"parent": "Purchase Invoice", "parent": "Purchase Invoice",
"parentfield": "permissions", "parentfield": "permissions",
"parenttype": "DocType", "parenttype": "DocType",
"read": 1 "permlevel": 0,
"read": 1,
"report": 1
}, },
{ {
"doctype": "DocType", "doctype": "DocType",
@ -41,6 +43,7 @@
"fieldname": "column_break0", "fieldname": "column_break0",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"oldfieldtype": "Column Break", "oldfieldtype": "Column Break",
"read_only": 0,
"width": "50%" "width": "50%"
}, },
{ {
@ -54,6 +57,7 @@
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "BILL\nBILLJ", "options": "BILL\nBILLJ",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1 "reqd": 1
}, },
@ -68,6 +72,7 @@
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Account", "options": "Account",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1 "search_index": 1
}, },
@ -80,7 +85,8 @@
"oldfieldname": "supplier", "oldfieldname": "supplier",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Supplier", "options": "Supplier",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -131,6 +137,7 @@
"fieldname": "column_break1", "fieldname": "column_break1",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"oldfieldtype": "Column Break", "oldfieldtype": "Column Break",
"read_only": 0,
"reqd": 0, "reqd": 0,
"width": "50%" "width": "50%"
}, },
@ -146,6 +153,7 @@
"oldfieldname": "posting_date", "oldfieldname": "posting_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1 "search_index": 1
}, },
@ -159,6 +167,7 @@
"oldfieldname": "bill_no", "oldfieldname": "bill_no",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1 "search_index": 1
}, },
@ -171,6 +180,7 @@
"oldfieldname": "bill_date", "oldfieldname": "bill_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"reqd": 0, "reqd": 0,
"search_index": 1 "search_index": 1
}, },
@ -179,7 +189,8 @@
"fieldname": "items", "fieldname": "items",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Items", "label": "Items",
"oldfieldtype": "Section Break" "oldfieldtype": "Section Break",
"read_only": 0
}, },
{ {
"allow_on_submit": 1, "allow_on_submit": 1,
@ -189,25 +200,29 @@
"label": "Entries", "label": "Entries",
"oldfieldname": "entries", "oldfieldname": "entries",
"oldfieldtype": "Table", "oldfieldtype": "Table",
"options": "Purchase Invoice Item" "options": "Purchase Invoice Item",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "section_break0", "fieldname": "section_break0",
"fieldtype": "Section Break" "fieldtype": "Section Break",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "recalculate", "fieldname": "recalculate",
"fieldtype": "Button", "fieldtype": "Button",
"label": "Recalculate", "label": "Recalculate",
"oldfieldtype": "Button" "oldfieldtype": "Button",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "section_break_17", "fieldname": "section_break_17",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"options": "Simple" "options": "Simple",
"read_only": 0
}, },
{ {
"description": "Select Items from Purchase Order", "description": "Select Items from Purchase Order",
@ -218,7 +233,8 @@
"oldfieldname": "purchase_order_main", "oldfieldname": "purchase_order_main",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Purchase Order", "options": "Purchase Order",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"description": "Select Items from Purchase Receipt", "description": "Select Items from Purchase Receipt",
@ -229,7 +245,8 @@
"oldfieldname": "purchase_receipt_main", "oldfieldname": "purchase_receipt_main",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Purchase Receipt", "options": "Purchase Receipt",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -237,13 +254,15 @@
"fieldtype": "Button", "fieldtype": "Button",
"label": "Get Items", "label": "Get Items",
"oldfieldtype": "Button", "oldfieldtype": "Button",
"options": "pull_details" "options": "pull_details",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "currency_price_list", "fieldname": "currency_price_list",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Currency & Price List" "label": "Currency & Price List",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -253,7 +272,8 @@
"oldfieldname": "currency", "oldfieldname": "currency",
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "Currency", "options": "Currency",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"default": "1", "default": "1",
@ -264,12 +284,14 @@
"label": "Exchange Rate", "label": "Exchange Rate",
"oldfieldname": "conversion_rate", "oldfieldname": "conversion_rate",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "column_break2", "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)", "description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
@ -278,7 +300,8 @@
"fieldtype": "Link", "fieldtype": "Link",
"label": "Price List", "label": "Price List",
"options": "Price List", "options": "Price List",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"depends_on": "price_list_name", "depends_on": "price_list_name",
@ -287,7 +310,8 @@
"fieldtype": "Link", "fieldtype": "Link",
"label": "Price List Currency", "label": "Price List Currency",
"options": "Currency", "options": "Currency",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"depends_on": "price_list_name", "depends_on": "price_list_name",
@ -295,7 +319,8 @@
"fieldname": "plc_conversion_rate", "fieldname": "plc_conversion_rate",
"fieldtype": "Float", "fieldtype": "Float",
"label": "Price List Exchange Rate", "label": "Price List Exchange Rate",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"description": "Add / Edit Taxes and Charges", "description": "Add / Edit Taxes and Charges",
@ -303,7 +328,8 @@
"fieldname": "taxes", "fieldname": "taxes",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Taxes", "label": "Taxes",
"oldfieldtype": "Section Break" "oldfieldtype": "Section Break",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -313,7 +339,8 @@
"oldfieldname": "purchase_other_charges", "oldfieldname": "purchase_other_charges",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Purchase Taxes and Charges Master", "options": "Purchase Taxes and Charges Master",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -322,7 +349,8 @@
"label": "Get Tax Detail", "label": "Get Tax Detail",
"oldfieldtype": "Button", "oldfieldtype": "Button",
"options": "get_purchase_tax_details", "options": "get_purchase_tax_details",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -331,7 +359,8 @@
"label": "Purchase Taxes and Charges", "label": "Purchase Taxes and Charges",
"oldfieldname": "purchase_tax_details", "oldfieldname": "purchase_tax_details",
"oldfieldtype": "Table", "oldfieldtype": "Table",
"options": "Purchase Taxes and Charges" "options": "Purchase Taxes and Charges",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -339,7 +368,8 @@
"fieldtype": "Button", "fieldtype": "Button",
"label": "Calculate Tax", "label": "Calculate Tax",
"oldfieldtype": "Button", "oldfieldtype": "Button",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -347,7 +377,8 @@
"fieldtype": "HTML", "fieldtype": "HTML",
"label": "Tax Calculation", "label": "Tax Calculation",
"oldfieldtype": "HTML", "oldfieldtype": "HTML",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -364,7 +395,8 @@
"doctype": "DocField", "doctype": "DocField",
"fieldname": "contact_section", "fieldname": "contact_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Contact Info" "label": "Contact Info",
"read_only": 0
}, },
{ {
"depends_on": "eval:doc.supplier", "depends_on": "eval:doc.supplier",
@ -372,12 +404,14 @@
"fieldname": "supplier_address", "fieldname": "supplier_address",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Supplier Address", "label": "Supplier Address",
"options": "Address" "options": "Address",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "col_break23", "fieldname": "col_break23",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"read_only": 0,
"width": "50%" "width": "50%"
}, },
{ {
@ -387,14 +421,16 @@
"fieldtype": "Link", "fieldtype": "Link",
"label": "Contact Person", "label": "Contact Person",
"options": "Contact", "options": "Contact",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "totals", "fieldname": "totals",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Totals", "label": "Totals",
"oldfieldtype": "Section Break" "oldfieldtype": "Section Break",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -497,6 +533,7 @@
"fieldtype": "Column Break", "fieldtype": "Column Break",
"oldfieldtype": "Column Break", "oldfieldtype": "Column Break",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"width": "50%" "width": "50%"
}, },
{ {
@ -562,7 +599,8 @@
"label": "Write Off Amount", "label": "Write Off Amount",
"no_copy": 1, "no_copy": 1,
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"depends_on": "eval:flt(doc.write_off_amount)!=0", "depends_on": "eval:flt(doc.write_off_amount)!=0",
@ -572,7 +610,8 @@
"label": "Write Off Account", "label": "Write Off Account",
"no_copy": 1, "no_copy": 1,
"options": "Account", "options": "Account",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"depends_on": "eval:flt(doc.write_off_amount)!=0", "depends_on": "eval:flt(doc.write_off_amount)!=0",
@ -581,8 +620,9 @@
"fieldtype": "Link", "fieldtype": "Link",
"label": "Write Off Cost Center", "label": "Write Off Cost Center",
"no_copy": 1, "no_copy": 1,
"options": "Account", "options": "Cost Center",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -594,6 +634,7 @@
"oldfieldname": "against_expense_account", "oldfieldname": "against_expense_account",
"oldfieldtype": "Small Text", "oldfieldtype": "Small Text",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"report_hide": 0 "report_hide": 0
}, },
{ {
@ -602,7 +643,8 @@
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Advances", "label": "Advances",
"oldfieldtype": "Section Break", "oldfieldtype": "Section Break",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -611,7 +653,8 @@
"label": "Get Advances Paid", "label": "Get Advances Paid",
"oldfieldtype": "Button", "oldfieldtype": "Button",
"options": "get_advances", "options": "get_advances",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -622,7 +665,8 @@
"oldfieldname": "advance_allocation_details", "oldfieldname": "advance_allocation_details",
"oldfieldtype": "Table", "oldfieldtype": "Table",
"options": "Purchase Invoice Advance", "options": "Purchase Invoice Advance",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -630,7 +674,8 @@
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "More Info", "label": "More Info",
"oldfieldtype": "Section Break", "oldfieldtype": "Section Break",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"default": "No", "default": "No",
@ -644,6 +689,7 @@
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "No\nYes", "options": "No\nYes",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"search_index": 1 "search_index": 1
}, },
{ {
@ -655,6 +701,7 @@
"oldfieldname": "aging_date", "oldfieldname": "aging_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"search_index": 0 "search_index": 0
}, },
{ {
@ -680,6 +727,7 @@
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Print Heading", "options": "Print Heading",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"report_hide": 1 "report_hide": 1
}, },
{ {
@ -692,6 +740,7 @@
"oldfieldname": "due_date", "oldfieldname": "due_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_hide": 0, "print_hide": 0,
"read_only": 0,
"search_index": 1 "search_index": 1
}, },
{ {
@ -701,12 +750,14 @@
"label": "Mode of Payment", "label": "Mode of Payment",
"oldfieldname": "mode_of_payment", "oldfieldname": "mode_of_payment",
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "link:Mode of Payment" "options": "link:Mode of Payment",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "column_break_63", "fieldname": "column_break_63",
"fieldtype": "Column Break" "fieldtype": "Column Break",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -718,6 +769,7 @@
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Company", "options": "Company",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"search_index": 1 "search_index": 1
}, },
{ {
@ -730,6 +782,7 @@
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "link:Fiscal Year", "options": "link:Fiscal Year",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"search_index": 1 "search_index": 1
}, },
{ {
@ -753,81 +806,53 @@
"oldfieldname": "remarks", "oldfieldname": "remarks",
"oldfieldtype": "Text", "oldfieldtype": "Text",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"reqd": 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, "amend": 1,
"cancel": 1, "cancel": 1,
"create": 1, "create": 1,
"doctype": "DocPerm", "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", "role": "Accounts User",
"submit": 1, "submit": 1,
"write": 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", "doctype": "DocPerm",
"match": "supplier", "match": "supplier",
"permlevel": 0, "role": "Supplier",
"report": 1, "submit": 0,
"role": "Supplier" "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
} }
] ]

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-04-10 08:35:38", "creation": "2013-04-19 11:00:07",
"docstatus": 0, "docstatus": 0,
"modified": "2013-04-17 14:05:20", "modified": "2013-05-22 12:01:56",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -224,6 +224,7 @@
"fieldtype": "Link", "fieldtype": "Link",
"in_filter": 1, "in_filter": 1,
"label": "Pur Order", "label": "Pur Order",
"no_copy": 1,
"oldfieldname": "purchase_order", "oldfieldname": "purchase_order",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Purchase Order", "options": "Purchase Order",
@ -238,6 +239,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "Purchase Order Item", "label": "Purchase Order Item",
"no_copy": 1,
"oldfieldname": "po_detail", "oldfieldname": "po_detail",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
@ -250,6 +252,7 @@
"fieldtype": "Link", "fieldtype": "Link",
"in_filter": 1, "in_filter": 1,
"label": "Pur Receipt", "label": "Pur Receipt",
"no_copy": 1,
"oldfieldname": "purchase_receipt", "oldfieldname": "purchase_receipt",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Purchase Receipt", "options": "Purchase Receipt",
@ -264,6 +267,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "PR Detail", "label": "PR Detail",
"no_copy": 1,
"oldfieldname": "pr_detail", "oldfieldname": "pr_detail",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,

View File

@ -30,7 +30,6 @@ from webnotes import _, msgprint
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12} month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
from controllers.selling_controller import SellingController from controllers.selling_controller import SellingController
class DocType(SellingController): class DocType(SellingController):
@ -40,9 +39,6 @@ class DocType(SellingController):
self.tname = 'Sales Invoice Item' self.tname = 'Sales Invoice Item'
self.fname = 'entries' self.fname = 'entries'
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
def validate(self): def validate(self):
super(DocType, self).validate() super(DocType, self).validate()
self.fetch_missing_values() self.fetch_missing_values()
@ -78,9 +74,11 @@ class DocType(SellingController):
self.set_aging_date() self.set_aging_date()
self.set_against_income_account() self.set_against_income_account()
self.validate_c_form() self.validate_c_form()
self.validate_rate_with_refdoc()
self.validate_time_logs_are_submitted() self.validate_time_logs_are_submitted()
self.validate_recurring_invoice() self.validate_recurring_invoice()
def on_submit(self): def on_submit(self):
if cint(self.doc.is_pos) == 1: if cint(self.doc.is_pos) == 1:
if cint(self.doc.update_stock) == 1: if cint(self.doc.update_stock) == 1:
@ -195,11 +193,11 @@ class DocType(SellingController):
self.doc.fields[fieldname] = pos.get(fieldname) self.doc.fields[fieldname] = pos.get(fieldname)
# set pos values in items # set pos values in items
for doc in self.doclist.get({"parentfield": "entries"}): for item in self.doclist.get({"parentfield": "entries"}):
if doc.fields.get('item_code'): if item.fields.get('item_code'):
for fieldname, val in self.apply_pos_settings(doc.fields).items(): for fieldname, val in self.apply_pos_settings(item.fields).items():
if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)): if (not for_validate) or (for_validate and not item.fields.get(fieldname)):
doc.fields[fieldname] = val item.fields[fieldname] = val
# fetch terms # fetch terms
if self.doc.tc_name and not self.doc.terms: if self.doc.tc_name and not self.doc.terms:
@ -217,8 +215,9 @@ class DocType(SellingController):
if self.doc.customer: if self.doc.customer:
acc_head = webnotes.conn.sql("""select name from `tabAccount` acc_head = webnotes.conn.sql("""select name from `tabAccount`
where (name = %s or (master_name = %s and master_type = 'customer')) where (name = %s or (master_name = %s and master_type = 'customer'))
and docstatus != 2""", and docstatus != 2 and company = %s""",
(cstr(self.doc.customer) + " - " + self.get_company_abbr(), self.doc.customer)) (cstr(self.doc.customer) + " - " + self.get_company_abbr(),
self.doc.customer, self.doc.company))
if acc_head and acc_head[0][0]: if acc_head and acc_head[0][0]:
return acc_head[0][0] return acc_head[0][0]
@ -555,6 +554,21 @@ class DocType(SellingController):
webnotes.conn.set(self.doc, 'c_form_no', '') 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): def update_current_stock(self):
for d in getlist(self.doclist, 'entries'): for d in getlist(self.doclist, 'entries'):

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-04-10 08:35:44", "creation": "2013-04-19 11:00:07",
"docstatus": 0, "docstatus": 0,
"modified": "2013-04-17 14:05:20", "modified": "2013-05-22 12:06:15",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -305,6 +305,7 @@
"fieldtype": "Link", "fieldtype": "Link",
"in_filter": 1, "in_filter": 1,
"label": "Sales Order", "label": "Sales Order",
"no_copy": 1,
"oldfieldname": "sales_order", "oldfieldname": "sales_order",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Sales Order", "options": "Sales Order",
@ -319,6 +320,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "SO Detail ", "label": "SO Detail ",
"no_copy": 1,
"oldfieldname": "so_detail", "oldfieldname": "so_detail",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
@ -331,6 +333,7 @@
"fieldtype": "Link", "fieldtype": "Link",
"in_filter": 1, "in_filter": 1,
"label": "Delivery Note", "label": "Delivery Note",
"no_copy": 1,
"oldfieldname": "delivery_note", "oldfieldname": "delivery_note",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Delivery Note", "options": "Delivery Note",
@ -345,6 +348,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "DN Detail", "label": "DN Detail",
"no_copy": 1,
"oldfieldname": "dn_detail", "oldfieldname": "dn_detail",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,

View File

@ -36,7 +36,7 @@ def execute(filters=None):
# invoice details # invoice details
sales_order = ", ".join(invoice_so_dn_map.get(inv.name, {}).get("sales_order", [])) 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", [])) 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, 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, account_map.get(inv.debit_to), customer_map.get(inv.customer), inv.project_name,
inv.remarks, sales_order, delivery_note] inv.remarks, sales_order, delivery_note]

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-02-22 01:27:42", "creation": "2013-03-07 11:42:55",
"docstatus": 0, "docstatus": 0,
"modified": "2013-03-07 07:03:27", "modified": "2013-05-22 11:59:52",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -36,6 +36,7 @@
"oldfieldname": "schedule_date", "oldfieldname": "schedule_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1 "search_index": 1
}, },
@ -49,6 +50,7 @@
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Item", "options": "Item",
"print_hide": 0, "print_hide": 0,
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1 "search_index": 1
}, },
@ -72,6 +74,7 @@
"oldfieldname": "item_name", "oldfieldname": "item_name",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1 "search_index": 1
}, },
@ -83,6 +86,7 @@
"oldfieldname": "description", "oldfieldname": "description",
"oldfieldtype": "Small Text", "oldfieldtype": "Small Text",
"print_width": "300px", "print_width": "300px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "300px" "width": "300px"
}, },
@ -95,6 +99,7 @@
"oldfieldname": "qty", "oldfieldname": "qty",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"print_width": "60px", "print_width": "60px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "60px" "width": "60px"
}, },
@ -108,6 +113,7 @@
"options": "UOM", "options": "UOM",
"print_hide": 0, "print_hide": 0,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "100px" "width": "100px"
}, },
@ -117,14 +123,16 @@
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Ref Rate ", "label": "Ref Rate ",
"options": "currency", "options": "currency",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "discount_rate", "fieldname": "discount_rate",
"fieldtype": "Float", "fieldtype": "Float",
"label": "Discount %", "label": "Discount %",
"print_hide": 0 "print_hide": 0,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -135,7 +143,8 @@
"oldfieldname": "import_rate", "oldfieldname": "import_rate",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "currency", "options": "currency",
"print_hide": 0 "print_hide": 0,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -153,7 +162,8 @@
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Ref Rate*", "label": "Ref Rate*",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"default": "0.00", "default": "0.00",
@ -166,6 +176,7 @@
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "100px" "width": "100px"
}, },
@ -192,6 +203,7 @@
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Warehouse", "options": "Warehouse",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"reqd": 0 "reqd": 0
}, },
{ {
@ -202,6 +214,7 @@
"label": "Project Name", "label": "Project Name",
"options": "Project", "options": "Project",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"report_hide": 0 "report_hide": 0
}, },
{ {
@ -214,6 +227,7 @@
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "100px" "width": "100px"
}, },
@ -237,7 +251,7 @@
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
"label": "Prevdoc DocType", "label": "Prevdoc DocType",
"no_copy": 0, "no_copy": 1,
"oldfieldname": "prevdoc_doctype", "oldfieldname": "prevdoc_doctype",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
@ -250,7 +264,7 @@
"hidden": 0, "hidden": 0,
"in_filter": 1, "in_filter": 1,
"label": "Material Request No", "label": "Material Request No",
"no_copy": 0, "no_copy": 1,
"oldfieldname": "prevdoc_docname", "oldfieldname": "prevdoc_docname",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Material Request", "options": "Material Request",
@ -267,6 +281,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "Material Request Date", "label": "Material Request Date",
"no_copy": 1,
"oldfieldname": "prevdoc_date", "oldfieldname": "prevdoc_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_hide": 1, "print_hide": 1,
@ -280,7 +295,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "Material Request Detail No", "label": "Material Request Detail No",
"no_copy": 0, "no_copy": 1,
"oldfieldname": "prevdoc_detail_docname", "oldfieldname": "prevdoc_detail_docname",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
@ -294,6 +309,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 0, "in_filter": 0,
"label": "Supplier Quotation", "label": "Supplier Quotation",
"no_copy": 1,
"options": "Supplier Quotation", "options": "Supplier Quotation",
"read_only": 1, "read_only": 1,
"search_index": 0 "search_index": 0
@ -304,6 +320,7 @@
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1, "hidden": 1,
"label": "Supplier Quotation Item", "label": "Supplier Quotation Item",
"no_copy": 1,
"options": "Supplier Quotation Item", "options": "Supplier Quotation Item",
"read_only": 1 "read_only": 1
}, },
@ -395,6 +412,7 @@
"no_copy": 1, "no_copy": 1,
"oldfieldname": "page_break", "oldfieldname": "page_break",
"oldfieldtype": "Check", "oldfieldtype": "Check",
"print_hide": 1 "print_hide": 1,
"read_only": 0
} }
] ]

View File

@ -17,28 +17,16 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.model import db_exists from webnotes.model.doc import addchild
from webnotes.model.doc import addchild, make_autoname
from webnotes.model.bean import copy_doclist
sql = webnotes.conn.sql
class DocType: class DocType:
def __init__(self, doc, doclist=[]): def __init__(self, doc, doclist=[]):
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist
# Autoname
# ---------
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
def get_item_specification_details(self): def get_item_specification_details(self):
self.doclist = self.doc.clear_table(self.doclist, 'qa_specification_details') 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)) where parent = '%s' order by idx" % (self.doc.item_code))
for d in specification: for d in specification:
child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', self.doclist) child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', self.doclist)
@ -48,13 +36,13 @@ class DocType:
def on_submit(self): def on_submit(self):
if self.doc.purchase_receipt_no: 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" \ 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)) % (self.doc.name, self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code))
def on_cancel(self): def on_cancel(self):
if self.doc.purchase_receipt_no: 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" \ 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)) % (self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code))

View File

@ -1,13 +1,13 @@
[ [
{ {
"creation": "2013-01-10 16:34:11", "creation": "2013-04-30 13:13:03",
"docstatus": 0, "docstatus": 0,
"modified": "2013-01-22 14:57:21", "modified": "2013-05-09 14:34:10",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
{ {
"autoname": "QAI/.######", "autoname": "naming_series:",
"doctype": "DocType", "doctype": "DocType",
"is_submittable": 1, "is_submittable": 1,
"module": "Buying", "module": "Buying",

View File

@ -168,7 +168,7 @@ class DocType(TransactionBase):
self.delete_supplier_communication() self.delete_supplier_communication()
self.delete_supplier_account() 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 #update supplier_name if not naming series
if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name': if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name':
update_fields = [ update_fields = [
@ -186,7 +186,7 @@ class DocType(TransactionBase):
for account in webnotes.conn.sql("""select name, account_name from for account in webnotes.conn.sql("""select name, account_name from
tabAccount where master_name=%s and master_type='Supplier'""", old, as_dict=1): tabAccount where master_name=%s and master_type='Supplier'""", old, as_dict=1):
if account.account_name != new: 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 #update master_name in doctype account
webnotes.conn.sql("""update `tabAccount` set master_name = %s, webnotes.conn.sql("""update `tabAccount` set master_name = %s,

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-02-22 01:27:43", "creation": "2013-03-07 11:42:56",
"docstatus": 0, "docstatus": 0,
"modified": "2013-03-07 07:03:32", "modified": "2013-05-22 12:02:28",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -35,6 +35,7 @@
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Item", "options": "Item",
"print_hide": 0, "print_hide": 0,
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1 "search_index": 1
}, },
@ -58,6 +59,7 @@
"oldfieldname": "item_name", "oldfieldname": "item_name",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1 "search_index": 1
}, },
@ -69,6 +71,7 @@
"oldfieldname": "description", "oldfieldname": "description",
"oldfieldtype": "Small Text", "oldfieldtype": "Small Text",
"print_width": "300px", "print_width": "300px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "300px" "width": "300px"
}, },
@ -81,6 +84,7 @@
"oldfieldname": "qty", "oldfieldname": "qty",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"print_width": "60px", "print_width": "60px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "60px" "width": "60px"
}, },
@ -94,6 +98,7 @@
"options": "UOM", "options": "UOM",
"print_hide": 0, "print_hide": 0,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "100px" "width": "100px"
}, },
@ -103,14 +108,16 @@
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Ref Rate ", "label": "Ref Rate ",
"options": "currency", "options": "currency",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "discount_rate", "fieldname": "discount_rate",
"fieldtype": "Float", "fieldtype": "Float",
"label": "Discount %", "label": "Discount %",
"print_hide": 0 "print_hide": 0,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -121,7 +128,8 @@
"oldfieldname": "import_rate", "oldfieldname": "import_rate",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "currency", "options": "currency",
"print_hide": 0 "print_hide": 0,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -139,7 +147,8 @@
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Ref Rate*", "label": "Ref Rate*",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"default": "0.00", "default": "0.00",
@ -152,6 +161,7 @@
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "100px" "width": "100px"
}, },
@ -178,6 +188,7 @@
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Warehouse", "options": "Warehouse",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"reqd": 0 "reqd": 0
}, },
{ {
@ -188,6 +199,7 @@
"label": "Project Name", "label": "Project Name",
"options": "Project", "options": "Project",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"report_hide": 0 "report_hide": 0
}, },
{ {
@ -196,7 +208,7 @@
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
"label": "Prevdoc DocType", "label": "Prevdoc DocType",
"no_copy": 0, "no_copy": 1,
"oldfieldname": "prevdoc_doctype", "oldfieldname": "prevdoc_doctype",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
@ -209,7 +221,7 @@
"hidden": 0, "hidden": 0,
"in_filter": 1, "in_filter": 1,
"label": "Material Request No", "label": "Material Request No",
"no_copy": 0, "no_copy": 1,
"oldfieldname": "prevdoc_docname", "oldfieldname": "prevdoc_docname",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Material Request", "options": "Material Request",
@ -226,6 +238,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "Material Request Date", "label": "Material Request Date",
"no_copy": 1,
"oldfieldname": "prevdoc_date", "oldfieldname": "prevdoc_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_hide": 1, "print_hide": 1,
@ -239,7 +252,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "Material Request Detail No", "label": "Material Request Detail No",
"no_copy": 0, "no_copy": 1,
"oldfieldname": "prevdoc_detail_docname", "oldfieldname": "prevdoc_detail_docname",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
@ -295,6 +308,7 @@
"no_copy": 1, "no_copy": 1,
"oldfieldname": "page_break", "oldfieldname": "page_break",
"oldfieldtype": "Check", "oldfieldtype": "Check",
"print_hide": 1 "print_hide": 1,
"read_only": 0
} }
] ]

View File

@ -111,6 +111,10 @@ wn.module_page["Buying"] = [
"label":wn._("Purchase In Transit"), "label":wn._("Purchase In Transit"),
route: "query-report/Purchase In Transit", route: "query-report/Purchase In Transit",
}, },
{
"label":wn._("Requested Items To Be Ordered"),
route: "query-report/Requested Items To Be Ordered",
},
] ]
} }
] ]

View File

@ -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"
}
]

View File

@ -115,7 +115,7 @@
"ticket": { "ticket": {
"no_cache": true, "no_cache": true,
"template": "app/website/templates/pages/ticket", "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": { "tickets": {
"template": "app/website/templates/pages/tickets" "template": "app/website/templates/pages/tickets"
@ -123,6 +123,10 @@
"writers": { "writers": {
"template": "app/website/templates/pages/writers", "template": "app/website/templates/pages/writers",
"args_method": "website.helpers.blog.get_writers_args" "args_method": "website.helpers.blog.get_writers_args"
},
"profile": {
"no_cache": true,
"template": "app/website/templates/pages/profile"
} }
}, },
"generators": { "generators": {

View File

@ -367,9 +367,13 @@ class BuyingController(StockController):
if d.item_code and d.qty: if d.item_code and d.qty:
# if no item code, which is sometimes the case in purchase invoice, # if no item code, which is sometimes the case in purchase invoice,
# then it is not possible to track valuation against it # then it is not possible to track valuation against it
d.valuation_rate = (flt(d.purchase_rate or d.rate) d.valuation_rate = flt(((flt(d.purchase_rate, self.precision.item.purchase_rate) or
+ (flt(d.item_tax_amount) + flt(d.rm_supp_cost)) / flt(d.qty) flt(d.rate, self.precision.item.rate)) +
) / flt(d.conversion_factor) (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: else:
d.valuation_rate = 0.0 d.valuation_rate = 0.0

View File

@ -1,4 +1,6 @@
erpnext.updates = [ 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", ["2nd May", ["Buying: Warehouse must belong to same company as transaction",
"Price List: Added Currency Field. One price list can have only one currency", "Price List: Added Currency Field. One price list can have only one currency",
"Item: Naming can now be by series or item code", "Item: Naming can now be by series or item code",

View File

@ -18,7 +18,6 @@ from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils import getdate, nowdate from webnotes.utils import getdate, nowdate
from webnotes.model.doc import make_autoname
from webnotes import msgprint, _ from webnotes import msgprint, _
sql = webnotes.conn.sql sql = webnotes.conn.sql
@ -28,9 +27,6 @@ class DocType:
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
def get_emp_name(self): def get_emp_name(self):
return { return {
"employee_name": webnotes.conn.get_value("Employee", "employee_name": webnotes.conn.get_value("Employee",

View File

@ -36,7 +36,7 @@ class DocType:
if ret[0][0]=='Naming Series': if ret[0][0]=='Naming Series':
self.doc.name = make_autoname(self.doc.naming_series + '.####') self.doc.name = make_autoname(self.doc.naming_series + '.####')
elif ret[0][0]=='Employee Number': 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 self.doc.employee = self.doc.name
@ -80,7 +80,7 @@ class DocType:
if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole
where parent=%s""", self.doc.user_id): where parent=%s""", self.doc.user_id):
from webnotes.profile import add_role 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) profile_wrapper = webnotes.bean("Profile", self.doc.user_id)

View File

@ -335,15 +335,22 @@ def add_holidays(events, start, end, employee, company):
def query_for_permitted_employees(doctype, txt, searchfield, start, page_len, filters): def query_for_permitted_employees(doctype, txt, searchfield, start, page_len, filters):
txt = "%" + cstr(txt) + "%" 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 where status = 'Active' and docstatus < 2 and
(`%s` like %s or employee_name like %s) and (`%s` like %s or employee_name like %s) %s
(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)
order by order by
case when name like %s then 0 else 1 end, case when name like %s then 0 else 1 end,
case when employee_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), name limit %s, %s""" % tuple([searchfield] + ["%s"]*2 + [condition] + ["%s"]*4),
(txt, txt, webnotes.session.user, webnotes.session.user, txt, txt, start, page_len)) (txt, txt, txt, txt, start, page_len))

View File

@ -75,7 +75,6 @@ erpnext.hr.AttendanceControlPanel = wn.ui.form.Controller.extend({
r.messages = ["<h4 style='color:green'>Import Successful!</h4>"]. r.messages = ["<h4 style='color:green'>Import Successful!</h4>"].
concat(r.messages) concat(r.messages)
} }
console.log(r.messages);
$.each(r.messages, function(i, v) { $.each(r.messages, function(i, v) {
var $p = $('<p>').html(v).appendTo($log_wrapper); var $p = $('<p>').html(v).appendTo($log_wrapper);

View File

@ -100,7 +100,6 @@ def get_naming_series():
def upload(): def upload():
from webnotes.utils.datautils import read_csv_content_from_uploaded_file from webnotes.utils.datautils import read_csv_content_from_uploaded_file
from webnotes.modules import scrub 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() rows = read_csv_content_from_uploaded_file()
if not rows: if not rows:
@ -112,6 +111,9 @@ def upload():
ret = [] ret = []
error = False error = False
from webnotes.utils.datautils import check_record, import_doc
doctype_dl = webnotes.get_doctype("Attendance")
for i, row in enumerate(rows[5:]): for i, row in enumerate(rows[5:]):
if not row: continue if not row: continue
row_idx = i + 5 row_idx = i + 5
@ -121,7 +123,7 @@ def upload():
d["docstatus"] = webnotes.conn.get_value("Attendance", d.name, "docstatus") d["docstatus"] = webnotes.conn.get_value("Attendance", d.name, "docstatus")
try: try:
check_record(d) check_record(d, doctype_dl=doctype_dl)
ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True)) ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
except Exception, e: except Exception, e:
error = True error = True

View File

@ -177,6 +177,14 @@ wn.module_page["HR"] = [
"label":wn._("Employee Information"), "label":wn._("Employee Information"),
route: "Report2/Employee/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"
},
] ]
} }
]; ];

View File

@ -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
}
]
}

View File

@ -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 <http://www.gnu.org/licenses/>.
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

View File

@ -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"
}
]

View File

@ -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
}
]
}

View File

@ -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 <http://www.gnu.org/licenses/>.
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

View File

@ -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"
}
]

View File

@ -34,7 +34,8 @@ class DocType:
last_name = sql("""select max(name) from `tabBOM` last_name = sql("""select max(name) from `tabBOM`
where name like "BOM/%s/%%" """ % cstr(self.doc.item).replace('"', '\\"')) where name like "BOM/%s/%%" """ % cstr(self.doc.item).replace('"', '\\"'))
if last_name: 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: else:
idx = 1 idx = 1
self.doc.name = 'BOM/' + self.doc.item + ('/%.3i' % idx) self.doc.name = 'BOM/' + self.doc.item + ('/%.3i' % idx)

View File

@ -18,9 +18,6 @@ from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils import cstr, flt, now, nowdate 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.model.code import get_obj
from webnotes import msgprint from webnotes import msgprint

View File

@ -9,10 +9,9 @@ def execute():
for doctype in webnotes.conn.sql_list("""select parent from tabDocField where for doctype in webnotes.conn.sql_list("""select parent from tabDocField where
fieldname='file_list'"""): fieldname='file_list'"""):
update_file_list(doctype, singles) # the other scenario is handled in p07_update_file_data_2
if doctype in singles:
webnotes.conn.sql("""delete from tabDocField where fieldname='file_list' update_file_list(doctype, singles)
and parent=%s""", doctype)
# export_to_files([["DocType", doctype]]) # export_to_files([["DocType", doctype]])

View File

@ -13,6 +13,4 @@ def execute():
webnotes.conn.sql("""delete from `tabCustom Field` where fieldname='file_list' webnotes.conn.sql("""delete from `tabCustom Field` where fieldname='file_list'
and parent=%s""", doctype) and parent=%s""", doctype)
webnotes.conn.sql("""delete from `tabDocField` where fieldname='file_list'
and parent=%s""", doctype)

View File

@ -31,5 +31,4 @@ def execute():
webnotes.conn.commit() webnotes.conn.commit()
webnotes.conn.begin() webnotes.conn.begin()
import webnotes.model.sync webnotes.reload_doc('core', 'doctype', 'profile')
webnotes.model.sync.sync('core', 'profile')

View File

@ -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()

View File

@ -1,4 +0,0 @@
from __future__ import unicode_literals
def execute():
from webnotes.modules import reload_doc
reload_doc("buying", "report", "supplier_quotations")

View File

@ -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_allow")
os.system("rm -rf app/hr/doctype/holiday_block_list_date") 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)

View File

@ -6,7 +6,6 @@ def execute():
where parent in ('Address', 'Contact')""") where parent in ('Address', 'Contact')""")
webnotes.conn.commit() webnotes.conn.commit()
import webnotes.model.sync webnotes.reload_doc('utilities', 'doctype', 'address')
webnotes.model.sync.sync('utilities', 'address') webnotes.reload_doc('utilities', 'doctype', 'contact')
webnotes.model.sync.sync('utilities', 'contact')
webnotes.conn.begin() webnotes.conn.begin()

View File

@ -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()

View File

@ -12,8 +12,6 @@ def execute():
and ifnull(t1.project_name, '') = ''""") and ifnull(t1.project_name, '') = ''""")
webnotes.conn.commit() webnotes.conn.commit()
from webnotes.model.sync import sync webnotes.reload_doc("buying", "doctype", "purchase_order")
sync("buying", "purchase_order") webnotes.reload_doc("accounts", "doctype", "purchase_invoice")
sync("buying", "purchase_request")
sync("accounts", "purchase_invoice")
webnotes.conn.begin() webnotes.conn.begin()

View File

@ -1,13 +1,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes
def execute(): def execute():
"""sync supplier quotatoin and create supplier quotation mappers""" """sync supplier quotatoin and create supplier quotation mappers"""
from webnotes.model.sync import sync webnotes.reload_doc('buying', 'doctype', 'supplier_quotation')
sync('buying', 'supplier_quotation') webnotes.reload_doc('buying', 'doctype', 'supplier_quotation_item')
sync('buying', 'supplier_quotation_item') webnotes.reload_doc('buying', 'doctype', 'purchase_order')
sync('buying', 'purchase_request') webnotes.reload_doc('buying', 'doctype', 'purchase_order_item')
sync('buying', 'purchase_request_item')
sync('buying', 'purchase_order')
sync('buying', 'purchase_order_item')
from webnotes.modules import reload_doc from webnotes.modules import reload_doc
reload_doc('buying', 'DocType Mapper', 'Material Request-Supplier Quotation') reload_doc('buying', 'DocType Mapper', 'Material Request-Supplier Quotation')

View File

@ -1,14 +1,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
def execute(): def execute():
import webnotes import webnotes
import webnotes.model.sync
# sync doctypes required for the patch # sync doctypes required for the patch
webnotes.model.sync.sync('website', 'web_cache') webnotes.reload_doc('website', 'doctype', 'web_page')
webnotes.model.sync.sync('website', 'web_page') webnotes.reload_doc('website', 'doctype', 'website_settings')
webnotes.model.sync.sync('website', 'blog') webnotes.reload_doc('stock', 'doctype', 'item')
webnotes.model.sync.sync('website', 'website_settings')
webnotes.model.sync.sync('stock', 'item')
cleanup() cleanup()

View File

@ -2,11 +2,9 @@ from __future__ import unicode_literals
def execute(): def execute():
import webnotes import webnotes
# perform sync webnotes.reload_doc('buying', 'doctype', 'purchase_order_item')
import webnotes.model.sync webnotes.reload_doc('accounts', 'doctype', 'purchase_invoice_item')
webnotes.model.sync.sync('buying', 'purchase_order_item') webnotes.reload_doc('stock', 'doctype', 'purchase_receipt_item')
webnotes.model.sync.sync('accounts', 'purchase_invoice_item')
webnotes.model.sync.sync('stock', '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 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") 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")

View File

@ -8,8 +8,7 @@ def execute():
webnotes.conn.commit() webnotes.conn.commit()
import webnotes.model.sync webnotes.reload_doc('core', 'doctype', 'search_criteria')
webnotes.model.sync.sync('core', 'search_criteria') webnotes.reload_doc('core', 'doctype', 'report')
webnotes.model.sync.sync('core', 'report')
webnotes.conn.begin() webnotes.conn.begin()

View File

@ -1,7 +1,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
def execute(): def execute():
import webnotes import webnotes
from webnotes.model.sync import sync webnotes.reload_doc('accounts', 'doctype', 'sales_invoice')
sync('accounts', 'sales_invoice')
webnotes.conn.sql("update `tabSales Invoice` set recurring_type = 'Monthly' where ifnull(convert_into_recurring_invoice, 0) = 1") webnotes.conn.sql("update `tabSales Invoice` set recurring_type = 'Monthly' where ifnull(convert_into_recurring_invoice, 0) = 1")

View File

@ -4,9 +4,8 @@ def execute():
import webnotes import webnotes
import webnotes.utils import webnotes.utils
import webnotes.model.sync
webnotes.conn.commit() webnotes.conn.commit()
webnotes.model.sync.sync('setup', 'email_settings') webnotes.reload_doc('setup', 'doctype', 'email_settings')
webnotes.conn.begin() webnotes.conn.begin()
sync_support_mails = webnotes.utils.cint(webnotes.conn.get_value('Email Settings', sync_support_mails = webnotes.utils.cint(webnotes.conn.get_value('Email Settings',

View File

@ -12,8 +12,7 @@ def execute():
clean_docfield_properties() clean_docfield_properties()
def change_property_setter_fieldnames(): def change_property_setter_fieldnames():
import webnotes.model.sync webnotes.reload_doc('core', 'doctype', 'property_setter')
webnotes.model.sync.sync('core', 'property_setter')
docfield_list = webnotes.conn.sql("""\ docfield_list = webnotes.conn.sql("""\
SELECT name, fieldname FROM `tabDocField`""", as_list=1) SELECT name, fieldname FROM `tabDocField`""", as_list=1)
custom_field_list = webnotes.conn.sql("""\ custom_field_list = webnotes.conn.sql("""\

View File

@ -94,8 +94,7 @@ from webnotes.model.code import get_obj
from webnotes.model.doc import Document from webnotes.model.doc import Document
def execute(): def execute():
import webnotes.model.sync webnotes.reload_doc('core', 'doctype', 'custom_field')
webnotes.model.sync.sync('core', 'custom_field')
for f in field_list: for f in field_list:
res = webnotes.conn.sql("""SELECT name FROM `tabCustom Field` res = webnotes.conn.sql("""SELECT name FROM `tabCustom Field`
WHERE dt=%s AND fieldname=%s""", (f[0], f[1])) WHERE dt=%s AND fieldname=%s""", (f[0], f[1]))

View File

@ -25,5 +25,4 @@ def execute():
webnotes.conn.commit() webnotes.conn.commit()
webnotes.conn.begin() webnotes.conn.begin()
import webnotes.model.sync webnotes.reload_doc('setup', 'doctype', 'notification_control')
webnotes.model.sync.sync('setup', 'notification_control')

View File

@ -27,5 +27,4 @@ def execute():
doc.save() doc.save()
webnotes.conn.commit() webnotes.conn.commit()
webnotes.conn.begin() webnotes.conn.begin()
import webnotes.model.sync webnotes.reload_doc('core', 'doctype', 'custom_script')
webnotes.model.sync.sync('core', 'custom_script')

View File

@ -19,5 +19,4 @@ def execute():
doc.save() doc.save()
webnotes.conn.commit() webnotes.conn.commit()
webnotes.conn.begin() webnotes.conn.begin()
import webnotes.model.sync webnotes.reload_doc('core', 'doctype', 'profile')
webnotes.model.sync.sync('core', 'profile')

View File

@ -1,8 +1,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
def execute(): def execute():
import webnotes import webnotes
import webnotes.model.sync webnotes.reload_doc('support', 'doctype', 'communication')
webnotes.model.sync.sync('support', 'communication')
webnotes.conn.commit() webnotes.conn.commit()
webnotes.conn.begin() webnotes.conn.begin()

View File

@ -27,5 +27,4 @@ def execute():
doc.save() doc.save()
webnotes.conn.commit() webnotes.conn.commit()
webnotes.conn.begin() webnotes.conn.begin()
import webnotes.model.sync webnotes.reload_doc('core', 'doctype', 'print_format')
webnotes.model.sync.sync('core', 'print_format')

View File

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/>.
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

View File

@ -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 <http://www.gnu.org/licenses/>.
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))

View File

@ -15,7 +15,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes
def execute(): def execute():
# reload gross profit report webnotes.reload_doc("Setup", "DocType", "Global Defaults")
from webnotes.modules import reload_doc
reload_doc('selling', 'search_criteria', 'gross_profit') if webnotes.conn.exists({"doctype": "Item", "email_notify": 1}):
webnotes.conn.set_value("Global Defaults", None, "reorder_email_notify", 1)

View File

@ -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 <http://www.gnu.org/licenses/>.
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)""")

View File

@ -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 <http://www.gnu.org/licenses/>.
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")

View File

@ -74,15 +74,12 @@ patch_list = [
"patches.july_2012.auth_table", "patches.july_2012.auth_table",
"patches.july_2012.remove_event_role_owner_match", "patches.july_2012.remove_event_role_owner_match",
"patches.july_2012.deprecate_bulk_rename", "patches.july_2012.deprecate_bulk_rename",
"patches.july_2012.blog_guest_permission",
"patches.july_2012.bin_permission", "patches.july_2012.bin_permission",
"patches.july_2012.project_patch_repeat", "patches.july_2012.project_patch_repeat",
"patches.july_2012.repost_stock_due_to_wrong_packing_list", "patches.july_2012.repost_stock_due_to_wrong_packing_list",
"patches.july_2012.supplier_quotation", "patches.july_2012.supplier_quotation",
"patches.august_2012.report_supplier_quotations",
"patches.august_2012.task_allocated_to_assigned", "patches.august_2012.task_allocated_to_assigned",
"patches.august_2012.change_profile_permission", "patches.august_2012.change_profile_permission",
"patches.august_2012.changed_blog_date_format",
"patches.august_2012.repost_billed_amt", "patches.august_2012.repost_billed_amt",
"patches.august_2012.remove_cash_flow_statement", "patches.august_2012.remove_cash_flow_statement",
"patches.september_2012.stock_report_permissions_for_accounts", "patches.september_2012.stock_report_permissions_for_accounts",
@ -93,7 +90,6 @@ patch_list = [
"patches.september_2012.plot_patch", "patches.september_2012.plot_patch",
"patches.september_2012.event_permission", "patches.september_2012.event_permission",
"patches.september_2012.repost_stock", "patches.september_2012.repost_stock",
"patches.september_2012.reload_gross_profit",
"patches.september_2012.rebuild_trees", "patches.september_2012.rebuild_trees",
"patches.september_2012.deprecate_account_balance", "patches.september_2012.deprecate_account_balance",
"patches.september_2012.profile_delete_permission", "patches.september_2012.profile_delete_permission",
@ -250,4 +246,10 @@ patch_list = [
"patches.april_2013.p07_update_file_data_2", "patches.april_2013.p07_update_file_data_2",
"patches.april_2013.rebuild_sales_browser", "patches.april_2013.rebuild_sales_browser",
"patches.april_2013.p08_price_list_country", "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",
] ]

View File

@ -1,5 +1,9 @@
$.extend(cur_frm.cscript, { wn.provide("erpnext.projects");
refresh: function(doc) {
erpnext.projects.TimeLog = wn.ui.form.Controller.extend({
setup: function() {
this.frm.set_query("task", erpnext.queries.task);
} }
}); });
cur_frm.cscript = new erpnext.projects.TimeLog({frm: cur_frm});

View File

@ -5,4 +5,25 @@ import webnotes
@webnotes.whitelist() @webnotes.whitelist()
def get_time_log_list(doctype, txt, searchfield, start, page_len, filters): def get_time_log_list(doctype, txt, searchfield, start, page_len, filters):
return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"]) 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))

View File

@ -40,7 +40,7 @@ $.extend(erpnext.complete_setup, {
{fieldname:'country', label: 'Country', reqd:1, {fieldname:'country', label: 'Country', reqd:1,
options: "", fieldtype: 'Select'}, options: "", fieldtype: 'Select'},
{fieldname:'currency', label: 'Default Currency', reqd:1, {fieldname:'currency', label: 'Default Currency', reqd:1,
options: "Currency", fieldtype: 'Link'}, options: "", fieldtype: 'Select'},
{fieldname:'timezone', label: 'Time Zone', reqd:1, {fieldname:'timezone', label: 'Time Zone', reqd:1,
options: "", fieldtype: 'Select'}, options: "", fieldtype: 'Select'},
{fieldname:'industry', label: 'Industry', reqd:1, {fieldname:'industry', label: 'Industry', reqd:1,
@ -55,11 +55,17 @@ $.extend(erpnext.complete_setup, {
} }
wn.call({ wn.call({
method:"webnotes.country_info.get_all", method:"webnotes.country_info.get_country_timezone_info",
callback: function(data) { 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() 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 country = d.fields_dict.country.input.value;
var $timezone = $(d.fields_dict.timezone.input); var $timezone = $(d.fields_dict.timezone.input);
$timezone.empty(); $timezone.empty();
// add country specific timezones first
if(country){ if(country){
var timezone_list = erpnext.country_info[country].timezones; var timezone_list = erpnext.country_info[country].timezones || [];
if(timezone_list.length==0) { $timezone.add_options(timezone_list.sort());
timezone_list = $.map(erpnext.country_info, function(m) {
return m.timezones
});
}
$timezone.empty().add_options(timezone_list);
console.log(d.get_input("currency"))
d.get_input("currency").val(erpnext.country_info[country].currency); 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', 'Finance', 'Food and Beverage', 'Government', 'Healthcare', 'Hospitality',
'Information Technology', 'Insurance', 'Machinery', 'Manufacturing', 'Media', 'Information Technology', 'Insurance', 'Machinery', 'Manufacturing', 'Media',
'Not For Profit', 'Recreation', 'Retail', 'Shipping', 'Technology', 'Not For Profit', 'Recreation', 'Retail', 'Shipping', 'Technology',
'Telecommunications', 'Transportation', 'Trading', 'Utilities', 'Other'], 'Telecommunications', 'Transportation', 'Trading', 'Utilities', 'Other'],
}); });

View File

@ -160,4 +160,8 @@ erpnext.queries.bom = function(opts) {
: "") : "")
+ " LIMIT 50" + " LIMIT 50"
} }
erpnext.queries.task = function() {
return { query: "projects.utils.query_task" };
};

View File

@ -216,7 +216,7 @@ class DocType(TransactionBase):
if self.doc.lead_name: if self.doc.lead_name:
sql("update `tabLead` set status='Interested' where name=%s",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 #update customer_name if not naming series
if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name': if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name':
update_fields = [ update_fields = [
@ -244,7 +244,7 @@ class DocType(TransactionBase):
for account in webnotes.conn.sql("""select name, account_name from for account in webnotes.conn.sql("""select name, account_name from
tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1): tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1):
if account.account_name != new: 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 #update master_name in doctype account
webnotes.conn.sql("""update `tabAccount` set master_name = %s, webnotes.conn.sql("""update `tabAccount` set master_name = %s,

View File

@ -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 = [ test_records = [
[{ [{
"doctype": "Customer", "doctype": "Customer",
@ -7,5 +63,13 @@ test_records = [
"customer_group": "_Test Customer Group", "customer_group": "_Test Customer Group",
"territory": "_Test Territory", "territory": "_Test Territory",
"company": "_Test Company" "company": "_Test Company"
}],
[{
"doctype": "Customer",
"customer_name": "_Test Customer 1",
"customer_type": "Individual",
"customer_group": "_Test Customer Group",
"territory": "_Test Territory",
"company": "_Test Company"
}] }]
] ]

View File

@ -18,9 +18,7 @@ from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils import cstr, getdate from webnotes.utils import cstr, getdate
from webnotes.model import db_exists from webnotes.model.bean import getlist
from webnotes.model.doc import make_autoname
from webnotes.model.bean import getlist, copy_doclist
from webnotes.model.code import get_obj from webnotes.model.code import get_obj
from webnotes import msgprint from webnotes import msgprint
from stock.utils import get_valid_serial_nos from stock.utils import get_valid_serial_nos
@ -37,9 +35,6 @@ class DocType(TransactionBase):
self.tname = 'Installation Note Item' self.tname = 'Installation Note Item'
self.fname = 'installed_item_details' self.fname = 'installed_item_details'
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
def validate(self): def validate(self):
self.validate_fiscal_year() self.validate_fiscal_year()
self.validate_installation_date() self.validate_installation_date()

View File

@ -1,13 +1,13 @@
[ [
{ {
"creation": "2013-01-10 16:34:18", "creation": "2013-04-30 13:13:06",
"docstatus": 0, "docstatus": 0,
"modified": "2013-01-22 14:56:02", "modified": "2013-05-09 14:43:28",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
{ {
"autoname": "IN/.####", "autoname": "naming_series:",
"doctype": "DocType", "doctype": "DocType",
"is_submittable": 1, "is_submittable": 1,
"module": "Selling", "module": "Selling",
@ -33,6 +33,7 @@
"permlevel": 0, "permlevel": 0,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Sales User",
"submit": 1, "submit": 1,
"write": 1 "write": 1
}, },
@ -302,15 +303,6 @@
"options": "Installation Note Item" "options": "Installation Note Item"
}, },
{ {
"doctype": "DocPerm", "doctype": "DocPerm"
"role": "System Manager"
},
{
"doctype": "DocPerm",
"role": "Sales User"
},
{
"doctype": "DocPerm",
"role": "Sales Manager"
} }
] ]

View File

@ -104,7 +104,17 @@ cur_frm.cscript['Create Customer'] = function(){
'from_to_list':"[['Lead', 'Customer']]" 'from_to_list':"[['Lead', 'Customer']]"
}, },
function(r,rt) { 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);
});
} }
); );
} }

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-04-03 09:10:44", "creation": "2013-05-22 12:10:46",
"docstatus": 0, "docstatus": 0,
"modified": "2013-04-03 09:58:02", "modified": "2013-05-22 16:54:07",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -833,12 +833,11 @@
"width": "100px" "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", "doctype": "DocField",
"fieldname": "communication_history", "fieldname": "communication_history",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Communication History",
"oldfieldtype": "Section Break", "oldfieldtype": "Section Break",
"options": "Simple",
"print_hide": 1, "print_hide": 1,
"read_only": 0 "read_only": 0
}, },
@ -869,28 +868,23 @@
"cancel": 1, "cancel": 1,
"create": 1, "create": 1,
"doctype": "DocPerm", "doctype": "DocPerm",
"role": "Sales Manager", "role": "Sales User",
"submit": 1, "submit": 1,
"write": 1 "write": 1
}, },
{
"doctype": "DocPerm",
"role": "Customer"
},
{ {
"amend": 1, "amend": 1,
"cancel": 1, "cancel": 1,
"create": 1, "create": 1,
"doctype": "DocPerm", "doctype": "DocPerm",
"role": "Sales User", "role": "Sales Manager",
"submit": 1, "submit": 1,
"write": 1 "write": 1
}, },
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"role": "Customer",
"submit": 0,
"write": 0
},
{ {
"amend": 1, "amend": 1,
"cancel": 1, "cancel": 1,

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-02-22 01:27:52", "creation": "2013-03-07 11:42:57",
"docstatus": 0, "docstatus": 0,
"modified": "2013-03-07 07:03:29", "modified": "2013-05-22 12:08:32",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -37,6 +37,7 @@
"options": "Item", "options": "Item",
"print_hide": 0, "print_hide": 0,
"print_width": "150px", "print_width": "150px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1, "search_index": 1,
"width": "150px" "width": "150px"
@ -60,6 +61,7 @@
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
"print_width": "150px", "print_width": "150px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1, "search_index": 1,
"width": "150px" "width": "150px"
@ -73,6 +75,7 @@
"oldfieldtype": "Small Text", "oldfieldtype": "Small Text",
"print_hide": 0, "print_hide": 0,
"print_width": "300px", "print_width": "300px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "300px" "width": "300px"
}, },
@ -87,6 +90,7 @@
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"print_hide": 0, "print_hide": 0,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
"width": "100px" "width": "100px"
@ -115,6 +119,7 @@
"options": "currency", "options": "currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 0, "reqd": 0,
"width": "100px" "width": "100px"
}, },
@ -128,6 +133,7 @@
"oldfieldtype": "Float", "oldfieldtype": "Float",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"width": "100px" "width": "100px"
}, },
{ {
@ -142,6 +148,7 @@
"options": "currency", "options": "currency",
"print_hide": 0, "print_hide": 0,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"width": "100px" "width": "100px"
@ -188,6 +195,7 @@
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"width": "100px" "width": "100px"
@ -291,6 +299,7 @@
"oldfieldname": "page_break", "oldfieldname": "page_break",
"oldfieldtype": "Check", "oldfieldtype": "Check",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"report_hide": 1 "report_hide": 1
} }
] ]

View File

@ -217,7 +217,10 @@ class DocType(SellingController):
self.validate_proj_cust() self.validate_proj_cust()
self.validate_po() self.validate_po()
#self.validate_reference_value() #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 = get_obj(dt = 'Sales Common')
sales_com_obj.check_active_sales_items(self) sales_com_obj.check_active_sales_items(self)
sales_com_obj.check_conversion_rate(self) sales_com_obj.check_conversion_rate(self)

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-02-22 01:27:52", "creation": "2013-03-07 11:42:58",
"docstatus": 0, "docstatus": 0,
"modified": "2013-03-07 07:03:30", "modified": "2013-05-22 12:09:03",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -35,6 +35,7 @@
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Item", "options": "Item",
"print_width": "150px", "print_width": "150px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1, "search_index": 1,
"width": "150px" "width": "150px"
@ -57,6 +58,7 @@
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
"print_width": "150", "print_width": "150",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "150" "width": "150"
}, },
@ -69,6 +71,7 @@
"oldfieldname": "description", "oldfieldname": "description",
"oldfieldtype": "Small Text", "oldfieldtype": "Small Text",
"print_width": "300px", "print_width": "300px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1, "search_index": 1,
"width": "300px" "width": "300px"
@ -82,6 +85,7 @@
"oldfieldname": "qty", "oldfieldname": "qty",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "100px" "width": "100px"
}, },
@ -109,6 +113,7 @@
"options": "currency", "options": "currency",
"print_hide": 1, "print_hide": 1,
"print_width": "70px", "print_width": "70px",
"read_only": 0,
"reqd": 0, "reqd": 0,
"width": "70px" "width": "70px"
}, },
@ -122,6 +127,7 @@
"oldfieldtype": "Float", "oldfieldtype": "Float",
"print_hide": 1, "print_hide": 1,
"print_width": "70px", "print_width": "70px",
"read_only": 0,
"width": "70px" "width": "70px"
}, },
{ {
@ -134,6 +140,7 @@
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "currency", "options": "currency",
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 0, "reqd": 0,
"width": "100px" "width": "100px"
}, },
@ -176,6 +183,7 @@
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 0, "reqd": 0,
"width": "100px" "width": "100px"
}, },
@ -206,6 +214,7 @@
"options": "Warehouse", "options": "Warehouse",
"print_hide": 1, "print_hide": 1,
"print_width": "150px", "print_width": "150px",
"read_only": 0,
"reqd": 0, "reqd": 0,
"width": "150px" "width": "150px"
}, },
@ -329,6 +338,7 @@
"hidden": 0, "hidden": 0,
"in_filter": 1, "in_filter": 1,
"label": "Quotation No.", "label": "Quotation No.",
"no_copy": 1,
"oldfieldname": "prevdoc_docname", "oldfieldname": "prevdoc_docname",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Quotation", "options": "Quotation",
@ -345,6 +355,7 @@
"oldfieldname": "page_break", "oldfieldname": "page_break",
"oldfieldtype": "Check", "oldfieldtype": "Check",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"report_hide": 1 "report_hide": 1
}, },
{ {

View File

@ -16,6 +16,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes import _, msgprint
from webnotes.utils import cstr from webnotes.utils import cstr
from webnotes.model.doc import Document from webnotes.model.doc import Document
@ -287,7 +288,10 @@ class DocType:
where doctype='Global Defaults' and field='default_company' where doctype='Global Defaults' and field='default_company'
and value=%s""", self.doc.name) 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 webnotes.conn.sql("""update `tabCompany` set company_name=%s
where name=%s""", (newdn, olddn)) where name=%s""", (newdn, olddn))

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-04-01 15:05:24", "creation": "2013-05-02 17:53:24",
"docstatus": 0, "docstatus": 0,
"modified": "2013-05-02 15:05:21", "modified": "2013-05-22 15:57:26",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -27,6 +27,8 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"doctype": "DocPerm", "doctype": "DocPerm",
"name": "__common__", "name": "__common__",
@ -170,7 +172,8 @@
"fieldname": "item_naming_by", "fieldname": "item_naming_by",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Item Naming By", "label": "Item Naming By",
"options": "Item Code\nNaming Series" "options": "Item Code\nNaming Series",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -212,14 +215,6 @@
"label": "Allow Negative Stock", "label": "Allow Negative Stock",
"read_only": 0 "read_only": 0
}, },
{
"doctype": "DocField",
"fieldname": "default_warehouse_type",
"fieldtype": "Link",
"label": "Default Warehouse Type",
"options": "Warehouse Type",
"read_only": 0
},
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "auto_indent", "fieldname": "auto_indent",
@ -227,6 +222,21 @@
"label": "Raise Material Request when stock reaches re-order level", "label": "Raise Material Request when stock reaches re-order level",
"read_only": 0 "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", "default": "1",
"doctype": "DocField", "doctype": "DocField",
@ -235,6 +245,14 @@
"read_only": 0, "read_only": 0,
"width": "50%" "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. <p>For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units</p>", "description": "Percentage you are allowed to receive or deliver more against the quantity ordered. <p>For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units</p>",
"doctype": "DocField", "doctype": "DocField",
@ -274,7 +292,8 @@
"fieldtype": "Check", "fieldtype": "Check",
"label": "Auto Inventory Accounting", "label": "Auto Inventory Accounting",
"no_copy": 0, "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", "description": "Accounting entry frozen up to this date, nobody can do / modify entry except authorized person",
@ -507,11 +526,6 @@
"label": "SMS Sender Name", "label": "SMS Sender Name",
"read_only": 0 "read_only": 0
}, },
{
"amend": 0,
"cancel": 0,
"doctype": "DocPerm"
},
{ {
"doctype": "DocPerm" "doctype": "DocPerm"
} }

View File

@ -81,3 +81,4 @@ class DocType(DocTypeNestedSet):
if self.doc.slideshow: if self.doc.slideshow:
from website.helpers.slideshow import get_slideshow from website.helpers.slideshow import get_slideshow
get_slideshow(self) get_slideshow(self)

View File

@ -33,3 +33,6 @@ class DocType:
msgprint(_("""Please check "Valid For All Countries" or \ msgprint(_("""Please check "Valid For All Countries" or \
enter atlease one row in the "Countries" table."""), raise_exception=True) 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)

View File

@ -193,21 +193,8 @@ wn.module_page["Setup"] = [
] ]
}, },
{ {
title: wn._("Backups"), title: wn._("Administration"),
icon: "icon-cloud-upload", icon: "icon-rocket",
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",
right: true, right: true,
items: [ items: [
{ {
@ -215,6 +202,18 @@ wn.module_page["Setup"] = [
label: wn._("Update This Application"), label: wn._("Update This Application"),
"description":wn._("Apply latest updates and patches to this app") "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")
},
] ]
}, },
] ]

View File

@ -55,6 +55,10 @@ def execute_daily():
from setup.doctype.backup_manager.backup_manager import take_backups_daily from setup.doctype.backup_manager.backup_manager import take_backups_daily
take_backups_daily() take_backups_daily()
# check reorder level
from stock.utils import reorder_item
run_fn(reorder_item)
def execute_weekly(): def execute_weekly():
from setup.doctype.backup_manager.backup_manager import take_backups_weekly from setup.doctype.backup_manager.backup_manager import take_backups_weekly
take_backups_weekly() take_backups_weekly()

View File

@ -1,5 +1,5 @@
import webnotes, conf, os import webnotes, conf, os
from webnotes.utils import cint, cstr from webnotes.utils import cint, cstr, encode
def get_templates_path(): def get_templates_path():
return os.path.join(os.path.dirname(conf.__file__), "app", "website", "templates") 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[k] = cint(args.get(k) or 0)
args.url = quote(str(get_request_site_address(full_address=True)), str("")) 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 return args

View File

@ -77,10 +77,6 @@ class DocType:
self.doc.save() 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): def get_first_sle(self):
sle = sql(""" sle = sql("""
select * from `tabStock Ledger Entry` select * from `tabStock Ledger Entry`
@ -90,82 +86,4 @@ class DocType:
order by timestamp(posting_date, posting_time) asc, name asc order by timestamp(posting_date, posting_time) asc, name asc
limit 1 limit 1
""", (self.doc.item_code, self.doc.warehouse), as_dict=1) """, (self.doc.item_code, self.doc.warehouse), as_dict=1)
return sle and sle[0] or None 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)

View File

@ -419,4 +419,4 @@ class DocType(SellingController):
if gl_entries: if gl_entries:
from accounts.general_ledger import make_gl_entries from accounts.general_ledger import make_gl_entries
make_gl_entries(gl_entries) make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2))

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-04-01 10:49:21", "creation": "2013-04-22 13:15:44",
"docstatus": 0, "docstatus": 0,
"modified": "2013-04-17 17:20:58", "modified": "2013-05-22 12:05:32",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -340,6 +340,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "Document Type", "label": "Document Type",
"no_copy": 1,
"oldfieldname": "prevdoc_doctype", "oldfieldname": "prevdoc_doctype",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
@ -371,6 +372,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "Against Document Date", "label": "Against Document Date",
"no_copy": 1,
"oldfieldname": "prevdoc_date", "oldfieldname": "prevdoc_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_hide": 1, "print_hide": 1,
@ -383,6 +385,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "Against Document Detail No", "label": "Against Document Detail No",
"no_copy": 1,
"oldfieldname": "prevdoc_detail_docname", "oldfieldname": "prevdoc_detail_docname",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,

View File

@ -51,6 +51,7 @@ class DocType(DocListController):
self.validate_barcode() self.validate_barcode()
self.check_non_asset_warehouse() self.check_non_asset_warehouse()
self.cant_change() self.cant_change()
self.validate_item_type_for_reorder()
if self.doc.name: if self.doc.name:
self.old_page_name = webnotes.conn.get_value('Item', self.doc.name, 'page_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 \ webnotes.msgprint(_("As there are existing stock transactions for this \
item, you can not change the values of 'Has Serial No', \ item, you can not change the values of 'Has Serial No', \
'Is Stock Item' and 'Valuation Method'"), raise_exception=1) '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): def check_if_sle_exists(self):
sle = webnotes.conn.sql("""select name from `tabStock Ledger Entry` sle = webnotes.conn.sql("""select name from `tabStock Ledger Entry`
@ -272,7 +280,7 @@ class DocType(DocListController):
from webnotes.webutils import clear_cache from webnotes.webutils import clear_cache
clear_cache(self.doc.page_name) 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)) webnotes.conn.sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
if self.doc.page_name: if self.doc.page_name:
from webnotes.webutils import clear_cache from webnotes.webutils import clear_cache

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-03 10:45:46", "creation": "2013-05-03 10:45:46",
"docstatus": 0, "docstatus": 0,
"modified": "2013-05-07 15:58:58", "modified": "2013-05-22 15:48:27",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -363,21 +363,6 @@
"label": "Re-Order Qty", "label": "Re-Order Qty",
"read_only": 0 "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", "doctype": "DocField",
"fieldname": "section_break_31", "fieldname": "section_break_31",

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-02-22 01:28:03", "creation": "2013-03-07 11:42:59",
"docstatus": 0, "docstatus": 0,
"modified": "2013-03-07 07:03:28", "modified": "2013-05-22 12:01:08",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -35,6 +35,7 @@
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Item", "options": "Item",
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1, "search_index": 1,
"width": "100px" "width": "100px"
@ -48,6 +49,7 @@
"oldfieldname": "item_name", "oldfieldname": "item_name",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 0 "search_index": 0
}, },
@ -59,6 +61,7 @@
"oldfieldname": "description", "oldfieldname": "description",
"oldfieldtype": "Text", "oldfieldtype": "Text",
"print_width": "300px", "print_width": "300px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "300px" "width": "300px"
}, },
@ -72,6 +75,7 @@
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "100px" "width": "100px"
}, },
@ -84,6 +88,7 @@
"oldfieldname": "qty", "oldfieldname": "qty",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"width": "100px" "width": "100px"
}, },
{ {
@ -97,6 +102,7 @@
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"search_index": 0, "search_index": 0,
"width": "100px" "width": "100px"
}, },
@ -110,6 +116,7 @@
"options": "UOM", "options": "UOM",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "100px" "width": "100px"
}, },
@ -119,14 +126,16 @@
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Ref Rate ", "label": "Ref Rate ",
"options": "currency", "options": "currency",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "discount_rate", "fieldname": "discount_rate",
"fieldtype": "Float", "fieldtype": "Float",
"label": "Discount %", "label": "Discount %",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"default": "0.00", "default": "0.00",
@ -139,6 +148,7 @@
"options": "currency", "options": "currency",
"print_hide": 0, "print_hide": 0,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"width": "100px" "width": "100px"
}, },
{ {
@ -157,7 +167,8 @@
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Ref Rate*", "label": "Ref Rate*",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"default": "0.00", "default": "0.00",
@ -170,6 +181,7 @@
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "100px" "width": "100px"
}, },
@ -184,6 +196,7 @@
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 0, "reqd": 0,
"width": "100px" "width": "100px"
}, },
@ -198,6 +211,7 @@
"options": "Warehouse", "options": "Warehouse",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"width": "100px" "width": "100px"
}, },
{ {
@ -209,6 +223,7 @@
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"reqd": 1, "reqd": 1,
"width": "100px" "width": "100px"
}, },
@ -235,6 +250,7 @@
"oldfieldname": "serial_no", "oldfieldname": "serial_no",
"oldfieldtype": "Text", "oldfieldtype": "Text",
"print_hide": 0, "print_hide": 0,
"read_only": 0,
"report_hide": 0 "report_hide": 0
}, },
{ {
@ -242,7 +258,8 @@
"fieldname": "rejected_serial_no", "fieldname": "rejected_serial_no",
"fieldtype": "Text", "fieldtype": "Text",
"label": "Rejected Serial No", "label": "Rejected Serial No",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -252,7 +269,8 @@
"oldfieldname": "batch_no", "oldfieldname": "batch_no",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Batch", "options": "Batch",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -278,6 +296,7 @@
"oldfieldname": "schedule_date", "oldfieldname": "schedule_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_hide": 1, "print_hide": 1,
"read_only": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0 "reqd": 0
}, },
@ -288,7 +307,8 @@
"in_filter": 1, "in_filter": 1,
"label": "Project Name", "label": "Project Name",
"options": "Project", "options": "Project",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -299,7 +319,8 @@
"oldfieldname": "qa_no", "oldfieldname": "qa_no",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Quality Inspection", "options": "Quality Inspection",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -336,6 +357,7 @@
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0,
"width": "100px" "width": "100px"
}, },
{ {
@ -344,9 +366,11 @@
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
"label": "Prevdoc Doctype", "label": "Prevdoc Doctype",
"no_copy": 1,
"oldfieldname": "prevdoc_doctype", "oldfieldname": "prevdoc_doctype",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1 "print_hide": 1,
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -355,7 +379,7 @@
"hidden": 0, "hidden": 0,
"in_filter": 1, "in_filter": 1,
"label": "PO No", "label": "PO No",
"no_copy": 0, "no_copy": 1,
"oldfieldname": "prevdoc_docname", "oldfieldname": "prevdoc_docname",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Purchase Order", "options": "Purchase Order",
@ -373,6 +397,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "PO Date", "label": "PO Date",
"no_copy": 1,
"oldfieldname": "prevdoc_date", "oldfieldname": "prevdoc_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_hide": 1, "print_hide": 1,
@ -418,7 +443,7 @@
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "Purchase Order Item No", "label": "Purchase Order Item No",
"no_copy": 0, "no_copy": 1,
"oldfieldname": "prevdoc_detail_docname", "oldfieldname": "prevdoc_detail_docname",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"print_hide": 1, "print_hide": 1,
@ -479,6 +504,7 @@
"label": "Page Break", "label": "Page Break",
"oldfieldname": "page_break", "oldfieldname": "page_break",
"oldfieldtype": "Check", "oldfieldtype": "Check",
"print_hide": 1 "print_hide": 1,
"read_only": 0
} }
] ]

View File

@ -19,7 +19,7 @@ import webnotes
from webnotes.utils import cint, getdate, nowdate from webnotes.utils import cint, getdate, nowdate
import datetime import datetime
from webnotes import msgprint from webnotes import msgprint, _
from controllers.stock_controller import StockController from controllers.stock_controller import StockController
@ -117,8 +117,11 @@ class DocType(StockController):
self.make_stock_ledger_entry(1) self.make_stock_ledger_entry(1)
self.make_gl_entries() self.make_gl_entries()
def on_rename(self, new, old): def on_rename(self, new, old, merge=False):
"""rename serial_no text fields""" """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 for dt in webnotes.conn.sql("""select parent from tabDocField
where fieldname='serial_no' and fieldtype='Text'"""): 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) gl_entries = self.get_gl_entries_for_stock(against_stock_account, self.doc.purchase_rate)
for entry in gl_entries: 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: if gl_entries:
make_gl_entries(gl_entries, cancel) make_gl_entries(gl_entries, cancel)

View File

@ -57,6 +57,7 @@ class DocType(StockController):
self.validate_return_reference_doc() self.validate_return_reference_doc()
self.validate_with_material_request() self.validate_with_material_request()
self.validate_fiscal_year() self.validate_fiscal_year()
self.set_total_amount()
def on_submit(self): def on_submit(self):
self.update_serial_no(1) self.update_serial_no(1)
@ -174,6 +175,9 @@ class DocType(StockController):
elif self.doc.purpose != "Material Transfer": elif self.doc.purpose != "Material Transfer":
self.doc.production_order = None 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): def make_gl_entries(self):
if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")): if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")):
return return
@ -220,7 +224,7 @@ class DocType(StockController):
if not flt(d.incoming_rate): if not flt(d.incoming_rate):
d.incoming_rate = self.get_incoming_rate(args) 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): def get_incoming_rate(self, args):
incoming_rate = 0 incoming_rate = 0

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-03-28 15:56:40", "creation": "2013-04-09 11:43:55",
"docstatus": 0, "docstatus": 0,
"modified": "2013-03-29 15:31:42", "modified": "2013-05-09 13:31:00",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -518,6 +518,14 @@
"read_only": 0, "read_only": 0,
"width": "50%" "width": "50%"
}, },
{
"doctype": "DocField",
"fieldname": "total_amount",
"fieldtype": "Currency",
"label": "Total Amount",
"options": "Company:company:default_currency",
"read_only": 1
},
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "project_name", "fieldname": "project_name",
@ -558,6 +566,14 @@
"read_only": 0, "read_only": 0,
"reqd": 1 "reqd": 1
}, },
{
"doctype": "DocField",
"fieldname": "col5",
"fieldtype": "Column Break",
"print_width": "50%",
"read_only": 0,
"width": "50%"
},
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"doctype": "DocField", "doctype": "DocField",
@ -576,14 +592,6 @@
"reqd": 1, "reqd": 1,
"search_index": 0 "search_index": 0
}, },
{
"doctype": "DocField",
"fieldname": "col5",
"fieldtype": "Column Break",
"print_width": "50%",
"read_only": 0,
"width": "50%"
},
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"doctype": "DocField", "doctype": "DocField",

View File

@ -201,6 +201,10 @@ wn.module_page["Stock"] = [
"label":wn._("Purchase In Transit"), "label":wn._("Purchase In Transit"),
route: "query-report/Purchase In Transit", route: "query-report/Purchase In Transit",
}, },
{
"label":wn._("Requested Items To Be Transferred"),
route: "query-report/Requested Items To Be Transferred",
},
] ]
} }
] ]

View File

@ -1,16 +1,17 @@
[ [
{ {
"creation": "2013-02-21 14:26:49", "creation": "2013-02-22 18:01:55",
"docstatus": 0, "docstatus": 0,
"modified": "2013-02-22 15:53:01", "modified": "2013-05-13 16:11:27",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
{ {
"add_total_row": 1,
"doctype": "Report", "doctype": "Report",
"is_standard": "Yes", "is_standard": "Yes",
"name": "__common__", "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", "ref_doctype": "Purchase Receipt",
"report_name": "Purchase Order Items To Be Received", "report_name": "Purchase Order Items To Be Received",
"report_type": "Query Report" "report_type": "Query Report"

Some files were not shown because too many files have changed in this diff Show More