diff --git a/accounts/DocType Mapper/Purchase Order-Purchase Invoice/Purchase Order-Purchase Invoice.txt b/accounts/DocType Mapper/Purchase Order-Purchase Invoice/Purchase Order-Purchase Invoice.txt
index ce45824e404..031abd216d8 100644
--- a/accounts/DocType Mapper/Purchase Order-Purchase Invoice/Purchase Order-Purchase Invoice.txt
+++ b/accounts/DocType Mapper/Purchase Order-Purchase Invoice/Purchase Order-Purchase Invoice.txt
@@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2010-08-08 17:09:35",
"modified_by": "Administrator",
- "modified": "2012-04-03 12:49:50"
+ "modified": "2013-07-04 12:49:50"
},
{
"name": "__common__",
@@ -120,4 +120,4 @@
"to_table": "Purchase Taxes and Charges",
"validation_logic": "docstatus =1"
}
-]
\ No newline at end of file
+]
diff --git a/accounts/DocType Mapper/Purchase Receipt-Purchase Invoice/Purchase Receipt-Purchase Invoice.txt b/accounts/DocType Mapper/Purchase Receipt-Purchase Invoice/Purchase Receipt-Purchase Invoice.txt
index f6c87e266c7..5ed4b2aced8 100644
--- a/accounts/DocType Mapper/Purchase Receipt-Purchase Invoice/Purchase Receipt-Purchase Invoice.txt
+++ b/accounts/DocType Mapper/Purchase Receipt-Purchase Invoice/Purchase Receipt-Purchase Invoice.txt
@@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2010-08-08 17:09:35",
"modified_by": "Administrator",
- "modified": "2012-04-03 12:49:50"
+ "modified": "2013-07-04 12:49:50"
},
{
"name": "__common__",
@@ -141,4 +141,4 @@
"to_table": "Purchase Taxes and Charges",
"validation_logic": "docstatus=1"
}
-]
\ No newline at end of file
+]
diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py
index eb65604e026..bdc26e46ce2 100644
--- a/accounts/doctype/account/account.py
+++ b/accounts/doctype/account/account.py
@@ -187,7 +187,7 @@ class DocType:
sql("""delete from `tabGL Entry` where account = %s and
ifnull(is_cancelled, 'No') = 'Yes'""", self.doc.name)
- def on_rename(self, new, old):
+ def on_rename(self, new, old, merge=False):
company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
parts = new.split(" - ")
diff --git a/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/accounts/doctype/bank_reconciliation/bank_reconciliation.py
index 980af5844f8..f19df48306e 100644
--- a/accounts/doctype/bank_reconciliation/bank_reconciliation.py
+++ b/accounts/doctype/bank_reconciliation/bank_reconciliation.py
@@ -66,6 +66,6 @@ class DocType:
vouchers.append(d.voucher_id)
if vouchers:
- msgprint("Clearance Date updated in %s" % vouchers)
+ msgprint("Clearance Date updated in %s" % ", ".join(vouchers))
else:
msgprint("Clearance Date not mentioned")
\ No newline at end of file
diff --git a/accounts/doctype/c_form/c_form.py b/accounts/doctype/c_form/c_form.py
index 9f89ad5d072..25a8c3bfc19 100644
--- a/accounts/doctype/c_form/c_form.py
+++ b/accounts/doctype/c_form/c_form.py
@@ -17,16 +17,12 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt, getdate
-from webnotes.model.doc import make_autoname
from webnotes.model.bean import getlist
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
- def autoname(self):
- self.doc.name = make_autoname(self.doc.naming_series + '.#####')
-
def validate(self):
"""Validate invoice that c-form is applicable
and no other c-form is received for that"""
diff --git a/accounts/doctype/c_form/c_form.txt b/accounts/doctype/c_form/c_form.txt
index 3a956e9aec8..9243d362cd3 100644
--- a/accounts/doctype/c_form/c_form.txt
+++ b/accounts/doctype/c_form/c_form.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-01-30 12:49:46",
+ "creation": "2013-03-07 14:48:29",
"docstatus": 0,
"modified": "2013-02-13 11:29:18",
"modified_by": "Administrator",
@@ -24,17 +24,13 @@
"permlevel": 0
},
{
- "create": 1,
"doctype": "DocPerm",
"name": "__common__",
"parent": "C-Form",
"parentfield": "permissions",
"parenttype": "DocType",
- "permlevel": 0,
"read": 1,
- "report": 1,
- "submit": 0,
- "write": 1
+ "submit": 0
},
{
"doctype": "DocType",
@@ -156,15 +152,6 @@
"print_hide": 0,
"read_only": 1
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "print_hide": 1,
- "read_only": 0
- },
{
"doctype": "DocField",
"fieldname": "amended_from",
@@ -176,11 +163,28 @@
"read_only": 1
},
{
+ "create": 1,
"doctype": "DocPerm",
- "role": "Accounts User"
+ "permlevel": 0,
+ "report": 1,
+ "role": "Accounts User",
+ "write": 1
},
{
+ "create": 1,
"doctype": "DocPerm",
- "role": "Accounts Manager"
+ "permlevel": 0,
+ "report": 1,
+ "role": "Accounts Manager",
+ "write": 1
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "match": "",
+ "permlevel": 1,
+ "role": "All"
}
]
\ No newline at end of file
diff --git a/accounts/doctype/cost_center/cost_center.py b/accounts/doctype/cost_center/cost_center.py
index e57b6a37582..4e9b7fd9e7a 100644
--- a/accounts/doctype/cost_center/cost_center.py
+++ b/accounts/doctype/cost_center/cost_center.py
@@ -29,7 +29,7 @@ class DocType(DocTypeNestedSet):
def autoname(self):
company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s",
self.doc.company_name)[0][0]
- self.doc.name = self.doc.cost_center_name + ' - ' + company_abbr
+ self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr
def validate_mandatory(self):
if not self.doc.group_or_ledger:
@@ -81,13 +81,13 @@ class DocType(DocTypeNestedSet):
"""
Cost Center name must be unique
"""
- if (self.doc.__islocal or not self.doc.name) and webnotes.conn.sql("select name from `tabCost Center` where cost_center_name = %s and company_name=%s", (self.doc.cost_center_name, self.doc.company_name)):
+ if (self.doc.fields.get("__islocal") or not self.doc.name) and webnotes.conn.sql("select name from `tabCost Center` where cost_center_name = %s and company_name=%s", (self.doc.cost_center_name, self.doc.company_name)):
msgprint("Cost Center Name already exists, please rename", raise_exception=1)
self.validate_mandatory()
self.validate_budget_details()
- def on_rename(self, new, old):
+ def on_rename(self, new, old, merge=False):
company_abbr = webnotes.conn.get_value("Company", self.doc.company_name, "abbr")
parts = new.split(" - ")
diff --git a/accounts/doctype/gl_entry/gl_entry.py b/accounts/doctype/gl_entry/gl_entry.py
index 64d84b04594..a2ef25a7773 100644
--- a/accounts/doctype/gl_entry/gl_entry.py
+++ b/accounts/doctype/gl_entry/gl_entry.py
@@ -42,9 +42,9 @@ class DocType:
self.check_negative_balance(adv_adj)
# Update outstanding amt on against voucher
- if self.doc.against_voucher and self.doc.against_voucher_type not in \
- ('Journal Voucher','POS') and update_outstanding == 'Yes':
- self.update_outstanding_amt()
+ if self.doc.against_voucher and self.doc.against_voucher_type != "POS" \
+ and update_outstanding == 'Yes':
+ self.update_outstanding_amt()
def check_mandatory(self):
mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company']
@@ -108,8 +108,8 @@ class DocType:
and not 'Accounts Manager' in webnotes.user.get_roles():
msgprint(_("Account") + ": " + self.doc.account + _(" has been freezed. \
Only Accounts Manager can do transaction against this account"), raise_exception=1)
-
- if ret and ret[0]["company"] != self.doc.company:
+
+ if self.doc.is_cancelled in ("No", None) and ret and ret[0]["company"] != self.doc.company:
msgprint(_("Account") + ": " + self.doc.account + _(" does not belong to the company") \
+ ": " + self.doc.company, raise_exception=1)
@@ -124,9 +124,10 @@ class DocType:
return self.cost_center_company[self.doc.cost_center]
- if self.doc.cost_center and _get_cost_center_company() != self.doc.company:
- msgprint(_("Cost Center") + ": " + self.doc.cost_center \
- + _(" does not belong to the company") + ": " + self.doc.company, raise_exception=True)
+ if self.doc.is_cancelled in ("No", None) and \
+ self.doc.cost_center and _get_cost_center_company() != self.doc.company:
+ msgprint(_("Cost Center") + ": " + self.doc.cost_center \
+ + _(" does not belong to the company") + ": " + self.doc.company, raise_exception=True)
def check_freezing_date(self, adv_adj):
"""
@@ -159,20 +160,29 @@ class DocType:
def update_outstanding_amt(self):
# get final outstanding amt
bal = flt(sql("""select sum(debit) - sum(credit) from `tabGL Entry`
- where against_voucher=%s and against_voucher_type=%s
- and ifnull(is_cancelled,'No') = 'No'""",
- (self.doc.against_voucher, self.doc.against_voucher_type))[0][0] or 0.0)
-
- if self.doc.against_voucher_type=='Purchase Invoice':
- # amount to debit
+ where against_voucher=%s and against_voucher_type=%s and account = %s
+ and ifnull(is_cancelled,'No') = 'No'""", (self.doc.against_voucher,
+ self.doc.against_voucher_type, self.doc.account))[0][0] or 0.0)
+
+ if self.doc.against_voucher_type == 'Purchase Invoice':
bal = -bal
+
+ elif self.doc.against_voucher_type == "Journal Voucher":
+ against_voucher_amount = flt(webnotes.conn.sql("""select sum(debit) - sum(credit)
+ from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s
+ and account = %s""", (self.doc.against_voucher, self.doc.account))[0][0])
+
+ bal = against_voucher_amount + bal
+ if against_voucher_amount < 0:
+ bal = -bal
# Validation : Outstanding can not be negative
if bal < 0 and self.doc.is_cancelled == 'No':
msgprint(_("Outstanding for Voucher ") + self.doc.against_voucher +
- _(" will become ") + fmt_money(bal) + _("Outstanding cannot be less than zero. \
+ _(" will become ") + fmt_money(bal) + _(". Outstanding cannot be less than zero. \
Please match exact outstanding."), raise_exception=1)
# Update outstanding amt on against voucher
- sql("update `tab%s` set outstanding_amount=%s where name='%s'"%
- (self.doc.against_voucher_type, bal, self.doc.against_voucher))
\ No newline at end of file
+ if self.doc.against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
+ sql("update `tab%s` set outstanding_amount=%s where name='%s'"%
+ (self.doc.against_voucher_type, bal, self.doc.against_voucher))
\ No newline at end of file
diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py
index 9b1ca7a105b..a5a4f10f344 100644
--- a/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/accounts/doctype/journal_voucher/journal_voucher.py
@@ -34,15 +34,12 @@ class DocType(AccountsController):
self.credit_days_global = -1
self.is_approving_authority = -1
- def autoname(self):
- if not self.doc.naming_series:
- webnotes.msgprint("""Naming Series is mandatory""", raise_exception=1)
- self.doc.name = make_autoname(self.doc.naming_series+'.#####')
-
def validate(self):
if not self.doc.is_opening:
self.doc.is_opening='No'
+ self.doc.clearance_date = None
+
self.validate_debit_credit()
self.validate_cheque_info()
self.validate_entries_for_advance()
diff --git a/accounts/doctype/journal_voucher/test_journal_voucher.py b/accounts/doctype/journal_voucher/test_journal_voucher.py
index 7cfeb595d81..feb1e2ca5a6 100644
--- a/accounts/doctype/journal_voucher/test_journal_voucher.py
+++ b/accounts/doctype/journal_voucher/test_journal_voucher.py
@@ -122,119 +122,4 @@ test_records = [
"parentfield": "entries",
"cost_center": "_Test Cost Center - _TC"
}],
-]
-
-
-
-
-
-
-#
-#
-# import webnotes.model
-# from webnotes.utils import nowdate, flt, add_days
-# from accounts.utils import get_fiscal_year, get_balance_on
-#
-# company = webnotes.conn.get_default("company")
-# abbr = webnotes.conn.get_value("Company", company, "abbr")
-#
-# data = {
-# "expense_account": {
-# "doctype": "Account",
-# "account_name": "Test Expense",
-# "parent_account": "Direct Expenses - %s" % abbr,
-# "company": company,
-# "debit_or_credit": "Debit",
-# "is_pl_account": "Yes",
-# "group_or_ledger": "Ledger"
-# },
-# "supplier_account": {
-# "doctype": "Account",
-# "account_name": "Test Supplier",
-# "parent_account": "Accounts Payable - %s" % abbr,
-# "company": company,
-# "debit_or_credit": "Credit",
-# "is_pl_account": "No",
-# "group_or_ledger": "Ledger"
-# },
-# "test_cost_center": {
-# "doctype": "Cost Center",
-# "cost_center_name": "Test Cost Center",
-# "parent_cost_center": "Root - %s" % abbr,
-# "company_name": company,
-# "group_or_ledger": "Ledger",
-# "company_abbr": abbr
-# },
-# "journal_voucher": [
-# {
-# "doctype": "Journal Voucher",
-# "voucher_type": "Journal Entry",
-# "naming_series": "JV",
-# "posting_date": nowdate(),
-# "remark": "Test Journal Voucher",
-# "fiscal_year": get_fiscal_year(nowdate())[0],
-# "company": company
-# },
-# {
-# "doctype": "Journal Voucher Detail",
-# "parentfield": "entries",
-# "account": "Test Expense - %s" % abbr,
-# "debit": 5000,
-# "cost_center": "Test Cost Center - %s" % abbr,
-# },
-# {
-# "doctype": "Journal Voucher Detail",
-# "parentfield": "entries",
-# "account": "Test Supplier - %s" % abbr,
-# "credit": 5000,
-# },
-# ]
-# }
-#
-# def get_name(s):
-# return s + " - " + abbr
-#
-# class TestJournalVoucher(unittest.TestCase):
-# def setUp(self):
-# webnotes.conn.begin()
-#
-# # create a dummy account
-# webnotes.model.insert([data["expense_account"]])
-# webnotes.model.insert([data["supplier_account"]])
-# webnotes.model.insert([data["test_cost_center"]])
-#
-# def tearDown(self):
-# webnotes.conn.rollback()
-#
-# def test_save_journal_voucher(self):
-# expense_ac_balance = get_balance_on(get_name("Test Expense"), nowdate())
-# supplier_ac_balance = get_balance_on(get_name("Test Supplier"), nowdate())
-#
-# dl = webnotes.model.insert(data["journal_voucher"])
-# dl.submit()
-# dl.load_from_db()
-#
-# # test submitted jv
-# self.assertTrue(webnotes.conn.exists("Journal Voucher", dl.doclist[0].name))
-# for d in dl.doclist[1:]:
-# self.assertEquals(webnotes.conn.get_value("Journal Voucher Detail",
-# d.name, "parent"), dl.doclist[0].name)
-#
-# # test gl entry
-# gle = webnotes.conn.sql("""select account, debit, credit
-# from `tabGL Entry` where voucher_no = %s order by account""",
-# dl.doclist[0].name)
-#
-# self.assertEquals((gle[0][0], flt(gle[0][1]), flt(gle[0][2])),
-# ('Test Expense - %s' % abbr, 5000.0, 0.0))
-# self.assertEquals((gle[1][0], flt(gle[1][1]), flt(gle[1][2])),
-# ('Test Supplier - %s' % abbr, 0.0, 5000.0))
-#
-# # check balance as on today
-# self.assertEqual(get_balance_on(get_name("Test Expense"), nowdate()),
-# expense_ac_balance + 5000)
-# self.assertEqual(get_balance_on(get_name("Test Supplier"), nowdate()),
-# supplier_ac_balance + 5000)
-#
-# # check previous balance
-# self.assertEqual(get_balance_on(get_name("Test Expense"), add_days(nowdate(), -1)), 0)
\ No newline at end of file
+]
\ No newline at end of file
diff --git a/accounts/doctype/mode_of_payment/mode_of_payment.txt b/accounts/doctype/mode_of_payment/mode_of_payment.txt
index 2d019964fca..0841af0dae5 100644
--- a/accounts/doctype/mode_of_payment/mode_of_payment.txt
+++ b/accounts/doctype/mode_of_payment/mode_of_payment.txt
@@ -1,68 +1,68 @@
[
{
- "owner": "harshada@webnotestech.com",
+ "creation": "2012-12-04 17:49:20",
"docstatus": 0,
- "creation": "2012-07-03 13:30:49",
+ "modified": "2013-04-19 10:59:05",
"modified_by": "Administrator",
- "modified": "2012-12-04 16:33:37"
+ "owner": "harshada@webnotestech.com"
},
{
- "name": "__common__",
+ "allow_rename": 1,
"autoname": "field:mode_of_payment",
- "module": "Accounts",
"doctype": "DocType",
- "document_type": "Master"
+ "document_type": "Master",
+ "module": "Accounts",
+ "name": "__common__"
},
{
+ "doctype": "DocField",
"name": "__common__",
"parent": "Mode of Payment",
- "doctype": "DocField",
+ "parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0,
- "parentfield": "fields"
+ "read_only": 0
},
{
- "parent": "Mode of Payment",
- "read": 1,
- "doctype": "DocPerm",
- "cancel": 1,
- "name": "__common__",
- "amend": 0,
"create": 1,
- "submit": 0,
- "write": 1,
+ "doctype": "DocPerm",
+ "name": "__common__",
+ "parent": "Mode of Payment",
+ "parentfield": "permissions",
"parenttype": "DocType",
- "role": "Accounts Manager",
- "report": 1,
"permlevel": 0,
- "parentfield": "permissions"
+ "read": 1,
+ "report": 1,
+ "role": "Accounts Manager",
+ "submit": 0,
+ "write": 1
},
{
- "name": "Mode of Payment",
- "doctype": "DocType"
+ "doctype": "DocType",
+ "name": "Mode of Payment"
},
{
- "oldfieldtype": "Data",
"doctype": "DocField",
- "label": "Mode of Payment",
- "oldfieldname": "mode_of_payment",
"fieldname": "mode_of_payment",
"fieldtype": "Data",
+ "label": "Mode of Payment",
+ "oldfieldname": "mode_of_payment",
+ "oldfieldtype": "Data",
"reqd": 1
},
{
"doctype": "DocField",
- "label": "Company",
"fieldname": "company",
"fieldtype": "Link",
+ "label": "Company",
"options": "Company"
},
{
"description": "Default Bank / Cash account will be automatically updated in POS Invoice when this mode is selected.",
"doctype": "DocField",
- "label": "Default Account",
"fieldname": "default_account",
"fieldtype": "Link",
+ "label": "Default Account",
"options": "Account"
},
{
diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js
index 8b35bc1028d..ac7d9d2d14e 100644
--- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js
+++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js
@@ -50,6 +50,7 @@ cur_frm.fields_dict.voucher_no.get_query = function(doc) {
where against_voucher_type = '%(dt)s' \
and against_voucher = gle.voucher_no \
and voucher_no != gle.voucher_no \
+ and account = gle.account \
and ifnull(is_cancelled, 'No') = 'No') != \
abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0)) \
ORDER BY gle.posting_date DESC, gle.voucher_no DESC LIMIT 50",
diff --git a/accounts/doctype/pos_setting/pos_setting.txt b/accounts/doctype/pos_setting/pos_setting.txt
index 4e30b57593b..788af9ee067 100755
--- a/accounts/doctype/pos_setting/pos_setting.txt
+++ b/accounts/doctype/pos_setting/pos_setting.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-26 11:03:07",
+ "creation": "2013-05-09 13:16:11",
"docstatus": 0,
- "modified": "2013-03-26 12:48:18",
+ "modified": "2013-05-23 12:52:09",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -40,6 +40,7 @@
"doctype": "DocField",
"fieldname": "user",
"fieldtype": "Link",
+ "in_list_view": 1,
"label": "User",
"oldfieldname": "user",
"oldfieldtype": "Link",
@@ -99,6 +100,7 @@
"doctype": "DocField",
"fieldname": "company",
"fieldtype": "Link",
+ "in_list_view": 1,
"label": "Company",
"oldfieldname": "company",
"oldfieldtype": "Link",
@@ -211,12 +213,14 @@
"options": "link:Print Heading"
},
{
+ "cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "System Manager",
"write": 1
},
{
+ "cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Accounts Manager",
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py
index 50d5d43d806..32a46cf58f3 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -326,7 +326,7 @@ class DocType(BuyingController):
against_accounts.append(stock_not_billed_account)
elif not item.expense_head:
- msgprint(_("""Expense account is mandatory for item: """) + item.item_code,
+ msgprint(_("""Expense account is mandatory for item: """) + (item.item_code or item.item_name),
raise_exception=1)
elif item.expense_head not in against_accounts:
@@ -464,15 +464,16 @@ class DocType(BuyingController):
# if auto inventory accounting enabled and stock item,
# then do stock related gl entries
# expense will be booked in sales invoice
-
stock_item_and_auto_inventory_accounting = True
+ valuation_amt = (flt(item.amount) + flt(item.item_tax_amount) +
+ flt(item.rm_supp_cost))
+
gl_entries.append(
self.get_gl_dict({
"account": stock_account,
"against": self.doc.credit_to,
- "debit": flt(item.valuation_rate) * flt(item.conversion_factor) \
- * flt(item.qty),
+ "debit": valuation_amt,
"remarks": self.doc.remarks or "Accounting Entry for Stock"
})
)
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.txt b/accounts/doctype/purchase_invoice/purchase_invoice.txt
index 4228264f68e..283c6123711 100755
--- a/accounts/doctype/purchase_invoice/purchase_invoice.txt
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-07 13:16:13",
+ "creation": "2013-05-07 13:50:30",
"docstatus": 0,
- "modified": "2013-03-22 18:17:14",
+ "modified": "2013-05-13 11:12:56",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -43,6 +43,7 @@
"fieldname": "column_break0",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -56,6 +57,7 @@
"oldfieldtype": "Select",
"options": "BILL\nBILLJ",
"print_hide": 1,
+ "read_only": 0,
"report_hide": 0,
"reqd": 1
},
@@ -70,6 +72,7 @@
"oldfieldtype": "Link",
"options": "Account",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1,
"search_index": 1
},
@@ -82,7 +85,8 @@
"oldfieldname": "supplier",
"oldfieldtype": "Link",
"options": "Supplier",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -133,6 +137,7 @@
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
+ "read_only": 0,
"reqd": 0,
"width": "50%"
},
@@ -148,6 +153,7 @@
"oldfieldname": "posting_date",
"oldfieldtype": "Date",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1,
"search_index": 1
},
@@ -161,6 +167,7 @@
"oldfieldname": "bill_no",
"oldfieldtype": "Data",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1,
"search_index": 1
},
@@ -173,6 +180,7 @@
"oldfieldname": "bill_date",
"oldfieldtype": "Date",
"print_hide": 1,
+ "read_only": 0,
"reqd": 0,
"search_index": 1
},
@@ -181,7 +189,8 @@
"fieldname": "items",
"fieldtype": "Section Break",
"label": "Items",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"allow_on_submit": 1,
@@ -191,25 +200,29 @@
"label": "Entries",
"oldfieldname": "entries",
"oldfieldtype": "Table",
- "options": "Purchase Invoice Item"
+ "options": "Purchase Invoice Item",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "section_break0",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "recalculate",
"fieldtype": "Button",
"label": "Recalculate",
- "oldfieldtype": "Button"
+ "oldfieldtype": "Button",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "section_break_17",
"fieldtype": "Section Break",
- "options": "Simple"
+ "options": "Simple",
+ "read_only": 0
},
{
"description": "Select Items from Purchase Order",
@@ -220,7 +233,8 @@
"oldfieldname": "purchase_order_main",
"oldfieldtype": "Link",
"options": "Purchase Order",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"description": "Select Items from Purchase Receipt",
@@ -231,7 +245,8 @@
"oldfieldname": "purchase_receipt_main",
"oldfieldtype": "Link",
"options": "Purchase Receipt",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -239,13 +254,15 @@
"fieldtype": "Button",
"label": "Get Items",
"oldfieldtype": "Button",
- "options": "pull_details"
+ "options": "pull_details",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "currency_price_list",
"fieldtype": "Section Break",
- "label": "Currency & Price List"
+ "label": "Currency & Price List",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -255,7 +272,8 @@
"oldfieldname": "currency",
"oldfieldtype": "Select",
"options": "Currency",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"default": "1",
@@ -266,12 +284,14 @@
"label": "Exchange Rate",
"oldfieldname": "conversion_rate",
"oldfieldtype": "Currency",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break2",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "read_only": 0
},
{
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
@@ -280,7 +300,8 @@
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"depends_on": "price_list_name",
@@ -289,7 +310,8 @@
"fieldtype": "Link",
"label": "Price List Currency",
"options": "Currency",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"depends_on": "price_list_name",
@@ -297,7 +319,8 @@
"fieldname": "plc_conversion_rate",
"fieldtype": "Float",
"label": "Price List Exchange Rate",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"description": "Add / Edit Taxes and Charges",
@@ -305,7 +328,8 @@
"fieldname": "taxes",
"fieldtype": "Section Break",
"label": "Taxes",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -315,7 +339,8 @@
"oldfieldname": "purchase_other_charges",
"oldfieldtype": "Link",
"options": "Purchase Taxes and Charges Master",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -324,7 +349,8 @@
"label": "Get Tax Detail",
"oldfieldtype": "Button",
"options": "get_purchase_tax_details",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -333,7 +359,8 @@
"label": "Purchase Taxes and Charges",
"oldfieldname": "purchase_tax_details",
"oldfieldtype": "Table",
- "options": "Purchase Taxes and Charges"
+ "options": "Purchase Taxes and Charges",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -341,7 +368,8 @@
"fieldtype": "Button",
"label": "Calculate Tax",
"oldfieldtype": "Button",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -349,7 +377,8 @@
"fieldtype": "HTML",
"label": "Tax Calculation",
"oldfieldtype": "HTML",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -366,7 +395,8 @@
"doctype": "DocField",
"fieldname": "contact_section",
"fieldtype": "Section Break",
- "label": "Contact Info"
+ "label": "Contact Info",
+ "read_only": 0
},
{
"depends_on": "eval:doc.supplier",
@@ -374,12 +404,14 @@
"fieldname": "supplier_address",
"fieldtype": "Link",
"label": "Supplier Address",
- "options": "Address"
+ "options": "Address",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break23",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -389,14 +421,16 @@
"fieldtype": "Link",
"label": "Contact Person",
"options": "Contact",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "totals",
"fieldtype": "Section Break",
"label": "Totals",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -499,6 +533,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
+ "read_only": 0,
"width": "50%"
},
{
@@ -564,7 +599,8 @@
"label": "Write Off Amount",
"no_copy": 1,
"options": "Company:company:default_currency",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"depends_on": "eval:flt(doc.write_off_amount)!=0",
@@ -574,7 +610,8 @@
"label": "Write Off Account",
"no_copy": 1,
"options": "Account",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"depends_on": "eval:flt(doc.write_off_amount)!=0",
@@ -583,8 +620,9 @@
"fieldtype": "Link",
"label": "Write Off Cost Center",
"no_copy": 1,
- "options": "Account",
- "print_hide": 1
+ "options": "Cost Center",
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -596,6 +634,7 @@
"oldfieldname": "against_expense_account",
"oldfieldtype": "Small Text",
"print_hide": 1,
+ "read_only": 0,
"report_hide": 0
},
{
@@ -604,7 +643,8 @@
"fieldtype": "Section Break",
"label": "Advances",
"oldfieldtype": "Section Break",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -613,7 +653,8 @@
"label": "Get Advances Paid",
"oldfieldtype": "Button",
"options": "get_advances",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -624,7 +665,8 @@
"oldfieldname": "advance_allocation_details",
"oldfieldtype": "Table",
"options": "Purchase Invoice Advance",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -632,7 +674,8 @@
"fieldtype": "Section Break",
"label": "More Info",
"oldfieldtype": "Section Break",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"default": "No",
@@ -646,6 +689,7 @@
"oldfieldtype": "Select",
"options": "No\nYes",
"print_hide": 1,
+ "read_only": 0,
"search_index": 1
},
{
@@ -657,6 +701,7 @@
"oldfieldname": "aging_date",
"oldfieldtype": "Date",
"print_hide": 1,
+ "read_only": 0,
"search_index": 0
},
{
@@ -682,6 +727,7 @@
"oldfieldtype": "Link",
"options": "Print Heading",
"print_hide": 1,
+ "read_only": 0,
"report_hide": 1
},
{
@@ -694,6 +740,7 @@
"oldfieldname": "due_date",
"oldfieldtype": "Date",
"print_hide": 0,
+ "read_only": 0,
"search_index": 1
},
{
@@ -703,12 +750,14 @@
"label": "Mode of Payment",
"oldfieldname": "mode_of_payment",
"oldfieldtype": "Select",
- "options": "link:Mode of Payment"
+ "options": "link:Mode of Payment",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break_63",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -720,6 +769,7 @@
"oldfieldtype": "Link",
"options": "Company",
"print_hide": 1,
+ "read_only": 0,
"search_index": 1
},
{
@@ -732,6 +782,7 @@
"oldfieldtype": "Select",
"options": "link:Fiscal Year",
"print_hide": 1,
+ "read_only": 0,
"search_index": 1
},
{
@@ -755,17 +806,9 @@
"oldfieldname": "remarks",
"oldfieldtype": "Text",
"print_hide": 1,
+ "read_only": 0,
"reqd": 0
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"amend": 1,
"cancel": 1,
@@ -776,8 +819,40 @@
"write": 1
},
{
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "doctype": "DocPerm",
+ "role": "Purchase User",
+ "submit": 0,
+ "write": 1
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
"doctype": "DocPerm",
"match": "supplier",
- "role": "Supplier"
+ "role": "Supplier",
+ "submit": 0,
+ "write": 0
+ },
+ {
+ "amend": 1,
+ "cancel": 1,
+ "create": 1,
+ "doctype": "DocPerm",
+ "role": "Accounts Manager",
+ "submit": 1,
+ "write": 1
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "role": "Auditor",
+ "submit": 0,
+ "write": 0
}
]
\ No newline at end of file
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice_list.js b/accounts/doctype/purchase_invoice/purchase_invoice_list.js
index a3f667f2126..7b410a3085c 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice_list.js
+++ b/accounts/doctype/purchase_invoice/purchase_invoice_list.js
@@ -1,9 +1,9 @@
// render
wn.listview_settings['Purchase Invoice'] = {
add_fields: ["`tabPurchase Invoice`.grand_total", "`tabPurchase Invoice`.outstanding_amount"],
- add_columns: [{"content":"outstanding_amount", width:"10%", type:"bar-graph", label: "Paid"}],
+ add_columns: [{"content":"paid_amount", width:"10%", type:"bar-graph", label: "Paid"}],
prepare_data: function(data) {
- data.outstanding_amount = ((flt(data.grand_total) -
- flt(data.outstanding_amount)) / flt(data.grand_total)) * 100;
+ data.paid_amount = flt(data.grand_total) ? (((flt(data.grand_total) -
+ flt(data.outstanding_amount)) / flt(data.grand_total)) * 100) : 0;
}
};
diff --git a/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 621604b96b6..a70c932d9b2 100644
--- a/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -72,7 +72,38 @@ class TestPurchaseInvoice(unittest.TestCase):
["Stock Received But Not Billed - _TC", 750.0, 0],
["_Test Account Shipping Charges - _TC", 100.0, 0],
["_Test Account VAT - _TC", 120.0, 0],
- ["Expenses Included In Valuation - _TC", 0, 250.0]
+ ["Expenses Included In Valuation - _TC", 0, 250.0],
+ ])
+
+ for i, gle in enumerate(gl_entries):
+ self.assertEquals(expected_values[i][0], gle.account)
+ self.assertEquals(expected_values[i][1], gle.debit)
+ self.assertEquals(expected_values[i][2], gle.credit)
+
+ webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
+
+ def test_gl_entries_with_aia_for_non_stock_items(self):
+ webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
+ self.assertEqual(cint(webnotes.defaults.get_global_default("auto_inventory_accounting")), 1)
+
+ pi = webnotes.bean(copy=test_records[1])
+ pi.doclist[1].item_code = "_Test Non Stock Item"
+ pi.doclist[1].expense_head = "_Test Account Cost for Goods Sold - _TC"
+ pi.doclist.pop(2)
+ pi.doclist.pop(3)
+ pi.run_method("calculate_taxes_and_totals")
+ pi.insert()
+ pi.submit()
+
+ gl_entries = webnotes.conn.sql("""select account, debit, credit
+ from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
+ order by account asc""", pi.doc.name, as_dict=1)
+ self.assertTrue(gl_entries)
+
+ expected_values = sorted([
+ ["_Test Supplier - _TC", 0, 620],
+ ["_Test Account Cost for Goods Sold - _TC", 500.0, 0],
+ ["_Test Account VAT - _TC", 120.0, 0],
])
for i, gle in enumerate(gl_entries):
@@ -106,7 +137,6 @@ class TestPurchaseInvoice(unittest.TestCase):
self.assertEqual(tax.account_head, expected_values[i][0])
self.assertEqual(tax.tax_amount, expected_values[i][1])
self.assertEqual(tax.total, expected_values[i][2])
- # print tax.account_head, tax.tax_amount, tax.item_wise_tax_detail
expected_values = [
["_Test Item Home Desktop 100", 90, 59],
@@ -142,7 +172,6 @@ class TestPurchaseInvoice(unittest.TestCase):
self.assertEqual(tax.account_head, expected_values[i][0])
self.assertEqual(tax.tax_amount, expected_values[i][1])
self.assertEqual(tax.total, expected_values[i][2])
- # print tax.account_head, tax.tax_amount, tax.item_wise_tax_detail
expected_values = [
["_Test FG Item", 90, 7059],
diff --git a/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt b/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt
index e33ab7c5698..8df4306f57b 100755
--- a/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt
+++ b/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-04-10 08:35:38",
+ "creation": "2013-04-19 11:00:07",
"docstatus": 0,
- "modified": "2013-04-17 14:05:20",
+ "modified": "2013-05-22 12:01:56",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -224,6 +224,7 @@
"fieldtype": "Link",
"in_filter": 1,
"label": "Pur Order",
+ "no_copy": 1,
"oldfieldname": "purchase_order",
"oldfieldtype": "Link",
"options": "Purchase Order",
@@ -238,6 +239,7 @@
"hidden": 1,
"in_filter": 1,
"label": "Purchase Order Item",
+ "no_copy": 1,
"oldfieldname": "po_detail",
"oldfieldtype": "Data",
"print_hide": 1,
@@ -250,6 +252,7 @@
"fieldtype": "Link",
"in_filter": 1,
"label": "Pur Receipt",
+ "no_copy": 1,
"oldfieldname": "purchase_receipt",
"oldfieldtype": "Link",
"options": "Purchase Receipt",
@@ -264,6 +267,7 @@
"hidden": 1,
"in_filter": 1,
"label": "PR Detail",
+ "no_copy": 1,
"oldfieldname": "pr_detail",
"oldfieldtype": "Data",
"print_hide": 1,
diff --git a/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt b/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt
index 576730779ae..619aed1954c 100644
--- a/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt
+++ b/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-26 06:51:12",
+ "creation": "2013-04-19 11:00:06",
"docstatus": 0,
- "modified": "2013-04-17 14:05:19",
+ "modified": "2013-05-07 11:23:56",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -35,6 +35,7 @@
"oldfieldname": "category",
"oldfieldtype": "Select",
"options": "Valuation and Total\nValuation\nTotal",
+ "read_only": 0,
"reqd": 1
},
{
@@ -45,6 +46,7 @@
"oldfieldname": "charge_type",
"oldfieldtype": "Select",
"options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total",
+ "read_only": 0,
"reqd": 1
},
{
@@ -55,6 +57,7 @@
"oldfieldname": "account_head",
"oldfieldtype": "Link",
"options": "Account",
+ "read_only": 0,
"reqd": 1
},
{
@@ -65,7 +68,8 @@
"label": "Cost Center",
"oldfieldname": "cost_center",
"oldfieldtype": "Link",
- "options": "Cost Center"
+ "options": "Cost Center",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -75,17 +79,18 @@
"oldfieldname": "description",
"oldfieldtype": "Small Text",
"print_width": "300px",
+ "read_only": 0,
"reqd": 1,
"width": "300px"
},
{
"doctype": "DocField",
"fieldname": "rate",
- "fieldtype": "Currency",
+ "fieldtype": "Float",
"label": "Rate",
"oldfieldname": "rate",
"oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
+ "read_only": 0,
"reqd": 0
},
{
@@ -96,6 +101,7 @@
"oldfieldname": "tax_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
+ "read_only": 0,
"reqd": 0
},
{
@@ -115,7 +121,8 @@
"hidden": 0,
"label": "Enter Row",
"oldfieldname": "row_id",
- "oldfieldtype": "Data"
+ "oldfieldtype": "Data",
+ "read_only": 0
},
{
"default": "Add",
@@ -126,6 +133,7 @@
"oldfieldname": "add_deduct_tax",
"oldfieldtype": "Select",
"options": "Add\nDeduct",
+ "read_only": 0,
"reqd": 1
},
{
@@ -149,6 +157,7 @@
"oldfieldname": "parenttype",
"oldfieldtype": "Data",
"print_hide": 1,
+ "read_only": 0,
"search_index": 0
},
{
@@ -163,6 +172,7 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
+ "read_only": 0,
"report_hide": 1
},
{
@@ -177,6 +187,7 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
+ "read_only": 0,
"report_hide": 1
}
]
\ No newline at end of file
diff --git a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
index 53588e06295..f04f895baf2 100644
--- a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
+++ b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
@@ -147,7 +147,7 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) {
d.account_head = '';
}
else if(d.account_head && d.charge_type) {
- arg = "{'charge_type' : '" + d.charge_type +"', 'account_head' : '" + d.account_head + "'}";
+ arg = "{'charge_type' : '" + d.charge_type + "', 'account_head' : '" + d.account_head + "'}";
get_server_fields('get_rate', arg, 'purchase_tax_details', doc, cdt, cdn, 1);
}
refresh_field('account_head',d.name,'purchase_tax_details');
diff --git a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py
index 1250db5c283..995415e29a9 100644
--- a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py
+++ b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py
@@ -26,11 +26,11 @@ sql = webnotes.conn.sql
class DocType:
- def __init__(self, doc, doclist=[]):
- self.doc = doc
- self.doclist = doclist
+ def __init__(self, doc, doclist=[]):
+ self.doc = doc
+ self.doclist = doclist
- # Get Tax Rate if account type is Tax
- # ===================================================================
- def get_rate(self, arg):
- return get_obj('Purchase Common').get_rate(arg, self)
\ No newline at end of file
+ # Get Tax Rate if account type is Tax
+ # ===================================================================
+ def get_rate(self, arg):
+ return get_obj('Purchase Common').get_rate(arg, self)
\ No newline at end of file
diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index 2d5abd7133d..f5301c1f1ed 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -159,7 +159,6 @@ cur_frm.cscript.update_stock = function(doc, dt, dn) {
cur_frm.cscript.hide_fields(doc, dt, dn);
}
-
cur_frm.cscript.warehouse = function(doc, cdt , cdn) {
var d = locals[cdt][cdn];
if (!d.item_code) { msgprint("please enter item code first"); return };
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index f44a787de95..956867d7abc 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -30,7 +30,6 @@ from webnotes import _, msgprint
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
-
from controllers.selling_controller import SellingController
class DocType(SellingController):
@@ -40,12 +39,9 @@ class DocType(SellingController):
self.tname = 'Sales Invoice Item'
self.fname = 'entries'
- def autoname(self):
- self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
-
def validate(self):
super(DocType, self).validate()
-
+ self.fetch_missing_values()
self.validate_posting_time()
self.so_dn_required()
self.validate_proj_cust()
@@ -78,9 +74,11 @@ class DocType(SellingController):
self.set_aging_date()
self.set_against_income_account()
self.validate_c_form()
+ self.validate_rate_with_refdoc()
self.validate_time_logs_are_submitted()
self.validate_recurring_invoice()
+
def on_submit(self):
if cint(self.doc.is_pos) == 1:
if cint(self.doc.update_stock) == 1:
@@ -137,7 +135,27 @@ class DocType(SellingController):
def on_update_after_submit(self):
self.validate_recurring_invoice()
self.convert_to_recurring()
-
+
+ def fetch_missing_values(self):
+ # fetch contact and address details for customer, if they are not mentioned
+ if not (self.doc.contact_person and self.doc.customer_address):
+ for fieldname, val in self.get_default_address_and_contact("customer").items():
+ if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
+ self.doc.fields[fieldname] = val
+
+ # fetch missing item values
+ for item in self.doclist.get({"parentfield": "entries"}):
+ if item.fields.get("item_code"):
+ ret = get_obj('Sales Common').get_item_details(item.fields, self)
+ for fieldname, value in ret.items():
+ if self.meta.get_field(fieldname, parentfield="entries") and \
+ item.fields.get(fieldname) is None:
+ item.fields[fieldname] = value
+
+ # fetch pos details, if they are not fetched
+ if cint(self.doc.is_pos):
+ self.set_pos_fields(for_validate=True)
+
def update_time_log_batch(self, sales_invoice):
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
if d.time_log_batch:
@@ -153,60 +171,42 @@ class DocType(SellingController):
webnotes.msgprint(_("Time Log Batch status must be 'Submitted'") + ":" + d.time_log_batch,
raise_exception=True)
- def set_pos_fields(self):
+ def set_pos_fields(self, for_validate=False):
"""Set retail related fields from pos settings"""
- pos = self.pos_details
-
- if pos:
- val = webnotes.conn.sql("""select name from `tabAccount`
- where name = %s and docstatus != 2""",
- (cstr(self.doc.customer) + " - " + self.get_company_abbr()))
-
- val = val and val[0][0] or ''
- if not val: val = pos[0]['customer_account'] or ''
+ if cint(self.doc.is_pos) != 1:
+ return
+
+ if self.pos_settings:
+ pos = self.pos_settings[0]
+
+ self.doc.conversion_rate = flt(pos.conversion_rate)
if not self.doc.debit_to:
- webnotes.conn.set(self.doc,'debit_to',val)
-
- lst = ['territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name',
- 'price_list_name', 'company', 'select_print_heading', 'cash_bank_account']
+ self.doc.debit_to = self.doc.customer and webnotes.conn.get_value("Account", {
+ "name": self.doc.customer + " - " + self.get_company_abbr(),
+ "docstatus": ["!=", 2]
+ }) or pos.customer_account
- for i in lst:
- self.doc.fields[i] = pos[0][i] or ''
+ for fieldname in ('territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name',
+ 'price_list_name', 'company', 'select_print_heading', 'cash_bank_account'):
+ if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)):
+ self.doc.fields[fieldname] = pos.get(fieldname)
- self.set_pos_item_values()
-
- self.doc.conversion_rate = flt(pos[0]['conversion_rate']) or 0
+ # set pos values in items
+ for item in self.doclist.get({"parentfield": "entries"}):
+ if item.fields.get('item_code'):
+ for fieldname, val in self.apply_pos_settings(item.fields).items():
+ if (not for_validate) or (for_validate and not item.fields.get(fieldname)):
+ item.fields[fieldname] = val
- #fetch terms
- if self.doc.tc_name:
+ # fetch terms
+ if self.doc.tc_name and not self.doc.terms:
self.get_tc_details()
- #fetch charges
- if self.doc.charge:
+ # fetch charges
+ if self.doc.charge and not len(self.doclist.get({"parentfield": "other_charges"})):
self.get_other_charges()
-
- def set_pos_item_values(self):
- """Set default values related to pos for previously created sales invoice."""
- if cint(self.doc.is_pos) == 1:
- dtl = self.pos_details
-
- for d in getlist(self.doclist,'entries'):
- # overwrite if mentioned in item
- item = webnotes.conn.sql("""select default_income_account,
- default_sales_cost_center, default_warehouse, purchase_account
- from tabItem where name = %s""", (d.item_code,), as_dict=1)
-
- d.income_account = (item and item[0]['default_income_account']) \
- or (dtl and dtl[0]['income_account']) or d.income_account
- d.cost_center = (item and item[0]['default_sales_cost_center']) \
- or (dtl and dtl[0]['cost_center']) or d.cost_center
- d.warehouse = (item and item[0]['default_warehouse']) \
- or (dtl and dtl[0]['warehouse']) or d.warehouse
- d.expense_account = (item and item[0].purchase_account) \
- or (dtl and dtl[0].expense_account) or d.expense_account
-
def get_customer_account(self):
"""Get Account Head to which amount needs to be Debited based on Customer"""
if not self.doc.company:
@@ -215,8 +215,9 @@ class DocType(SellingController):
if self.doc.customer:
acc_head = webnotes.conn.sql("""select name from `tabAccount`
where (name = %s or (master_name = %s and master_type = 'customer'))
- and docstatus != 2""",
- (cstr(self.doc.customer) + " - " + self.get_company_abbr(), self.doc.customer))
+ and docstatus != 2 and company = %s""",
+ (cstr(self.doc.customer) + " - " + self.get_company_abbr(),
+ self.doc.customer, self.doc.company))
if acc_head and acc_head[0][0]:
return acc_head[0][0]
@@ -299,60 +300,59 @@ class DocType(SellingController):
args = args and json.loads(args) or {}
if args.get('item_code'):
ret = get_obj('Sales Common').get_item_details(args, self)
- return self.get_pos_details(args, ret)
- else:
- for doc in self.doclist:
+
+ if cint(self.doc.is_pos) == 1 and self.pos_settings:
+ ret = self.apply_pos_settings(args, ret)
+
+ return ret
+
+ elif cint(self.doc.is_pos) == 1 and self.pos_settings:
+ for doc in self.doclist.get({"parentfield": "entries"}):
if doc.fields.get('item_code'):
- arg = {
- 'item_code':doc.fields.get('item_code'),
- 'income_account':doc.fields.get('income_account'),
- 'cost_center': doc.fields.get('cost_center'),
- 'warehouse': doc.fields.get('warehouse'),
- 'expense_account': doc.fields.get('expense_account'),
- }
-
- ret = self.get_pos_details(arg)
+ ret = self.apply_pos_settings(doc.fields)
for r in ret:
if not doc.fields.get(r):
doc.fields[r] = ret[r]
@property
- def pos_details(self):
- if not hasattr(self, "_pos_details"):
+ def pos_settings(self):
+ if not hasattr(self, "_pos_settings"):
dtl = webnotes.conn.sql("""select * from `tabPOS Setting` where user = %s
and company = %s""", (webnotes.session['user'], self.doc.company), as_dict=1)
if not dtl:
dtl = webnotes.conn.sql("""select * from `tabPOS Setting`
where ifnull(user,'') = '' and company = %s""", self.doc.company, as_dict=1)
- self._pos_details = dtl
+ self._pos_settings = dtl
- return self._pos_details
+ return self._pos_settings
- def get_pos_details(self, args, ret = {}):
- if args['item_code'] and cint(self.doc.is_pos) == 1:
- dtl = self.pos_details
-
- item = webnotes.conn.sql("""select default_income_account, default_sales_cost_center,
- default_warehouse, purchase_account from tabItem where name = %s""",
- args['item_code'], as_dict=1)
-
- ret['income_account'] = item and item[0].get('default_income_account') \
- or (dtl and dtl[0].get('income_account') or args.get('income_account'))
-
- ret['cost_center'] = item and item[0].get('default_sales_cost_center') \
- or (dtl and dtl[0].get('cost_center') or args.get('cost_center'))
+ def apply_pos_settings(self, args, ret=None):
+ if not ret: ret = {}
+
+ pos = self.pos_settings[0]
+
+ item = webnotes.conn.sql("""select default_income_account, default_sales_cost_center,
+ default_warehouse, purchase_account from tabItem where name = %s""",
+ args.get('item_code'), as_dict=1)
+
+ if item:
+ item = item[0]
- ret['warehouse'] = item and item[0].get('default_warehouse') \
- or (dtl and dtl[0].get('warehouse') or args.get('warehouse'))
+ ret.update({
+ "income_account": item.get("default_income_account") \
+ or pos.get("income_account") or args.get("income_account"),
+ "cost_center": item.get("default_sales_cost_center") \
+ or pos.get("cost_center") or args.get("cost_center"),
+ "warehouse": item.get("default_warehouse") \
+ or pos.get("warehouse") or args.get("warehouse"),
+ "expense_account": item.get("purchase_account") \
+ or pos.get("expense_account") or args.get("expense_account")
+ })
- ret['expense_account'] = item and item[0].get('purchase_account') \
- or (dtl and dtl[0].get('expense_account') or args.get('expense_account'))
-
- if ret['warehouse']:
- actual_qty = webnotes.conn.sql("""select actual_qty from `tabBin`
- where item_code = %s and warehouse = %s""",
- (args['item_code'], ret['warehouse']))
- ret['actual_qty']= actual_qty and flt(actual_qty[0][0]) or 0
+ if ret.get("warehouse"):
+ ret["actual_qty"] = flt(webnotes.conn.get_value("Bin",
+ {"item_code": args.get("item_code"), "warehouse": ret.get("warehouse")},
+ "actual_qty"))
return ret
def get_barcode_details(self, barcode):
@@ -433,17 +433,6 @@ class DocType(SellingController):
from accounts.utils import reconcile_against_document
reconcile_against_document(lst)
- def validate_customer(self):
- """ Validate customer name with SO and DN"""
- for d in getlist(self.doclist,'entries'):
- dt = d.delivery_note and 'Delivery Note' or d.sales_order and 'Sales Order' or ''
- if dt:
- dt_no = d.delivery_note or d.sales_order
- cust = webnotes.conn.sql("select customer from `tab%s` where name = %s" % (dt, '%s'), dt_no)
- if cust and cstr(cust[0][0]) != cstr(self.doc.customer):
- msgprint("Customer %s does not match with customer of %s: %s." %(self.doc.customer, dt, dt_no), raise_exception=1)
-
-
def validate_customer_account(self):
"""Validates Debit To Account and Customer Matches"""
if self.doc.customer and self.doc.debit_to and not cint(self.doc.is_pos):
@@ -453,6 +442,19 @@ class DocType(SellingController):
(not acc_head and (self.doc.debit_to != cstr(self.doc.customer) + " - " + self.get_company_abbr())):
msgprint("Debit To: %s do not match with Customer: %s for Company: %s.\n If both correctly entered, please select Master Type \
and Master Name in account master." %(self.doc.debit_to, self.doc.customer,self.doc.company), raise_exception=1)
+
+
+ def validate_customer(self):
+ """ Validate customer name with SO and DN"""
+ if self.doc.customer:
+ for d in getlist(self.doclist,'entries'):
+ dt = d.delivery_note and 'Delivery Note' or d.sales_order and 'Sales Order' or ''
+ if dt:
+ dt_no = d.delivery_note or d.sales_order
+ cust = webnotes.conn.get_value(dt, dt_no, "customer")
+ if cust and cstr(cust) != cstr(self.doc.customer):
+ msgprint("Customer %s does not match with customer of %s: %s."
+ %(self.doc.customer, dt, dt_no), raise_exception=1)
def validate_debit_acc(self):
@@ -554,6 +556,21 @@ class DocType(SellingController):
webnotes.conn.set(self.doc, 'c_form_no', '')
+ def validate_rate_with_refdoc(self):
+ """Validate values with reference document with previous document"""
+ for d in self.doclist.get({"parentfield": "entries"}):
+ if d.so_detail:
+ self.check_value("Sales Order", d.sales_order, d.so_detail,
+ d.export_rate, d.item_code)
+ if d.dn_detail:
+ self.check_value("Delivery Note", d.delivery_note, d.dn_detail,
+ d.export_rate, d.item_code)
+
+ def check_value(self, ref_dt, ref_dn, ref_item_dn, val, item_code):
+ ref_val = webnotes.conn.get_value(ref_dt + " Item", ref_item_dn, "export_rate")
+ if flt(ref_val, 2) != flt(val, 2):
+ msgprint(_("Rate is not matching with ") + ref_dt + ": " + ref_dn +
+ _(" for item: ") + item_code, raise_exception=True)
def update_current_stock(self):
for d in getlist(self.doclist, 'entries'):
diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt
index cf6e994c117..a2c422f38a2 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.txt
+++ b/accounts/doctype/sales_invoice/sales_invoice.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-22 18:37:25",
+ "creation": "2013-04-19 11:00:14",
"docstatus": 0,
- "modified": "2013-03-22 18:38:13",
+ "modified": "2013-04-22 11:59:28",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -30,9 +30,7 @@
"parent": "Sales Invoice",
"parentfield": "permissions",
"parenttype": "DocType",
- "permlevel": 0,
- "read": 1,
- "report": 1
+ "read": 1
},
{
"doctype": "DocType",
@@ -44,7 +42,8 @@
"fieldtype": "Section Break",
"label": "Basic Info",
"oldfieldtype": "Section Break",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -52,6 +51,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 0,
+ "read_only": 0,
"width": "50%"
},
{
@@ -65,6 +65,7 @@
"oldfieldtype": "Select",
"options": "INV\nINV/10-11/",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1
},
{
@@ -74,7 +75,8 @@
"label": "Is POS",
"oldfieldname": "is_pos",
"oldfieldtype": "Check",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_pos==1",
@@ -84,7 +86,8 @@
"label": "Update Stock",
"oldfieldname": "update_stock",
"oldfieldtype": "Check",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"description": "The account to which you will pay (have paid) the money to.",
@@ -97,6 +100,7 @@
"oldfieldtype": "Link",
"options": "Account",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1,
"search_index": 1
},
@@ -110,7 +114,8 @@
"oldfieldname": "customer",
"oldfieldtype": "Link",
"options": "Customer",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -160,7 +165,8 @@
"doctype": "DocField",
"fieldname": "column_break1",
"fieldtype": "Column Break",
- "oldfieldtype": "Column Break"
+ "oldfieldtype": "Column Break",
+ "read_only": 0
},
{
"default": "Today",
@@ -174,6 +180,7 @@
"oldfieldname": "posting_date",
"oldfieldtype": "Date",
"print_hide": 0,
+ "read_only": 0,
"reqd": 1,
"search_index": 1
},
@@ -188,6 +195,7 @@
"no_copy": 1,
"oldfieldname": "due_date",
"oldfieldtype": "Date",
+ "read_only": 0,
"reqd": 1,
"search_index": 0
},
@@ -198,14 +206,16 @@
"label": "Mode of Payment",
"oldfieldname": "mode_of_payment",
"oldfieldtype": "Select",
- "options": "link:Mode of Payment"
+ "options": "link:Mode of Payment",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "items",
"fieldtype": "Section Break",
"label": "Items",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"allow_on_submit": 1,
@@ -215,25 +225,29 @@
"label": "Entries",
"oldfieldname": "entries",
"oldfieldtype": "Table",
- "options": "Sales Invoice Item"
+ "options": "Sales Invoice Item",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "sales_bom_help",
"fieldtype": "HTML",
"label": "Sales BOM Help",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "section_break0",
"fieldtype": "Section Break",
- "options": "Simple"
+ "options": "Simple",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break26",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -255,12 +269,14 @@
"fieldtype": "Button",
"label": "Re-Calculate Values",
"oldfieldtype": "Button",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break25",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -272,7 +288,8 @@
"oldfieldname": "sales_order_main",
"oldfieldtype": "Link",
"options": "Sales Order",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"description": "Select Items from Delivery Note",
@@ -283,7 +300,8 @@
"oldfieldname": "delivery_note_main",
"oldfieldtype": "Link",
"options": "Delivery Note",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -291,18 +309,21 @@
"fieldtype": "Button",
"label": "Get Items",
"oldfieldtype": "Button",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "currency_section",
"fieldtype": "Section Break",
- "label": "Price List and Currency"
+ "label": "Price List and Currency",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break27",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -314,6 +335,7 @@
"oldfieldtype": "Select",
"options": "link:Price List",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1
},
{
@@ -324,6 +346,7 @@
"label": "Price List Currency",
"options": "Currency",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1
},
{
@@ -333,12 +356,14 @@
"fieldtype": "Float",
"label": "Price List Currency Conversion Rate",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "column_break2",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -350,6 +375,7 @@
"oldfieldtype": "Select",
"options": "Currency",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1
},
{
@@ -362,6 +388,7 @@
"oldfieldname": "conversion_rate",
"oldfieldtype": "Currency",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1
},
{
@@ -369,7 +396,8 @@
"fieldname": "taxes",
"fieldtype": "Section Break",
"label": "Taxes and Charges",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -379,7 +407,8 @@
"oldfieldname": "charge",
"oldfieldtype": "Link",
"options": "Sales Taxes and Charges Master",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -387,7 +416,8 @@
"fieldtype": "Button",
"label": "Get Taxes and Charges",
"oldfieldtype": "Button",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"allow_on_submit": 1,
@@ -397,7 +427,8 @@
"label": "Taxes and Charges1",
"oldfieldname": "other_charges",
"oldfieldtype": "Table",
- "options": "Sales Taxes and Charges"
+ "options": "Sales Taxes and Charges",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -405,7 +436,8 @@
"fieldtype": "Button",
"label": "Calculate Taxes and Charges",
"oldfieldtype": "Button",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -424,7 +456,8 @@
"fieldtype": "HTML",
"label": "Taxes and Charges Calculation",
"oldfieldtype": "HTML",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -432,7 +465,8 @@
"fieldtype": "Section Break",
"label": "Totals",
"oldfieldtype": "Section Break",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -440,6 +474,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
+ "read_only": 0,
"width": "50%"
},
{
@@ -508,6 +543,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
+ "read_only": 0,
"width": "50%"
},
{
@@ -569,12 +605,14 @@
"doctype": "DocField",
"fieldname": "payments_section",
"fieldtype": "Section Break",
- "label": "Payments"
+ "label": "Payments",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break3",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -585,7 +623,8 @@
"oldfieldname": "paid_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -595,12 +634,14 @@
"oldfieldname": "cash_bank_account",
"oldfieldtype": "Link",
"options": "Account",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break4",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -608,7 +649,8 @@
"fieldname": "write_off_outstanding_amount_automatically",
"fieldtype": "Check",
"label": "Write Off Outstanding Amount",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -616,7 +658,8 @@
"fieldtype": "Currency",
"label": "Write Off Amount",
"options": "Company:company:default_currency",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -624,7 +667,8 @@
"fieldtype": "Link",
"label": "Write Off Account",
"options": "Account",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -632,14 +676,16 @@
"fieldtype": "Link",
"label": "Write Off Cost Center",
"options": "Cost Center",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "terms_section_break",
"fieldtype": "Section Break",
"label": "Terms and Conditions",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -649,7 +695,8 @@
"oldfieldname": "tc_name",
"oldfieldtype": "Link",
"options": "Terms and Conditions",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -658,7 +705,8 @@
"label": "Get Terms and Conditions",
"oldfieldtype": "Button",
"options": "get_tc_details",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -667,7 +715,8 @@
"label": "Terms and Conditions HTML",
"oldfieldtype": "HTML",
"options": "You can add Terms and Notes that will be printed in the Transaction",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -675,18 +724,21 @@
"fieldtype": "Text Editor",
"label": "Terms and Conditions Details",
"oldfieldname": "terms",
- "oldfieldtype": "Text Editor"
+ "oldfieldtype": "Text Editor",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "contact_section",
"fieldtype": "Section Break",
- "label": "Contact Info"
+ "label": "Contact Info",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break23",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -695,7 +747,8 @@
"fieldtype": "Link",
"label": "Customer Address",
"options": "Address",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -703,12 +756,14 @@
"fieldtype": "Link",
"label": "Contact Person",
"options": "Contact",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break24",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -719,6 +774,7 @@
"label": "Territory",
"options": "Territory",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1,
"search_index": 0
},
@@ -730,6 +786,7 @@
"label": "Customer Group",
"options": "Customer Group",
"print_hide": 1,
+ "read_only": 0,
"search_index": 0
},
{
@@ -738,7 +795,8 @@
"fieldtype": "Section Break",
"label": "More Info",
"oldfieldtype": "Section Break",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -746,6 +804,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
+ "read_only": 0,
"width": "50%"
},
{
@@ -760,6 +819,7 @@
"oldfieldtype": "Select",
"options": "No\nYes",
"print_hide": 1,
+ "read_only": 0,
"search_index": 0
},
{
@@ -770,7 +830,8 @@
"label": "Aging Date",
"oldfieldname": "aging_date",
"oldfieldtype": "Date",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -780,7 +841,8 @@
"no_copy": 1,
"oldfieldname": "posting_time",
"oldfieldtype": "Time",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"allow_on_submit": 1,
@@ -791,7 +853,8 @@
"oldfieldname": "letter_head",
"oldfieldtype": "Select",
"options": "link:Letter Head",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -801,6 +864,7 @@
"no_copy": 1,
"options": "No\nYes",
"print_hide": 1,
+ "read_only": 0,
"report_hide": 0
},
{
@@ -822,7 +886,8 @@
"oldfieldname": "campaign",
"oldfieldtype": "Link",
"options": "Campaign",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"description": "Track this Sales Invoice against any Project",
@@ -834,6 +899,7 @@
"oldfieldname": "project_name",
"oldfieldtype": "Link",
"options": "Project",
+ "read_only": 0,
"search_index": 1
},
{
@@ -847,6 +913,7 @@
"oldfieldtype": "Link",
"options": "Print Heading",
"print_hide": 1,
+ "read_only": 0,
"report_hide": 1
},
{
@@ -854,7 +921,8 @@
"fieldname": "column_break8",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -864,7 +932,8 @@
"oldfieldname": "source",
"oldfieldtype": "Select",
"options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -876,6 +945,7 @@
"oldfieldtype": "Link",
"options": "Company",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1,
"search_index": 0
},
@@ -890,6 +960,7 @@
"oldfieldtype": "Select",
"options": "link:Fiscal Year",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1,
"search_index": 0
},
@@ -914,7 +985,8 @@
"no_copy": 1,
"oldfieldname": "amendment_date",
"oldfieldtype": "Date",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"depends_on": "eval:!doc.__islocal",
@@ -936,6 +1008,7 @@
"oldfieldname": "remarks",
"oldfieldtype": "Text",
"print_hide": 1,
+ "read_only": 0,
"reqd": 0
},
{
@@ -944,7 +1017,8 @@
"fieldtype": "Section Break",
"label": "Advances",
"oldfieldtype": "Section Break",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -953,7 +1027,8 @@
"label": "Get Advances Received",
"oldfieldtype": "Button",
"options": "get_advances",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -963,14 +1038,16 @@
"oldfieldname": "advance_adjustment_details",
"oldfieldtype": "Table",
"options": "Sales Invoice Advance",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "packing_list",
"fieldtype": "Section Break",
"label": "Packing List",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -978,7 +1055,8 @@
"fieldtype": "Table",
"label": "Packing Details",
"options": "Delivery Note Packing Item",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -986,7 +1064,8 @@
"fieldtype": "Section Break",
"label": "Sales Team",
"oldfieldtype": "Section Break",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -994,6 +1073,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
+ "read_only": 0,
"width": "50%"
},
{
@@ -1005,7 +1085,8 @@
"oldfieldname": "sales_partner",
"oldfieldtype": "Link",
"options": "Sales Partner",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -1013,6 +1094,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
+ "read_only": 0,
"width": "50%"
},
{
@@ -1022,7 +1104,8 @@
"label": "Commission Rate (%)",
"oldfieldname": "commission_rate",
"oldfieldtype": "Currency",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -1032,14 +1115,16 @@
"oldfieldname": "total_commission",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "section_break2",
"fieldtype": "Section Break",
"options": "Simple",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -1049,7 +1134,8 @@
"oldfieldname": "sales_team",
"oldfieldtype": "Table",
"options": "Sales Team",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"depends_on": "eval:doc.docstatus<2",
@@ -1057,13 +1143,15 @@
"fieldname": "recurring_invoice",
"fieldtype": "Section Break",
"label": "Recurring Invoice",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break11",
"fieldtype": "Column Break",
"print_hide": 1,
+ "read_only": 0,
"width": "50%"
},
{
@@ -1075,7 +1163,8 @@
"fieldtype": "Check",
"label": "Convert into Recurring Invoice",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"allow_on_submit": 1,
@@ -1087,7 +1176,8 @@
"label": "Recurring Type",
"no_copy": 1,
"options": "Monthly\nQuarterly\nHalf-yearly\nYearly",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"allow_on_submit": 1,
@@ -1098,7 +1188,8 @@
"fieldtype": "Int",
"label": "Repeat on Day of Month",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"allow_on_submit": 1,
@@ -1109,7 +1200,8 @@
"fieldtype": "Date",
"label": "Invoice Period From Date",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"allow_on_submit": 1,
@@ -1120,7 +1212,8 @@
"fieldtype": "Date",
"label": "Invoice Period To Date",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -1128,6 +1221,7 @@
"fieldtype": "Column Break",
"no_copy": 0,
"print_hide": 1,
+ "read_only": 0,
"width": "50%"
},
{
@@ -1139,7 +1233,8 @@
"fieldtype": "Small Text",
"label": "Notification Email Address",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"depends_on": "eval:doc.convert_into_recurring_invoice==1",
@@ -1172,7 +1267,8 @@
"fieldtype": "Date",
"label": "End Date",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -1184,22 +1280,16 @@
"oldfieldname": "against_income_account",
"oldfieldtype": "Small Text",
"print_hide": 1,
+ "read_only": 0,
"report_hide": 1
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
+ "permlevel": 0,
+ "report": 1,
"role": "Accounts User",
"submit": 1,
"write": 1
@@ -1207,6 +1297,8 @@
{
"doctype": "DocPerm",
"match": "customer",
+ "permlevel": 0,
+ "report": 1,
"role": "Customer"
- }
+ },
]
\ No newline at end of file
diff --git a/accounts/doctype/sales_invoice/sales_invoice_list.js b/accounts/doctype/sales_invoice/sales_invoice_list.js
index c1f80616659..e83611aff05 100644
--- a/accounts/doctype/sales_invoice/sales_invoice_list.js
+++ b/accounts/doctype/sales_invoice/sales_invoice_list.js
@@ -1,9 +1,10 @@
// render
wn.listview_settings['Sales Invoice'] = {
add_fields: ["`tabSales Invoice`.grand_total", "`tabSales Invoice`.outstanding_amount"],
- add_columns: [{"content":"outstanding_amount", width:"10%", type:"bar-graph"}],
+ add_columns: [{"content":"paid_amount", width:"10%", type:"bar-graph",
+ label: "Payment Received"}],
prepare_data: function(data) {
- data.outstanding_amount = (flt(data.grand_total) -
- flt(data.outstanding_amount)) / flt(data.grand_total) * 100;
+ data.paid_amount = flt(data.grand_total) ? (((flt(data.grand_total) -
+ flt(data.outstanding_amount)) / flt(data.grand_total)) * 100) : 0;
}
};
diff --git a/accounts/doctype/sales_invoice/test_sales_invoice.py b/accounts/doctype/sales_invoice/test_sales_invoice.py
index fd8dc648d24..b46cdd17770 100644
--- a/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -90,6 +90,9 @@ class TestSalesInvoice(unittest.TestCase):
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
+ old_default_company = webnotes.conn.get_default("company")
+ webnotes.conn.set_default("company", "_Test Company")
+
self._insert_purchase_receipt()
self._insert_pos_settings()
@@ -106,7 +109,8 @@ class TestSalesInvoice(unittest.TestCase):
# check stock ledger entries
sle = webnotes.conn.sql("""select * from `tabStock Ledger Entry`
- where voucher_type = 'Sales Invoice' and voucher_no = %s""", si.doc.name, as_dict=1)[0]
+ where voucher_type = 'Sales Invoice' and voucher_no = %s""",
+ si.doc.name, as_dict=1)[0]
self.assertTrue(sle)
self.assertEquals([sle.item_code, sle.warehouse, sle.actual_qty],
["_Test Item", "_Test Warehouse", -5.0])
@@ -145,6 +149,7 @@ class TestSalesInvoice(unittest.TestCase):
self.assertEquals(gl_count[0][0], 16)
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
+ webnotes.conn.set_default("company", old_default_company)
def test_sales_invoice_gl_entry_with_aii_no_item_code(self):
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
@@ -337,7 +342,7 @@ class TestSalesInvoice(unittest.TestCase):
# change posting date but keep recuring day to be today
si7 = webnotes.bean(copy=base_si.doclist)
si7.doc.fields.update({
- "posting_date": add_to_date(today, days=-3)
+ "posting_date": add_to_date(today, days=-1)
})
si7.insert()
si7.submit()
@@ -345,7 +350,7 @@ class TestSalesInvoice(unittest.TestCase):
# setting so that _test function works
si7.doc.posting_date = today
self._test_recurring_invoice(si7, True)
-
+
def _test_recurring_invoice(self, base_si, first_and_last_day):
from webnotes.utils import add_months, get_last_day, getdate
from accounts.doctype.sales_invoice.sales_invoice import manage_recurring_invoices
@@ -361,7 +366,8 @@ class TestSalesInvoice(unittest.TestCase):
manage_recurring_invoices(next_date=next_date, commit=False)
recurred_invoices = webnotes.conn.sql("""select name from `tabSales Invoice`
- where recurring_id=%s and docstatus=1 order by name desc""", base_si.doc.recurring_id)
+ where recurring_id=%s and docstatus=1 order by name desc""",
+ base_si.doc.recurring_id)
self.assertEquals(i+2, len(recurred_invoices))
@@ -395,7 +401,7 @@ class TestSalesInvoice(unittest.TestCase):
for i in xrange(count):
base_si = _test(i)
-test_dependencies = ["Journal Voucher", "POS Setting"]
+test_dependencies = ["Journal Voucher", "POS Setting", "Contact", "Address"]
test_records = [
[
diff --git a/accounts/doctype/sales_invoice_item/sales_invoice_item.txt b/accounts/doctype/sales_invoice_item/sales_invoice_item.txt
index 2a6384d7629..82ad3b15272 100644
--- a/accounts/doctype/sales_invoice_item/sales_invoice_item.txt
+++ b/accounts/doctype/sales_invoice_item/sales_invoice_item.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-04-10 08:35:44",
+ "creation": "2013-06-04 11:02:19",
"docstatus": 0,
- "modified": "2013-04-17 14:05:20",
+ "modified": "2013-06-26 14:33:21",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -243,7 +243,8 @@
"oldfieldname": "serial_no",
"oldfieldtype": "Small Text",
"print_hide": 0,
- "read_only": 0
+ "read_only": 0,
+ "reqd": 0
},
{
"doctype": "DocField",
@@ -305,6 +306,7 @@
"fieldtype": "Link",
"in_filter": 1,
"label": "Sales Order",
+ "no_copy": 1,
"oldfieldname": "sales_order",
"oldfieldtype": "Link",
"options": "Sales Order",
@@ -319,6 +321,7 @@
"hidden": 1,
"in_filter": 1,
"label": "SO Detail ",
+ "no_copy": 1,
"oldfieldname": "so_detail",
"oldfieldtype": "Data",
"print_hide": 1,
@@ -331,6 +334,7 @@
"fieldtype": "Link",
"in_filter": 1,
"label": "Delivery Note",
+ "no_copy": 1,
"oldfieldname": "delivery_note",
"oldfieldtype": "Link",
"options": "Delivery Note",
@@ -345,6 +349,7 @@
"hidden": 1,
"in_filter": 1,
"label": "DN Detail",
+ "no_copy": 1,
"oldfieldname": "dn_detail",
"oldfieldtype": "Data",
"print_hide": 1,
diff --git a/accounts/page/accounts_browser/accounts_browser.js b/accounts/page/accounts_browser/accounts_browser.js
index 2e8cc820a6e..3541fcbf1f7 100644
--- a/accounts/page/accounts_browser/accounts_browser.js
+++ b/accounts/page/accounts_browser/accounts_browser.js
@@ -131,7 +131,7 @@ erpnext.AccountsChart = Class.extend({
if (wn.model.can_read(this.ctype) !== -1) {
node_links.push('Edit');
}
- if (data.expandable) {
+ if (data.expandable && wn.boot.profile.in_create.indexOf(this.ctype) !== -1) {
node_links.push('Add Child');
} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
node_links.push('View Ledger');
diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js
index 9981ee9a974..31660eb9042 100644
--- a/accounts/page/accounts_home/accounts_home.js
+++ b/accounts/page/accounts_home/accounts_home.js
@@ -139,6 +139,26 @@ wn.module_page["Accounts"] = [
"page":"Financial Statements",
"label": wn._("Financial Statements")
},
+ {
+ "label":wn._("Accounts Receivable"),
+ route: "query-report/Accounts Receivable",
+ doctype: "Sales Invoice"
+ },
+ {
+ "label":wn._("Accounts Payable"),
+ route: "query-report/Accounts Payable",
+ doctype: "Purchase Invoice"
+ },
+ {
+ "label":wn._("Sales Register"),
+ route: "query-report/Sales Register",
+ doctype: "Sales Invoice"
+ },
+ {
+ "label":wn._("Purchase Register"),
+ route: "query-report/Purchase Register",
+ doctype: "Purchase Invoice"
+ },
]
},
{
@@ -150,11 +170,6 @@ wn.module_page["Accounts"] = [
"label":wn._("Financial Analytics"),
page: "financial-analytics"
},
- {
- "label":wn._("Trend Analyzer"),
- route: "Report/Profile/Trend Analyzer",
- doctype: "Sales Invoice"
- },
{
"label":wn._("Gross Profit"),
route: "query-report/Gross Profit",
@@ -167,16 +182,86 @@ wn.module_page["Accounts"] = [
right: true,
icon: "icon-list",
items: [
+ {
+ "label":wn._("Bank Reconciliation Statement"),
+ route: "query-report/Bank Reconciliation Statement",
+ doctype: "Journal Voucher"
+ },
{
"label":wn._("Delivered Items To Be Billed"),
route: "query-report/Delivered Items To Be Billed",
doctype: "Sales Invoice"
},
+ {
+ "label":wn._("Received Items To Be Billed"),
+ route: "query-report/Received Items To Be Billed",
+ doctype: "Purchase Invoice"
+ },
{
"label":wn._("Ordered Items To Be Billed"),
route: "query-report/Ordered Items To Be Billed",
doctype: "Sales Invoice"
},
+ {
+ "label":wn._("Purchase Order Items To Be Billed"),
+ route: "query-report/Purchase Order Items To Be Billed",
+ doctype: "Purchase Invoice"
+ },
+ {
+ "label":wn._("Bank Clearance Summary"),
+ route: "query-report/Bank Clearance Summary",
+ doctype: "Journal Voucher"
+ },
+ {
+ "label":wn._("Payment Collection With Ageing"),
+ route: "query-report/Payment Collection With Ageing",
+ doctype: "Journal Voucher"
+ },
+ {
+ "label":wn._("Payment Made With Ageing"),
+ route: "query-report/Payment Made With Ageing",
+ doctype: "Journal Voucher"
+ },
+ {
+ "label":wn._("Sales Partners Commission"),
+ route: "query-report/Sales Partners Commission",
+ doctype: "Sales Invoice"
+ },
+ {
+ "label":wn._("Customer Account Head"),
+ route: "query-report/Customer Account Head",
+ doctype: "Account"
+ },
+ {
+ "label":wn._("Supplier Account Head"),
+ route: "query-report/Supplier Account Head",
+ doctype: "Account"
+ },
+ {
+ "label":wn._("Item-wise Sales Register"),
+ route: "query-report/Item-wise Sales Register",
+ doctype: "Sales Invoice"
+ },
+ {
+ "label":wn._("Item-wise Purchase Register"),
+ route: "query-report/Item-wise Purchase Register",
+ doctype: "Purchase Invoice"
+ },
+ {
+ "label":wn._("Budget Variance Report"),
+ route: "query-report/Budget Variance Report",
+ doctype: "Cost Center"
+ },
+ {
+ "label":wn._("Purchase Invoice Trends"),
+ route: "query-report/Purchase Invoice Trends",
+ doctype: "Purchase Invoice"
+ },
+ {
+ "label":wn._("Sales Invoice Trends"),
+ route: "query-report/Sales Invoice Trends",
+ doctype: "Sales Invoice"
+ },
]
}
]
diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js
index 21be3a05dd7..269ed5e3f23 100644
--- a/accounts/page/general_ledger/general_ledger.js
+++ b/accounts/page/general_ledger/general_ledger.js
@@ -68,6 +68,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
];
},
+
filters: [
{fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
filter: function(val, item, opts) {
@@ -96,6 +97,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
}},
{fieldtype: "Check", label: "Group by Ledger"},
+ {fieldtype: "Check", label: "Group by Voucher"},
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: "Reset Filters"}
],
@@ -116,9 +118,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
me.filter_inputs.group_by_ledger
.parent().toggle(!!(me.account_by_name[$(this).val()]
&& me.account_by_name[$(this).val()].group_or_ledger==="Group"));
+
+ me.filter_inputs.group_by_voucher
+ .parent().toggle(!!(me.account_by_name[$(this).val()]
+ && me.account_by_name[$(this).val()].group_or_ledger==="Ledger"));
});
this.trigger_refresh_on_change(["group_by_ledger"]);
+ this.trigger_refresh_on_change(["group_by_voucher"]);
},
setup_account_filter: function(company_filter) {
var me = this;
@@ -139,12 +146,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
init_filter_values: function() {
this._super();
this.filter_inputs.group_by_ledger.parent().toggle(false);
+ this.filter_inputs.group_by_voucher.parent().toggle(false);
this.filter_inputs.company.change();
this.filter_inputs.account.change();
},
apply_filters_from_route: function() {
this._super();
this.filter_inputs.group_by_ledger.parent().toggle(false);
+ this.filter_inputs.group_by_voucher.parent().toggle(false);
this.filter_inputs.company.change();
this.filter_inputs.account.change();
},
@@ -186,7 +195,6 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
var totals = this.make_summary_row("Totals", this.account);
var grouped_ledgers = {};
-
$.each(data, function(i, item) {
if((me.is_default("company") ? true : me.apply_filter(item, "company")) &&
(me.account ? me.is_child_account(me.account, item.account)
@@ -197,13 +205,21 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
if(!grouped_ledgers[item.account]) {
grouped_ledgers[item.account] = {
entries: [],
+ entries_group_by_voucher: {},
opening: me.make_summary_row("Opening", item.account),
totals: me.make_summary_row("Totals", item.account),
closing: me.make_summary_row("Closing (Opening + Totals)",
item.account)
};
}
-
+
+ if(!grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]) {
+ grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] = {
+ row: {},
+ totals: {"debit": 0, "credit": 0}
+ }
+ }
+
if(date < from_date || item.is_opening=="Yes") {
opening.debit += item.debit;
opening.credit += item.credit;
@@ -216,9 +232,12 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
grouped_ledgers[item.account].totals.debit += item.debit;
grouped_ledgers[item.account].totals.credit += item.credit;
+ grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
+ .totals.debit += item.debit;
+ grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
+ .totals.credit += item.credit;
}
-
- if(me.account) {
+ if(item.account) {
item.against_account = me.voucher_accounts[item.voucher_type + ":"
+ item.voucher_no][(item.debit > 0 ? "credits" : "debits")].join(", ");
}
@@ -226,6 +245,11 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
if(me.apply_filters(item) && item.is_opening=="No") {
out.push(item);
grouped_ledgers[item.account].entries.push(item);
+
+ if(grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no].row){
+ grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
+ .row = jQuery.extend({}, item);
+ }
}
}
});
@@ -243,6 +267,11 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
out = this.group_data_by_ledger(grouped_ledgers);
}
+ if(this.account_by_name[this.account].group_or_ledger==="Ledger"
+ && this.group_by_voucher) {
+ out = this.group_data_by_voucher(grouped_ledgers);
+ }
+
opening = me.get_balance(me.account_by_name[me.account].debit_or_credit, opening)
closing = me.get_balance(me.account_by_name[me.account].debit_or_credit, closing)
@@ -285,6 +314,27 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
},
+ group_data_by_voucher: function(grouped_ledgers) {
+ var me = this;
+ var out = []
+ $.each(Object.keys(grouped_ledgers).sort(), function(i, account) {
+ if(grouped_ledgers[account].entries.length) {
+ $.each(Object.keys(grouped_ledgers[account].entries_group_by_voucher),
+ function(j, voucher) {
+ voucher_dict = grouped_ledgers[account].entries_group_by_voucher[voucher];
+ if(voucher_dict &&
+ (voucher_dict.totals.debit || voucher_dict.totals.credit)) {
+ voucher_dict.row.debit = voucher_dict.totals.debit;
+ voucher_dict.row.credit = voucher_dict.totals.credit;
+ voucher_dict.row.id = "entry_grouped_by_" + voucher
+ out = out.concat(voucher_dict.row);
+ }
+ });
+ }
+ });
+ return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
+ },
+
get_balance: function(debit_or_credit, balance) {
if(debit_or_credit == "Debit") {
balance.debit -= balance.credit; balance.credit = 0;
diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py
index 6648ee6f8e2..a3790a8fe16 100644
--- a/accounts/page/voucher_import_tool/voucher_import_tool.py
+++ b/accounts/page/voucher_import_tool/voucher_import_tool.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes import _
-from webnotes.utils import flt, comma_and
+from webnotes.utils import flt, comma_and, cstr
import webnotes.defaults
@webnotes.whitelist()
@@ -31,13 +31,12 @@ def get_template():
"3. Naming Series Options: %(naming_options)s"
"4. Voucher Type Options: %(voucher_type)s"%(extra_note)s
"-------Common Values-----------"
-"Company:","%(default_company)s"
+"Company:",
"--------Data----------"
%(columns)s
''' % {
"template_type": template_type,
"user_fmt": webnotes.defaults.get_global_default('date_format'),
- "default_company": webnotes.conn.get_default("company"),
"naming_options": naming_options.replace("\n", ", "),
"voucher_type": voucher_type.replace("\n", ", "),
"extra_note": extra_note,
@@ -49,14 +48,29 @@ def get_template():
@webnotes.whitelist()
def upload():
- from webnotes.utils.datautils import read_csv_content_from_uploaded_file
- rows = read_csv_content_from_uploaded_file()
-
- common_values = get_common_values(rows)
- company_abbr = webnotes.conn.get_value("Company", common_values.company, "abbr")
- data, start_idx = get_data(rows, company_abbr)
+ messages = []
+ try:
+ from webnotes.utils.datautils import read_csv_content_from_uploaded_file
+ rows = read_csv_content_from_uploaded_file()
+ common_values = get_common_values(rows)
+ company_abbr = webnotes.conn.get_value("Company", common_values.company, "abbr")
+
+ if not company_abbr:
+ webnotes.msgprint(_("Company is missing or entered incorrect value"), raise_exception=1)
+
+ data, start_idx = get_data(rows, company_abbr, rows[0][0])
+ except Exception, e:
+ err_msg = webnotes.message_log and "
".join(webnotes.message_log) or cstr(e)
+ messages.append("""
google-api-python-client
@@ -100,7 +105,12 @@
| Downloadify - Flash Download Widget |
A tiny javascript + Flash library that enables the creation and download of text files without server interaction. |
-
+
+
+ | GeoLite data by MaxMind |
+ GeoLite data created by MaxMind, available from
+ https://www.maxmind.com |
+
diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js
index 949849d8f18..910c1b16028 100644
--- a/home/page/latest_updates/latest_updates.js
+++ b/home/page/latest_updates/latest_updates.js
@@ -1,5 +1,16 @@
erpnext.updates = [
+ ["17th May", ["Patch: Set Conversion Factor for purchase invoice item in all old records. And repost JV to book Stock Received But Not Billed account, if Auto Inventory Integration enabed."
+ ]],
+ ["2nd May", ["Buying: Warehouse must belong to same company as transaction",
+ "Price List: Added Currency Field. One price list can have only one currency",
+ "Item: Naming can now be by series or item code",
+ "Naming Series: Set number of digits in series (optionally)",
+ "Login: Disable Signup link in the login page"]],
+ ["30th April", ["Price List: Valid for all countries or only valid for specific countries"]],
+ ["18th April", ["Cost Center: Set a default Cost Center for a Company"]],
["12th April", ["Employee: List of Leave Approvers who can approve the Employee's Leave Applications"]],
+ ["10th April", ["Redesigned File Uploads and added File Manager in Setup"]],
+ ["3rd April", ["Update Manager: Open source users can update their ERPNext instance from Setup > Update Manager"]],
["27th March", ["Rename multiple items together. Go to Setup > Rename Tool"]],
["26th March", ["Added project to Stock Ledger and Balance",
"Added Default Cash Account in Company."]],
diff --git a/hr/doctype/attendance/attendance.py b/hr/doctype/attendance/attendance.py
index 67af429dd08..ac41acf8156 100644
--- a/hr/doctype/attendance/attendance.py
+++ b/hr/doctype/attendance/attendance.py
@@ -18,7 +18,6 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import getdate, nowdate
-from webnotes.model.doc import make_autoname
from webnotes import msgprint, _
sql = webnotes.conn.sql
@@ -28,9 +27,6 @@ class DocType:
self.doc = doc
self.doclist = doclist
- def autoname(self):
- self.doc.name = make_autoname(self.doc.naming_series+'.#####')
-
def get_emp_name(self):
return {
"employee_name": webnotes.conn.get_value("Employee",
diff --git a/hr/doctype/deduction_type/deduction_type.txt b/hr/doctype/deduction_type/deduction_type.txt
index 4c9ad7ac4c3..f3467936f5f 100644
--- a/hr/doctype/deduction_type/deduction_type.txt
+++ b/hr/doctype/deduction_type/deduction_type.txt
@@ -1,12 +1,13 @@
[
{
- "creation": "2013-01-10 16:34:13",
+ "creation": "2013-01-22 16:50:30",
"docstatus": 0,
- "modified": "2013-01-22 14:25:38",
+ "modified": "2013-05-02 11:22:59",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
+ "allow_rename": 1,
"autoname": "field:deduction_name",
"doctype": "DocType",
"document_type": "Master",
diff --git a/hr/doctype/earning_type/earning_type.txt b/hr/doctype/earning_type/earning_type.txt
index 18cac6821a2..d69f48619cc 100644
--- a/hr/doctype/earning_type/earning_type.txt
+++ b/hr/doctype/earning_type/earning_type.txt
@@ -1,12 +1,13 @@
[
{
- "creation": "2013-01-10 16:34:13",
+ "creation": "2013-01-24 11:03:32",
"docstatus": 0,
- "modified": "2013-01-23 16:32:07",
+ "modified": "2013-05-02 11:22:48",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
+ "allow_rename": 1,
"autoname": "field:earning_name",
"doctype": "DocType",
"document_type": "Master",
diff --git a/hr/doctype/employee/employee.py b/hr/doctype/employee/employee.py
index 59c8380ee64..036980326cf 100644
--- a/hr/doctype/employee/employee.py
+++ b/hr/doctype/employee/employee.py
@@ -36,7 +36,7 @@ class DocType:
if ret[0][0]=='Naming Series':
self.doc.name = make_autoname(self.doc.naming_series + '.####')
elif ret[0][0]=='Employee Number':
- self.doc.name = make_autoname(self.doc.employee_number)
+ self.doc.name = self.doc.employee_number
self.doc.employee = self.doc.name
@@ -80,7 +80,7 @@ class DocType:
if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole
where parent=%s""", self.doc.user_id):
from webnotes.profile import add_role
- add_role(self.doc.user_id, "HR User")
+ add_role(self.doc.user_id, "Employee")
profile_wrapper = webnotes.bean("Profile", self.doc.user_id)
@@ -101,18 +101,19 @@ class DocType:
if self.doc.gender:
profile_wrapper.doc.gender = self.doc.gender
- if self.doc.image and self.doc.file_list:
- # add to file list and user_image
- for file_args in self.doc.file_list.split("\n"):
- fname, fid = file_args.split(",")
- if self.doc.image == fname:
- new_file_args = fname + "," + fid
- file_list = cstr(profile_wrapper.doc.file_list).split("\n")
- if new_file_args not in file_list:
- file_list += [new_file_args]
- profile_wrapper.doc.file_list = "\n".join(file_list)
- profile_wrapper.doc.user_image = fname
- break
+ if self.doc.image:
+ if not profile_wrapper.doc.user_image == self.doc.image:
+ profile_wrapper.doc.user_image = self.doc.image
+ try:
+ webnotes.doc({
+ "doctype": "File Data",
+ "file_name": self.doc.image,
+ "attached_to_doctype": "Profile",
+ "attached_to_name": self.doc.user_id
+ }).insert()
+ except webnotes.DuplicateEntryError, e:
+ # already exists
+ pass
profile_wrapper.save()
diff --git a/hr/doctype/employee/employee.txt b/hr/doctype/employee/employee.txt
index 997a1efb51b..705eaa72730 100644
--- a/hr/doctype/employee/employee.txt
+++ b/hr/doctype/employee/employee.txt
@@ -30,9 +30,7 @@
"parent": "Employee",
"parentfield": "permissions",
"parenttype": "DocType",
- "permlevel": 0,
"read": 1,
- "report": 1,
"submit": 0
},
{
@@ -741,14 +739,6 @@
"oldfieldname": "feedback",
"oldfieldtype": "Text"
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "print_hide": 1
- },
{
"doctype": "DocField",
"fieldname": "trash_reason",
@@ -763,6 +753,18 @@
"create": 0,
"doctype": "DocPerm",
"match": "employee",
+ "permlevel": 0,
+ "report": 1,
+ "role": "Employee",
+ "write": 0
+ },
+ {
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "match": "",
+ "permlevel": 1,
+ "report": 0,
"role": "Employee",
"write": 0
},
@@ -771,6 +773,8 @@
"create": 1,
"doctype": "DocPerm",
"match": "company",
+ "permlevel": 0,
+ "report": 1,
"role": "HR User",
"write": 1
},
@@ -778,7 +782,29 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
+ "permlevel": 0,
+ "report": 1,
"role": "HR Manager",
"write": 1
+ },
+ {
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "match": "",
+ "permlevel": 1,
+ "report": 0,
+ "role": "HR User",
+ "write": 0
+ },
+ {
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "match": "",
+ "permlevel": 1,
+ "report": 0,
+ "role": "HR Manager",
+ "write": 0
}
]
\ No newline at end of file
diff --git a/hr/doctype/job_applicant/job_applicant.txt b/hr/doctype/job_applicant/job_applicant.txt
index 4500d9b64a7..d2a2d77ca76 100644
--- a/hr/doctype/job_applicant/job_applicant.txt
+++ b/hr/doctype/job_applicant/job_applicant.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-01-15 16:32:13",
+ "creation": "2013-01-29 19:25:37",
"docstatus": 0,
"modified": "2013-01-29 17:44:52",
"modified_by": "Administrator",
@@ -88,16 +88,6 @@
"fieldtype": "HTML",
"label": "Thread HTML"
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "in_list_view": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"doctype": "DocPerm"
}
diff --git a/hr/doctype/leave_application/leave_application.js b/hr/doctype/leave_application/leave_application.js
index 7f8948a674c..2715a6c5db9 100755
--- a/hr/doctype/leave_application/leave_application.js
+++ b/hr/doctype/leave_application/leave_application.js
@@ -16,7 +16,6 @@
cur_frm.add_fetch('employee','employee_name','employee_name');
-
cur_frm.cscript.onload = function(doc, dt, dn) {
if(!doc.posting_date)
set_multiple(dt,dn,{posting_date:get_today()});
@@ -127,4 +126,8 @@ cur_frm.cscript.calculate_total_days = function(doc, dt, dn) {
}
}
-cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query;
\ No newline at end of file
+cur_frm.fields_dict.employee.get_query = function() {
+ return {
+ query: "hr.doctype.leave_application.leave_application.query_for_permitted_employees"
+ };
+}
\ No newline at end of file
diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py
index b9f9e5bfefd..7c47d6a09eb 100755
--- a/hr/doctype/leave_application/leave_application.py
+++ b/hr/doctype/leave_application/leave_application.py
@@ -330,3 +330,27 @@ def add_holidays(events, start, end, employee, company):
"title": _("Holiday") + ": " + cstr(holiday.description),
"name": holiday.name
})
+
+@webnotes.whitelist()
+def query_for_permitted_employees(doctype, txt, searchfield, start, page_len, filters):
+ txt = "%" + cstr(txt) + "%"
+
+ if "Leave Approver" in webnotes.user.get_roles():
+ condition = """and (exists(select ela.name from `tabEmployee Leave Approver` ela
+ where ela.parent=`tabEmployee`.name and ela.leave_approver= "%s") or
+ not exists(select ela.name from `tabEmployee Leave Approver` ela
+ where ela.parent=`tabEmployee`.name)
+ or user_id = "%s")""" % (webnotes.session.user, webnotes.session.user)
+ else:
+ from webnotes.widgets.reportview import build_match_conditions
+ condition = build_match_conditions("Employee")
+ condition = ("and " + condition) if condition else ""
+
+ return webnotes.conn.sql("""select name, employee_name from `tabEmployee`
+ where status = 'Active' and docstatus < 2 and
+ (`%s` like %s or employee_name like %s) %s
+ order by
+ case when name like %s then 0 else 1 end,
+ case when employee_name like %s then 0 else 1 end,
+ name limit %s, %s""" % tuple([searchfield] + ["%s"]*2 + [condition] + ["%s"]*4),
+ (txt, txt, txt, txt, start, page_len))
diff --git a/hr/doctype/leave_application/leave_application.txt b/hr/doctype/leave_application/leave_application.txt
index f0f15604e6c..0710a5c6562 100644
--- a/hr/doctype/leave_application/leave_application.txt
+++ b/hr/doctype/leave_application/leave_application.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-02-18 18:37:56",
+ "creation": "2013-02-20 11:18:11",
"docstatus": 0,
"modified": "2013-02-19 16:30:05",
"modified_by": "Administrator",
@@ -8,7 +8,6 @@
},
{
"allow_attach": 1,
- "allow_import": 1,
"autoname": "LAP/.#####",
"description": "Apply / Approve Leaves",
"doctype": "DocType",
@@ -227,16 +226,6 @@
"print_hide": 1,
"read_only": 1
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "permlevel": 0,
- "print_hide": 1
- },
{
"create": 1,
"doctype": "DocPerm",
@@ -251,6 +240,7 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
+ "match": "",
"permlevel": 1,
"role": "All",
"submit": 0
@@ -260,7 +250,6 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
- "match": "company",
"permlevel": 0,
"report": 1,
"role": "HR User",
@@ -269,8 +258,8 @@
},
{
"amend": 1,
- "cancel": 1,
- "create": 1,
+ "cancel": 0,
+ "create": 0,
"doctype": "DocPerm",
"match": "leave_approver:user",
"permlevel": 0,
@@ -284,6 +273,7 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
+ "match": "",
"permlevel": 1,
"report": 1,
"role": "HR User",
@@ -295,6 +285,7 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
+ "match": "",
"permlevel": 1,
"report": 1,
"role": "Leave Approver",
diff --git a/hr/doctype/salary_slip/salary_slip.py b/hr/doctype/salary_slip/salary_slip.py
index 3edf4109547..d1ce3ccf1db 100644
--- a/hr/doctype/salary_slip/salary_slip.py
+++ b/hr/doctype/salary_slip/salary_slip.py
@@ -152,7 +152,7 @@ class DocType(TransactionBase):
d.e_modified_amount = round(flt(d.e_amount)*flt(self.doc.payment_days)/cint(self.doc.total_days_in_month), 2)
elif not self.doc.payment_days:
d.e_modified_amount = 0
- self.doc.gross_pay += d.e_modified_amount
+ self.doc.gross_pay += flt(d.e_modified_amount)
def calculate_ded_total(self):
"""
@@ -165,7 +165,7 @@ class DocType(TransactionBase):
elif not self.doc.payment_days:
d.d_modified_amount = 0
- self.doc.total_deduction += d.d_modified_amount
+ self.doc.total_deduction += flt(d.d_modified_amount)
def calculate_net_pay(self):
"""
diff --git a/hr/doctype/salary_structure/salary_structure.py b/hr/doctype/salary_structure/salary_structure.py
index 22789e3f499..018aab7e7c3 100644
--- a/hr/doctype/salary_structure/salary_structure.py
+++ b/hr/doctype/salary_structure/salary_structure.py
@@ -18,31 +18,25 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt
-from webnotes.model import db_exists
from webnotes.model.doc import addchild, make_autoname
-from webnotes.model.bean import copy_doclist
-from webnotes import msgprint
+from webnotes import msgprint, _
sql = webnotes.conn.sql
class DocType:
- #init function
def __init__(self,doc,doclist=[]):
self.doc = doc
self.doclist = doclist
-
- #autoname function
- #---------------------------------------------------------
+
def autoname(self):
self.doc.name = make_autoname(self.doc.employee + '/.SST' + '/.#####')
-
- #get employee details
- #---------------------------------------------------------
+
def get_employee_details(self):
ret = {}
- det = sql("select employee_name, branch, designation, department, grade from `tabEmployee` where name = '%s'" %self.doc.employee)
+ det = sql("""select employee_name, branch, designation, department, grade
+ from `tabEmployee` where name = %s""", self.doc.employee)
if det:
ret = {
'employee_name': cstr(det[0][0]),
@@ -53,20 +47,16 @@ class DocType:
'backup_employee': cstr(self.doc.employee)
}
return ret
-
- # Set Salary structure field values
- #---------------------------------------------------------
def get_ss_values(self,employee):
- basic_info = sql("select bank_name, bank_ac_no, esic_card_no, pf_number from `tabEmployee` where name ='%s'" % employee)
+ basic_info = sql("""select bank_name, bank_ac_no, esic_card_no, pf_number
+ from `tabEmployee` where name =%s""", employee)
ret = {'bank_name': basic_info and basic_info[0][0] or '',
'bank_ac_no': basic_info and basic_info[0][1] or '',
'esic_no': basic_info and basic_info[0][2] or '',
'pf_no': basic_info and basic_info[0][3] or ''}
return ret
-
- # Make earning and deduction table
- #---------------------------------------------------------
+
def make_table(self, doct_name, tab_fname, tab_name):
list1 = sql("select name from `tab%s` where docstatus != 2" % doct_name)
for li in list1:
@@ -77,37 +67,31 @@ class DocType:
elif(tab_fname == 'deduction_details'):
child.d_type = cstr(li[0])
child.d_modified_amt = 0
-
- # add earning & deduction types to table
- #---------------------------------------------------------
+
def make_earn_ded_table(self):
- #Earning List
self.make_table('Earning Type','earning_details','Salary Structure Earning')
-
- #Deduction List
- self.make_table('Deduction Type','deduction_details',
- 'Salary Structure Deduction')
-
+ self.make_table('Deduction Type','deduction_details', 'Salary Structure Deduction')
- # Check if another active ss exists
- #---------------------------------------------------------
def check_existing(self):
- ret = sql("select name from `tabSalary Structure` where is_active = 'Yes' and employee = '%s' and name!='%s'" %(self.doc.employee,self.doc.name))
+ ret = sql("""select name from `tabSalary Structure` where is_active = 'Yes'
+ and employee = %s and name!=%s""", (self.doc.employee,self.doc.name))
if ret and self.doc.is_active=='Yes':
- msgprint("Another Salary Structure '%s' is active for employee '%s'. Please make its status 'Inactive' to proceed."%(cstr(ret), self.doc.employee))
- raise Exception
+ msgprint(_("""Another Salary Structure '%s' is active for employee '%s'.
+ Please make its status 'Inactive' to proceed.""") %
+ (cstr(ret), self.doc.employee), raise_exception=1)
- # Validate net pay
- #---------------------------------------------------------
- def validate_net_pay(self):
+ def validate_amount(self):
+ if flt(self.doc.ctc) < 12*flt(self.doc.total_earning):
+ msgprint(_("Annual Cost To Company can not be less than 12 months of Total Earning"),
+ raise_exception=1)
+
if flt(self.doc.net_pay) < 0:
- msgprint("Net pay can not be negative")
- raise Exception
- elif flt(self.doc.net_pay) > flt(self.doc.ctc):
- msgprint("Net pay can not be greater than CTC")
- raise Exception
+ msgprint(_("Net pay can not be negative"), raise_exception=1)
+ elif flt(self.doc.net_pay)*12 > flt(self.doc.ctc):
+ msgprint(_("Net pay can not be greater than 1/12th of Annual Cost To Company"),
+ raise_exception=1)
+
def validate(self):
self.check_existing()
- self.validate_net_pay()
-
+ self.validate_amount()
\ No newline at end of file
diff --git a/hr/doctype/salary_structure/salary_structure.txt b/hr/doctype/salary_structure/salary_structure.txt
index c2efac6a8db..43b36626f6c 100644
--- a/hr/doctype/salary_structure/salary_structure.txt
+++ b/hr/doctype/salary_structure/salary_structure.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-01-23 19:57:18",
+ "creation": "2013-03-07 18:50:29",
"docstatus": 0,
- "modified": "2013-01-29 17:35:34",
+ "modified": "2013-04-22 14:09:04",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -41,6 +41,7 @@
"doctype": "DocField",
"fieldname": "column_break0",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -52,6 +53,7 @@
"oldfieldname": "employee",
"oldfieldtype": "Link",
"options": "Employee",
+ "read_only": 0,
"reqd": 1
},
{
@@ -116,6 +118,7 @@
"doctype": "DocField",
"fieldname": "column_break1",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -129,6 +132,7 @@
"oldfieldname": "is_active",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -139,6 +143,7 @@
"label": "From Date",
"oldfieldname": "from_date",
"oldfieldtype": "Date",
+ "read_only": 0,
"reqd": 1
},
{
@@ -148,7 +153,8 @@
"in_list_view": 1,
"label": "To Date",
"oldfieldname": "to_date",
- "oldfieldtype": "Date"
+ "oldfieldtype": "Date",
+ "read_only": 0
},
{
"description": "Cost to Company",
@@ -156,10 +162,11 @@
"fieldname": "ctc",
"fieldtype": "Currency",
"in_filter": 1,
- "label": "CTC",
+ "label": "Annual Cost To Company",
"oldfieldname": "ctc",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
+ "read_only": 0,
"reqd": 1
},
{
@@ -169,6 +176,7 @@
"in_filter": 1,
"label": "Company",
"options": "link:Company",
+ "read_only": 0,
"reqd": 1
},
{
@@ -178,7 +186,8 @@
"fieldtype": "Section Break",
"label": "Earning & Deduction",
"oldfieldname": "earning_deduction",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -188,6 +197,7 @@
"label": "Earning",
"oldfieldname": "col_brk2",
"oldfieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -198,7 +208,8 @@
"label": "Earning1",
"oldfieldname": "earning_details",
"oldfieldtype": "Table",
- "options": "Salary Structure Earning"
+ "options": "Salary Structure Earning",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -208,6 +219,7 @@
"label": "Deduction",
"oldfieldname": "col_brk3",
"oldfieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -218,18 +230,21 @@
"label": "Deduction1",
"oldfieldname": "deduction_details",
"oldfieldtype": "Table",
- "options": "Salary Structure Deduction"
+ "options": "Salary Structure Deduction",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "section_break0",
"fieldtype": "Section Break",
- "options": "Simple"
+ "options": "Simple",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break2",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -256,6 +271,7 @@
"doctype": "DocField",
"fieldname": "column_break3",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
diff --git a/hr/doctype/upload_attendance/upload_attendance.js b/hr/doctype/upload_attendance/upload_attendance.js
index 35a00ed69dc..4e5b47fe00f 100644
--- a/hr/doctype/upload_attendance/upload_attendance.js
+++ b/hr/doctype/upload_attendance/upload_attendance.js
@@ -75,7 +75,6 @@ erpnext.hr.AttendanceControlPanel = wn.ui.form.Controller.extend({
r.messages = ["Import Successful!
"].
concat(r.messages)
}
- console.log(r.messages);
$.each(r.messages, function(i, v) {
var $p = $('').html(v).appendTo($log_wrapper);
diff --git a/hr/doctype/upload_attendance/upload_attendance.py b/hr/doctype/upload_attendance/upload_attendance.py
index e48cbefb69e..ee4234a2791 100644
--- a/hr/doctype/upload_attendance/upload_attendance.py
+++ b/hr/doctype/upload_attendance/upload_attendance.py
@@ -100,7 +100,6 @@ def get_naming_series():
def upload():
from webnotes.utils.datautils import read_csv_content_from_uploaded_file
from webnotes.modules import scrub
- from core.page.data_import_tool.data_import_tool import check_record, import_doc
rows = read_csv_content_from_uploaded_file()
if not rows:
@@ -112,6 +111,9 @@ def upload():
ret = []
error = False
+ from webnotes.utils.datautils import check_record, import_doc
+ doctype_dl = webnotes.get_doctype("Attendance")
+
for i, row in enumerate(rows[5:]):
if not row: continue
row_idx = i + 5
@@ -121,7 +123,7 @@ def upload():
d["docstatus"] = webnotes.conn.get_value("Attendance", d.name, "docstatus")
try:
- check_record(d)
+ check_record(d, doctype_dl=doctype_dl)
ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
except Exception, e:
error = True
diff --git a/hr/page/hr_home/hr_home.js b/hr/page/hr_home/hr_home.js
index df3264501a9..e35a80849b9 100644
--- a/hr/page/hr_home/hr_home.js
+++ b/hr/page/hr_home/hr_home.js
@@ -169,6 +169,22 @@ wn.module_page["HR"] = [
"label":wn._("Employee Leave Balance"),
route: "query-report/Employee Leave Balance"
},
+ {
+ "label":wn._("Employee Birthday"),
+ route: "query-report/Employee Birthday"
+ },
+ {
+ "label":wn._("Employee Information"),
+ route: "Report2/Employee/Employee Information"
+ },
+ {
+ "label":wn._("Monthly Salary Register"),
+ route: "query-report/Monthly Salary Register"
+ },
+ {
+ "label":wn._("Monthly Attendance Sheet"),
+ route: "query-report/Monthly Attendance Sheet"
+ },
]
}
];
diff --git a/hr/report/employee_birthday/__init__.py b/hr/report/employee_birthday/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/hr/report/employee_birthday/employee_birthday.js b/hr/report/employee_birthday/employee_birthday.js
new file mode 100644
index 00000000000..f2bc9cbe564
--- /dev/null
+++ b/hr/report/employee_birthday/employee_birthday.js
@@ -0,0 +1,19 @@
+wn.query_reports["Employee Birthday"] = {
+ "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":"company",
+ "label": "Company",
+ "fieldtype": "Link",
+ "options": "Company",
+ "default": wn.defaults.get_user_default("company")
+ }
+ ]
+}
\ No newline at end of file
diff --git a/hr/report/employee_birthday/employee_birthday.py b/hr/report/employee_birthday/employee_birthday.py
new file mode 100644
index 00000000000..7268055b728
--- /dev/null
+++ b/hr/report/employee_birthday/employee_birthday.py
@@ -0,0 +1,50 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import flt
+
+def execute(filters=None):
+ if not filters: filters = {}
+
+ columns = get_columns()
+ data = get_employees(filters)
+
+ return columns, data
+
+def get_columns():
+ return [
+ "Employee:Link/Employee:120", "Date of Birth:Date:100", "Branch:Link/Branch:120",
+ "Department:Link/Department:120", "Designation:Link/Designation:120", "Gender::60",
+ "Company:Link/Company:120"
+ ]
+
+def get_employees(filters):
+ conditions = get_conditions(filters)
+ return webnotes.conn.sql("""select name, date_of_birth, branch, department, designation,
+ gender, company from tabEmployee where status = 'Active' %s""" % conditions, as_list=1)
+
+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
+ conditions += " and month(date_of_birth) = '%s'" % month
+
+ if filters.get("company"): conditions += " and company = '%s'" % filters["company"]
+
+ return conditions
\ No newline at end of file
diff --git a/hr/report/employee_birthday/employee_birthday.txt b/hr/report/employee_birthday/employee_birthday.txt
new file mode 100644
index 00000000000..575ae733527
--- /dev/null
+++ b/hr/report/employee_birthday/employee_birthday.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-05-06 17:56:03",
+ "docstatus": 0,
+ "modified": "2013-05-06 17:56:03",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Employee",
+ "report_name": "Employee Birthday",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Employee Birthday"
+ }
+]
\ No newline at end of file
diff --git a/hr/report/employee_information/__init__.py b/hr/report/employee_information/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/hr/report/employee_information/employee_information.txt b/hr/report/employee_information/employee_information.txt
new file mode 100644
index 00000000000..b9d190b0292
--- /dev/null
+++ b/hr/report/employee_information/employee_information.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-05-06 18:43:53",
+ "docstatus": 0,
+ "modified": "2013-05-06 18:47:43",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "json": "{\"filters\":[],\"columns\":[[\"name\",\"Employee\"],[\"employee_number\",\"Employee\"],[\"date_of_joining\",\"Employee\"],[\"branch\",\"Employee\"],[\"department\",\"Employee\"],[\"designation\",\"Employee\"],[\"gender\",\"Employee\"],[\"status\",\"Employee\"],[\"company\",\"Employee\"],[\"employment_type\",\"Employee\"],[\"grade\",\"Employee\"],[\"reports_to\",\"Employee\"],[\"company_email\",\"Employee\"]],\"sort_by\":\"Employee.bank_ac_no\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}",
+ "name": "__common__",
+ "ref_doctype": "Employee",
+ "report_name": "Employee Information",
+ "report_type": "Report Builder"
+ },
+ {
+ "doctype": "Report",
+ "name": "Employee Information"
+ }
+]
\ No newline at end of file
diff --git a/hr/report/monthly_attendance_sheet/__init__.py b/hr/report/monthly_attendance_sheet/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js
new file mode 100644
index 00000000000..6dc8d78ea5e
--- /dev/null
+++ b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js
@@ -0,0 +1,32 @@
+wn.query_reports["Monthly Attendance Sheet"] = {
+ "filters": [
+ {
+ "fieldname":"month",
+ "label": "Month",
+ "fieldtype": "Select",
+ "options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
+ "default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
+ "Dec"][wn.datetime.str_to_obj(wn.datetime.get_today()).getMonth()],
+ },
+ {
+ "fieldname":"fiscal_year",
+ "label": "Fiscal Year",
+ "fieldtype": "Link",
+ "options": "Fiscal Year",
+ "default": sys_defaults.fiscal_year,
+ },
+ {
+ "fieldname":"employee",
+ "label": "Employee",
+ "fieldtype": "Link",
+ "options": "Employee"
+ },
+ {
+ "fieldname":"company",
+ "label": "Company",
+ "fieldtype": "Link",
+ "options": "Company",
+ "default": sys_defaults.company
+ }
+ ]
+}
\ No newline at end of file
diff --git a/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py
new file mode 100644
index 00000000000..42a977025a6
--- /dev/null
+++ b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py
@@ -0,0 +1,107 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import cstr, cint
+from webnotes import msgprint, _
+
+def execute(filters=None):
+ if not filters: filters = {}
+
+ conditions, filters = get_conditions(filters)
+ columns = get_columns(filters)
+ att_map = get_attendance_list(conditions, filters)
+ emp_map = get_employee_details()
+
+ data = []
+ for emp in sorted(att_map):
+ emp_det = emp_map.get(emp)
+ row = [emp, emp_det.employee_name, emp_det.branch, emp_det.department, emp_det.designation,
+ emp_det.company]
+
+ total_p = total_a = 0.0
+ for day in range(filters["total_days_in_month"]):
+ status = att_map.get(emp).get(day + 1, "Absent")
+ status_map = {"Present": "P", "Absent": "A", "Half Day": "HD"}
+ row.append(status_map[status])
+
+ if status == "Present":
+ total_p += 1
+ elif status == "Absent":
+ total_a += 1
+ elif status == "Half Day":
+ total_p += 0.5
+ total_a += 0.5
+
+ row += [total_p, total_a]
+
+ data.append(row)
+
+ return columns, data
+
+def get_columns(filters):
+ columns = [
+ "Employee:Link/Employee:120", "Employee Name::140", "Branch:Link/Branch:120",
+ "Department:Link/Department:120", "Designation:Link/Designation:120",
+ "Company:Link/Company:120"
+ ]
+
+ for day in range(filters["total_days_in_month"]):
+ columns.append(cstr(day+1) +"::20")
+
+ columns += ["Total Present:Float:80", "Total Absent:Float:80"]
+ return columns
+
+def get_attendance_list(conditions, filters):
+ attendance_list = webnotes.conn.sql("""select employee, day(att_date) as day_of_month,
+ status from tabAttendance where docstatus = 1 %s order by employee, att_date""" %
+ conditions, filters, as_dict=1)
+
+ att_map = {}
+ for d in attendance_list:
+ att_map.setdefault(d.employee, webnotes._dict()).setdefault(d.day_of_month, "")
+ att_map[d.employee][d.day_of_month] = d.status
+
+ return att_map
+
+def get_conditions(filters):
+ if not (filters.get("month") and filters.get("fiscal_year")):
+ msgprint(_("Please select month and year"), raise_exception=1)
+
+ filters["month"] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
+ "Dec"].index(filters["month"]) + 1
+
+ from calendar import monthrange
+ filters["total_days_in_month"] = monthrange(cint(filters["fiscal_year"].split("-")[-1]),
+ filters["month"])[1]
+
+ conditions = " and month(att_date) = %(month)s and fiscal_year = %(fiscal_year)s"
+
+ if filters.get("company"): conditions += " and company = %(company)s"
+ if filters.get("employee"): conditions += " and employee = %(employee)s"
+
+ return conditions, filters
+
+def get_employee_details():
+ employee = webnotes.conn.sql("""select name, employee_name, designation, department,
+ branch, company from tabEmployee where docstatus < 2 and status = 'Active'""", as_dict=1)
+
+ emp_map = {}
+ for emp in employee:
+ emp_map[emp.name] = emp
+
+ return emp_map
\ No newline at end of file
diff --git a/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt
new file mode 100644
index 00000000000..3c53aae8e46
--- /dev/null
+++ b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-05-13 14:04:03",
+ "docstatus": 0,
+ "modified": "2013-05-13 14:32:42",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "add_total_row": 0,
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Attendance",
+ "report_name": "Monthly Attendance Sheet",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Monthly Attendance Sheet"
+ }
+]
\ No newline at end of file
diff --git a/hr/report/monthly_salary_register/__init__.py b/hr/report/monthly_salary_register/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/hr/report/monthly_salary_register/monthly_salary_register.js b/hr/report/monthly_salary_register/monthly_salary_register.js
new file mode 100644
index 00000000000..da881378ff0
--- /dev/null
+++ b/hr/report/monthly_salary_register/monthly_salary_register.js
@@ -0,0 +1,32 @@
+wn.query_reports["Monthly Salary Register"] = {
+ "filters": [
+ {
+ "fieldname":"month",
+ "label": "Month",
+ "fieldtype": "Select",
+ "options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
+ "default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
+ "Dec"][wn.datetime.str_to_obj(wn.datetime.get_today()).getMonth()],
+ },
+ {
+ "fieldname":"fiscal_year",
+ "label": "Fiscal Year",
+ "fieldtype": "Link",
+ "options": "Fiscal Year",
+ "default": sys_defaults.fiscal_year,
+ },
+ {
+ "fieldname":"employee",
+ "label": "Employee",
+ "fieldtype": "Link",
+ "options": "Employee"
+ },
+ {
+ "fieldname":"company",
+ "label": "Company",
+ "fieldtype": "Link",
+ "options": "Company",
+ "default": sys_defaults.company
+ }
+ ]
+}
\ No newline at end of file
diff --git a/hr/report/monthly_salary_register/monthly_salary_register.py b/hr/report/monthly_salary_register/monthly_salary_register.py
new file mode 100644
index 00000000000..cc25dc3e329
--- /dev/null
+++ b/hr/report/monthly_salary_register/monthly_salary_register.py
@@ -0,0 +1,119 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import flt, cstr
+from webnotes import msgprint, _
+
+def execute(filters=None):
+ if not filters: filters = {}
+
+ salary_slips = get_salary_slips(filters)
+ columns, earning_types, ded_types = get_columns(salary_slips)
+ ss_earning_map = get_ss_earning_map(salary_slips)
+ ss_ded_map = get_ss_ded_map(salary_slips)
+
+ data = []
+ for ss in salary_slips:
+ row = [ss.employee, ss.employee_name, ss.branch, ss.department, ss.designation,
+ ss.company, ss.month, ss.leave_withut_pay, ss.payment_days]
+
+ for e in earning_types:
+ row.append(ss_earning_map.get(ss.name, {}).get(e))
+
+ row += [ss.arrear_amount, ss.leave_encashment_amount, ss.gross_pay]
+
+ for d in ded_types:
+ row.append(ss_ded_map.get(ss.name, {}).get(d))
+
+ row += [ss.total_deduction, ss.net_pay]
+
+ data.append(row)
+
+ return columns, data
+
+def get_columns(salary_slips):
+ columns = [
+ "Employee:Link/Employee:120", "Employee Name::140", "Branch:Link/Branch:120",
+ "Department:Link/Department:120", "Designation:Link/Designation:120",
+ "Company:Link/Company:120", "Month::80", "Leave Without pay:Float:130",
+ "Payment Days:Float:120"
+ ]
+
+ earning_types = webnotes.conn.sql_list("""select distinct e_type from `tabSalary Slip Earning`
+ where ifnull(e_modified_amount, 0) != 0 and parent in (%s)""" %
+ (', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]))
+
+ ded_types = webnotes.conn.sql_list("""select distinct d_type from `tabSalary Slip Deduction`
+ where ifnull(d_modified_amount, 0) != 0 and parent in (%s)""" %
+ (', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]))
+
+ columns = columns + [(e + ":Link/Earning Type:120") for e in earning_types] + \
+ ["Arrear Amount:Currency:120", "Leave Encashment Amount:Currency:150",
+ "Gross Pay:Currency:120"] + [(d + ":Link/Deduction Type:120") for d in ded_types] + \
+ ["Total Deduction:Currency:120", "Net Pay:Currency:120"]
+
+ return columns, earning_types, ded_types
+
+def get_salary_slips(filters):
+ conditions, filters = get_conditions(filters)
+ salary_slips = webnotes.conn.sql("""select * from `tabSalary Slip` where docstatus = 1 %s""" %
+ conditions, filters, as_dict=1)
+
+ if not salary_slips:
+ msgprint(_("No salary slip found for month: ") + cstr(filters.get("month")) +
+ _(" and year: ") + cstr(filters.get("fiscal_year")), raise_exception=1)
+
+ return salary_slips
+
+def get_conditions(filters):
+ conditions = ""
+ if filters.get("month"):
+ month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
+ "Dec"].index(filters["month"]) + 1
+ filters["month"] = month
+ conditions += " and month = %(month)s"
+
+ if filters.get("fiscal_year"): conditions += " and fiscal_year = %(fiscal_year)s"
+ if filters.get("company"): conditions += " and company = %(company)s"
+ if filters.get("employee"): conditions += " and employee = %(employee)s"
+
+ return conditions, filters
+
+def get_ss_earning_map(salary_slips):
+ ss_earnings = webnotes.conn.sql("""select parent, e_type, e_modified_amount
+ from `tabSalary Slip Earning` where parent in (%s)""" %
+ (', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]), as_dict=1)
+
+ ss_earning_map = {}
+ for d in ss_earnings:
+ ss_earning_map.setdefault(d.parent, webnotes._dict()).setdefault(d.e_type, [])
+ ss_earning_map[d.parent][d.e_type] = flt(d.e_modified_amount)
+
+ return ss_earning_map
+
+def get_ss_ded_map(salary_slips):
+ ss_deductions = webnotes.conn.sql("""select parent, d_type, d_modified_amount
+ from `tabSalary Slip Deduction` where parent in (%s)""" %
+ (', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]), as_dict=1)
+
+ ss_ded_map = {}
+ for d in ss_deductions:
+ ss_ded_map.setdefault(d.parent, webnotes._dict()).setdefault(d.d_type, [])
+ ss_ded_map[d.parent][d.e_type] = flt(d.d_modified_amount)
+
+ return ss_ded_map
\ No newline at end of file
diff --git a/hr/report/monthly_salary_register/monthly_salary_register.txt b/hr/report/monthly_salary_register/monthly_salary_register.txt
new file mode 100644
index 00000000000..b0d5880eaf0
--- /dev/null
+++ b/hr/report/monthly_salary_register/monthly_salary_register.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-05-07 18:09:42",
+ "docstatus": 0,
+ "modified": "2013-05-07 18:09:42",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "add_total_row": 1,
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Salary Slip",
+ "report_name": "Monthly Salary Register",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Monthly Salary Register"
+ }
+]
\ No newline at end of file
diff --git a/hr/search_criteria/__init__.py b/hr/search_criteria/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/hr/search_criteria/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/hr/search_criteria/employee_appraisals/__init__.py b/hr/search_criteria/employee_appraisals/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/hr/search_criteria/employee_appraisals/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/hr/search_criteria/employee_appraisals/employee_appraisals.txt b/hr/search_criteria/employee_appraisals/employee_appraisals.txt
deleted file mode 100644
index ce12a0e97f4..00000000000
--- a/hr/search_criteria/employee_appraisals/employee_appraisals.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "ashwini@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:51"
- },
- {
- "module": "HR",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Appraisal\u0001Saved':1,'Appraisal\u0001Submitted':1,'Appraisal\u0001Status':'','Appraisal\u0001Fiscal Year':''}",
- "doctype": "Search Criteria",
- "doc_type": "Appraisal",
- "name": "__common__",
- "sort_by": "`tabAppraisal`.`name`",
- "page_len": 50,
- "criteria_name": "Employee Appraisals",
- "columns": "Appraisal\u0001ID,Appraisal\u0001Status,Appraisal\u0001Employee,Appraisal\u0001Employee Name,Appraisal\u0001Start Date,Appraisal\u0001End Date,Appraisal\u0001Approver,Appraisal\u0001Total Score"
- },
- {
- "name": "employee_appraisals",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/hr/search_criteria/employee_information/__init__.py b/hr/search_criteria/employee_information/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/hr/search_criteria/employee_information/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/hr/search_criteria/employee_information/employee_information.txt b/hr/search_criteria/employee_information/employee_information.txt
deleted file mode 100644
index d05461380f0..00000000000
--- a/hr/search_criteria/employee_information/employee_information.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "harshada@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:51"
- },
- {
- "module": "HR",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Employee\u0001Saved':1,'Employee\u0001Submitted':1,'Employee\u0001Gender':'','Employee\u0001Month of Birth':'','Employee\u0001Status':''}",
- "doctype": "Search Criteria",
- "doc_type": "Employee",
- "name": "__common__",
- "sort_by": "`tabEmployee`.`name`",
- "page_len": 50,
- "criteria_name": "Employee Information",
- "columns": "Employee\u0001ID,Employee\u0001Employee Name,Employee\u0001Employee Number,Employee\u0001Date of Joining,Employee\u0001Gender,Employee\u0001Date of Birth,Employee\u0001Employment Type,Employee\u0001Scheduled Confirmation Date,Employee\u0001Contract End Date,Employee\u0001Status,Employee\u0001Branch,Employee\u0001Department,Employee\u0001Designation,Employee\u0001Grade,Employee\u0001Reports to,Employee\u0001Email (By company),Employee\u0001Bank Name,Employee\u0001Relieving Date"
- },
- {
- "name": "employee_information",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/hr/search_criteria/employees_birthday/__init__.py b/hr/search_criteria/employees_birthday/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/hr/search_criteria/employees_birthday/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/hr/search_criteria/employees_birthday/employees_birthday.txt b/hr/search_criteria/employees_birthday/employees_birthday.txt
deleted file mode 100644
index a96b8698b90..00000000000
--- a/hr/search_criteria/employees_birthday/employees_birthday.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:51"
- },
- {
- "module": "HR",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Employee\u0001Saved':1,'Employee\u0001Gender':'','Employee\u0001Month of Birth':'May','Employee\u0001Status':''}",
- "doctype": "Search Criteria",
- "doc_type": "Employee",
- "name": "__common__",
- "sort_by": "`tabEmployee`.`name`",
- "page_len": 50,
- "criteria_name": "Employee's Birthday",
- "columns": "Employee\u0001ID,Employee\u0001Employee Name,Employee\u0001Department,Employee\u0001Gender,Employee\u0001Date of Birth,Employee\u0001Month of Birth"
- },
- {
- "name": "employees_birthday",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/hr/search_criteria/expense_claims/__init__.py b/hr/search_criteria/expense_claims/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/hr/search_criteria/expense_claims/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/hr/search_criteria/expense_claims/expense_claims.txt b/hr/search_criteria/expense_claims/expense_claims.txt
deleted file mode 100644
index f1324d2e1cf..00000000000
--- a/hr/search_criteria/expense_claims/expense_claims.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "ashwini@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-03-30 13:33:32",
- "modified_by": "Administrator",
- "modified": "2012-03-30 13:33:32"
- },
- {
- "module": "HR",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Expense Claim\u0001Saved':1,'Expense Claim\u0001Submitted':1,'Expense Claim\u0001Approval Status':'','Expense Claim\u0001Fiscal Year':''}",
- "doctype": "Search Criteria",
- "doc_type": "Expense Claim",
- "name": "__common__",
- "sort_by": "`tabExpense Claim`.`name`",
- "page_len": 50,
- "criteria_name": "Expense Claims",
- "columns": "Expense Claim\u0001ID,Expense Claim\u0001Approval Status,Expense Claim\u0001From Employee,Expense Claim\u0001Employee Name,Expense Claim\u0001Approver,Expense Claim\u0001Posting Date,Expense Claim\u0001Total Claimed Amount,Expense Claim\u0001Total Sanctioned Amount"
- },
- {
- "name": "expense_claims",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/hr/search_criteria/monthly_attendance_details/__init__.py b/hr/search_criteria/monthly_attendance_details/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/hr/search_criteria/monthly_attendance_details/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.js b/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.js
deleted file mode 100644
index e922a2f433d..00000000000
--- a/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.js
+++ /dev/null
@@ -1,45 +0,0 @@
-// 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 .
-
-var get_month = function(){
-
- var dict = {0:'Jan', 1:'Feb',2:'Mar',3:'Apr',4:'May',5:'June',6:'July',7:'Aug',8:'Sept',9:'Oct',10:'Nov',11:'Dec'}
- var d = new Date();
- return dict[d.getMonth()]
-
-}
-
-report.customize_filters = function() {
- this.hide_all_filters();
- this.add_filter({fieldname:'month', label:'Month', fieldtype:'Select', options:'Jan'+NEWLINE+'Feb'+NEWLINE+'Mar'+NEWLINE+'Apr'+NEWLINE+'May'+NEWLINE+'June'+NEWLINE+'July'+NEWLINE+'Aug'+NEWLINE+'Sept'+NEWLINE+'Oct'+NEWLINE+'Nov'+NEWLINE+'Dec',ignore : 1,parent:'Attendance', single_select:1});
-
- this.filter_fields_dict['Attendance'+FILTER_SEP +'Employee'].df.filter_hide = 0;
- this.filter_fields_dict['Attendance'+FILTER_SEP +'Month'].df.filter_hide = 0;
- this.filter_fields_dict['Attendance'+FILTER_SEP +'Fiscal Year'].df.filter_hide = 0;
- this.filter_fields_dict['Attendance'+FILTER_SEP +'Company'].df.filter_hide = 0;
-
- this.filter_fields_dict['Attendance'+FILTER_SEP +'Employee'].df.in_first_page = 1;
- this.filter_fields_dict['Attendance'+FILTER_SEP +'Month'].df.in_first_page = 1;
- this.filter_fields_dict['Attendance'+FILTER_SEP +'Fiscal Year'].df.in_first_page = 1;
- this.filter_fields_dict['Attendance'+FILTER_SEP +'Company'].df.in_first_page = 1;
-
- this.filter_fields_dict['Attendance'+FILTER_SEP +'Month'].df['report_default'] = get_month();
- this.filter_fields_dict['Attendance'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
- this.filter_fields_dict['Attendance'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
- this.get_filter('Attendance', 'Fiscal Year').set_as_single();
-}
-this.mytabs.items['More Filters'].hide();
-this.mytabs.items['Select Columns'].hide();
\ No newline at end of file
diff --git a/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.py b/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.py
deleted file mode 100644
index dff95df1695..00000000000
--- a/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.py
+++ /dev/null
@@ -1,93 +0,0 @@
-# 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 .
-
-#add column employee, employee name
-#--------------------------------------------------------------------------------------
-from __future__ import unicode_literals
-col =[['Employee','Link','155px','Employee'],['Employee Name','Data','150px','']]
-
-for c in col:
- colnames.append(c[0])
- coltypes.append(c[1])
- colwidths.append(c[2])
- coloptions.append(c[3])
-
- col_idx[c[0]] = len(colnames)-1
-
-
-#get feb months last day
-#--------------------------------------------------------------------------------------
-fy = filter_values.get('fiscal_year')
-month = filter_values.get('month')
-mdict = {'Jan':'01', 'Feb':'02','Mar':'03','Apr':'04','May':'05','June':'06','July':'07','Aug':'08','Sept':'09','Oct':'10','Nov':'11','Dec':'12'}
-
-import webnotes.utils
-from dateutil.relativedelta import relativedelta
-
-ysd = sql("select year_start_date from `tabFiscal Year` where name = '%s' and docstatus !=2"%fy)[0][0]
-
-last_date = webnotes.utils.get_last_day(ysd + relativedelta(months = (cint(ysd.strftime('%m'))>cint(mdict[month]) and (12-cint(ysd.strftime('%m'))+cint(mdict[month])) or (cint(mdict[month]) - cint(ysd.strftime('%m'))))))
-feb = last_date.strftime('%d')
-
-
-
-#get last day and add columns
-#--------------------------------------------------------------------------------------
-dict = {'Jan': 31,'Feb':cint(feb), 'Mar':31,'Apr':30,'May':31,'June':30,'July':31,'Aug':31,'Sept':30,'Oct':31,'Nov':30,'Dec':31}
-
-for i in range(0,dict[month]):
- colnames.append(i+1)
- coltypes.append('Data')
- colwidths.append('25px')
-
- col_idx[c[0]] = len(colnames)-1
-
-#add total present, absent days
-#--------------------------------------------------------------------------------------
-tot_col =[['Total Present Days','Data','120px'],['Total Absent Days','Data','120px']]
-
-for c in tot_col:
- colnames.append(c[0])
- coltypes.append(c[1])
- colwidths.append(c[2])
-
- col_idx[c[0]] = len(colnames)-1
-
-#get data
-#--------------------------------------------------------------------------------------
-
-
-year = last_date.strftime('%Y')
-out = []
-for r in res:
- p_cnt = a_cnt = 0
-
- for i in range(0,dict[month]):
- new_date = str(year)+'-'+mdict[month]+'-'+((i>=9) and str(i+1) or ('0'+str(i+1)))
-
- chk = sql("select status from `tabAttendance` where employee='%s' and att_date = '%s' and docstatus=1"%(r[0],new_date))
- chk = chk and chk[0][0][0] or '-'
- if chk=='P':
- p_cnt +=1
- elif chk=='A':
- a_cnt +=1
- r.append(chk)
-
- r.append(p_cnt)
- r.append(a_cnt)
-
- if p_cnt or a_cnt:
- out.append(r)
diff --git a/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.sql b/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.sql
deleted file mode 100644
index 762a94f7fbd..00000000000
--- a/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.sql
+++ /dev/null
@@ -1 +0,0 @@
-SELECT DISTINCT `tabAttendance`.employee, `tabEmployee`.employee_name FROM `tabAttendance`, `tabEmployee` WHERE `tabEmployee`.name = `tabAttendance`.employee and `tabAttendance`.fiscal_year like '%(fiscal_year)s%%' AND `tabAttendance`.company like '%(company)s%%' AND `tabAttendance`.employee like '%(employee)s%%'
\ No newline at end of file
diff --git a/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.txt b/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.txt
deleted file mode 100644
index abbacae1e93..00000000000
--- a/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "harshada@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:51"
- },
- {
- "module": "HR",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Attendance\u0001Status':'','Attendance\u0001Fiscal Year':''}",
- "doctype": "Search Criteria",
- "doc_type": "Attendance",
- "name": "__common__",
- "sort_by": "`tabAttendance`.`employee`",
- "page_len": 50,
- "criteria_name": "Monthly Attendance Details",
- "columns": "Attendance\u0001Employee"
- },
- {
- "name": "monthly_attendance_details",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/hr/search_criteria/monthly_salary_register/__init__.py b/hr/search_criteria/monthly_salary_register/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/hr/search_criteria/monthly_salary_register/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/hr/search_criteria/monthly_salary_register/monthly_salary_register.py b/hr/search_criteria/monthly_salary_register/monthly_salary_register.py
deleted file mode 100644
index 2291b6682d3..00000000000
--- a/hr/search_criteria/monthly_salary_register/monthly_salary_register.py
+++ /dev/null
@@ -1,99 +0,0 @@
-from __future__ import unicode_literals
-colwidths[col_idx['Employee Name']]="120px"
-colwidths[col_idx['Leave Without Pay']] = '120px'
-
-sum_net = total_earning = total_deduction = total_lwp = total_arr = 0
-total = ['Total Net Pay','','']
-
-
-earn_type_lst = sql("select name from `tabEarning Type`")
-
-ded_type_lst = sql("select name from `tabDeduction Type`")
-li=[]
-for lst in earn_type_lst:
-
- li.append(lst[0])
-
-
-
-li.append('Total Earning')
-for lst in ded_type_lst:
-
- li.append(lst[0])
-
-
-li.append('Total Deduction')
-li.append('Net Pay')
-
-
-
-for d in li:
- colnames.append(d)
- colwidths.append("150px")
- coltypes.append("Currency")
- coloptions.append("")
- col_idx[d] = len(colnames)-1
- for r in res:
- r.append("0")
-
-for r in res:
-
- total_lwp += flt(r[col_idx['Leave Without Pay']])
- total_arr += flt(r[col_idx['Arrear Amount']])
-
- for d1 in li:
- d2 = '%s'%d1
-
- earn_ret=webnotes.conn.convert_to_lists(sql("select e_type,e_amount from `tabSalary Slip Earning` where parent = '%s'"%r[col_idx['ID']]))
- ded_ret=webnotes.conn.convert_to_lists(sql("select d_type,d_amount from `tabSalary Slip Deduction` where parent = '%s'"%r[col_idx['ID']]))
-
-
- for e in earn_ret:
- e0 = '%s'%e[0]
- r[col_idx[e0]]=flt(e[1]) or 0.00
-
-
- for d in ded_ret:
- d0 = '%s'%d[0]
- r[col_idx[d0]]=flt(d[1]) or 0.00
-
-
- tot_earn_ded_net_ret = sql("select gross_pay, total_deduction,net_pay from `tabSalary Slip` where name = '%s'"%r[col_idx['ID']])
- if d2 == 'Total Earning':
- r[col_idx[d2]] = flt(tot_earn_ded_net_ret[0][0]) or 0
- total_earning += flt(tot_earn_ded_net_ret[0][0]) or 0
- elif d2 == 'Total Deduction':
- r[col_idx[d2]] = flt(tot_earn_ded_net_ret[0][1]) or 0
- total_deduction += flt(tot_earn_ded_net_ret[0][1]) or 0
- elif d2 == 'Net Pay':
- r[col_idx[d2]] = flt(tot_earn_ded_net_ret[0][2]) or 0
- sum_net += flt(tot_earn_ded_net_ret[0][2]) or 0
-
-
-total.append(total_lwp)
-total.append(total_arr)
-
-for lst in earn_type_lst:
-
- total_ear = 0
- for r in res:
-
- lst0 = '%s'%lst[0]
- total_ear += flt(r[col_idx[lst0]])
-
- total.append(total_ear)
-
-total.append(total_earning)
-for lst in ded_type_lst:
- total_ded = 0
- for r in res:
- lst0 = '%s'%lst[0]
- total_ded += flt(r[col_idx[lst0]])
-
- total.append(total_ded)
-
-
-total.append(total_deduction)
-total.append(sum_net)
-
-res.append(total)
diff --git a/hr/search_criteria/monthly_salary_register/monthly_salary_register.txt b/hr/search_criteria/monthly_salary_register/monthly_salary_register.txt
deleted file mode 100644
index 2e1db8c7cf2..00000000000
--- a/hr/search_criteria/monthly_salary_register/monthly_salary_register.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-03-30 14:50:44",
- "modified_by": "Administrator",
- "modified": "2012-04-05 17:23:13"
- },
- {
- "module": "HR",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{\"Salary Slip\\u0001Submitted\":1,\"Salary Slip\\u0001Company\":[\"\"],\"Salary Slip\\u0001Month\":[\"\"]}",
- "doctype": "Search Criteria",
- "doc_type": "Salary Slip",
- "name": "__common__",
- "sort_by": "`tabSalary Slip`.`name`",
- "page_len": 50,
- "criteria_name": "Monthly Salary Register",
- "columns": "Salary Slip\u0001ID,Salary Slip\u0001Employee,Salary Slip\u0001Employee Name,Salary Slip\u0001Leave Without Pay,Salary Slip\u0001Arrear Amount"
- },
- {
- "name": "monthly_salary_register",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/hr/search_criteria/new_or_left_employees_for_a_month/__init__.py b/hr/search_criteria/new_or_left_employees_for_a_month/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/hr/search_criteria/new_or_left_employees_for_a_month/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/hr/search_criteria/new_or_left_employees_for_a_month/new_or_left_employees_for_a_month.js b/hr/search_criteria/new_or_left_employees_for_a_month/new_or_left_employees_for_a_month.js
deleted file mode 100644
index e6dc2675e70..00000000000
--- a/hr/search_criteria/new_or_left_employees_for_a_month/new_or_left_employees_for_a_month.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- var d = new Date();
-
- var month=["January","February","March","April","May","June","July","August","September","October","November","December"]
-
- this.add_filter({fieldname:'month', label:'Month',fieldtype:'Select', options:"January"+NEWLINE+"February"+NEWLINE+"March"+NEWLINE+"April"+NEWLINE+"May"+NEWLINE+"June"+NEWLINE+"July"+NEWLINE+"August"+NEWLINE+"September"+NEWLINE+"October"+NEWLINE+"November"+NEWLINE+"December",report_default : month[d.getMonth()],ignore : 1, parent:'Employee'});
-
- this.filter_fields_dict['Employee'+FILTER_SEP +'Month'].df.in_first_page = 1;
- this.filter_fields_dict['Employee'+FILTER_SEP +'Status'].df.in_first_page = 1;
- this.filter_fields_dict['Employee'+FILTER_SEP +'Status'].df.report_default = 'Active';
-
- this.add_filter({fieldname:'year', label:'Year',fieldtype:'Select', options:"2000"+NEWLINE+"2001"+NEWLINE+"2002"+NEWLINE+"2003"+NEWLINE+"2004"+NEWLINE+"2005"+NEWLINE+"2006"+NEWLINE+"2007"+NEWLINE+"2008"+NEWLINE+"2009"+NEWLINE+"2010"+NEWLINE+"2011",report_default : d.getFullYear(),ignore : 1, parent:'Employee'});
-
- this.filter_fields_dict['Employee'+FILTER_SEP +'Year'].df.in_first_page = 1;
-}
-
-report.get_query = function() {
-
- emp_month = this.filter_fields_dict['Employee'+FILTER_SEP+'Month'].get_value();
- emp_year = this.filter_fields_dict['Employee'+FILTER_SEP+'Year'].get_value();
- emp_status = this.filter_fields_dict['Employee'+FILTER_SEP+'Status'].get_value();
-
- // month and year mandatory
- if ((emp_month == '') || (emp_year == '')) {
- alert("Please enter Month and Year");
- return;
- }
-
- month={"January":"1", "February":"2", "March":"3", "April":"4","May":"5", "June":"6", "July":"7","August":"8", "September":"9", "October":"10", "November":"11", "December":"12"}
-
- mnt = ''
- for(m=0; m.
-
-from __future__ import unicode_literals
-status = filter_values.get('status')
-month = filter_values.get('month')
-
-
-if status == 'Active' and not status == 'Left':
- col = [['Employee', 'Link', 'Employee'], ['Employee Name', 'Data', ''], ['Employee Number', 'Data', ''], ['Employment Type','Link','Employment Type'],['Scheduled Confirmation Date','Data',''],['Final Confirmation Date','Data',''],['Contract End Date','Data',''],['Branch','Link','Branch'],['Department','Link','Department'],['Designation','Link','Designation'],['Reports to','Link','Employee'],['Grade','Link','Grade']]
-
-elif status == 'Left' and not status == 'Active':
- col = [['Employee', 'Link', 'Employee'], ['Employee Name', 'Data', ''], ['Employee Number', 'Data', ''], ['Resignation Letter Date','Data',''],['Relieving Date','Data',''],['Notice - Number of Days','Data',''],['Reason for Leaving','Data',''],['Leave Encashed?','Data',''],['Encashment Date','Data',''],['Reason for Resignation','Data','']]
-
-else:
- col = [['Employee', 'Link', 'Employee'], ['Employee Name', 'Data', ''], ['Employee Number', 'Data', ''], ['Employment Type','Link','Employment Type'],['Scheduled Confirmation Date','Data',''],['Final Confirmation Date','Data',''],['Contract End Date','Data',''],['Branch','Link','Branch'],['Department','Link','Department'],['Designation','Link','Designation'],['Reports to','Link','Employee'],['Grade','Link','Grade'],['Resignation Letter Date','Data',''],['Relieving Date','Data',''],['Notice - Number of Days','Data',''],['Reason for Leaving','Data',''],['Leave Encashed?','Data',''],['Encashment Date','Data',''],['Reason for Resignation','Data','']]
-
-for c in col:
- colnames.append(c[0])
- coltypes.append(c[1])
- colwidths.append('150px')
- coloptions.append(c[2])
-
- col_idx[c[0]] = len(colnames)-1
-
-
-for c in range(0,len(colnames)):
- l = (len(colnames[c])*9)
- if l < 150 : col_width = '150px'
- else: col_width = '%spx'%(l)
-
- colwidths[c] = col_width
-
-for r in res:
-
- if status == 'Active':
- ret = sql("select employment_type,scheduled_confirmation_date,final_confirmation_date,contract_end_date,branch,department,designation,reports_to,grade from `tabEmployee` where name = %s",r[0])
-
- elif status == 'Left':
- ret = sql("select resignation_letter_date,relieving_date,notice_number_of_days,reason_for_leaving,leave_encashed,encashment_date,reason_for_resignation from `tabEmployee` where name =%s",r[0])
-
- else:
- ret = sql("select employment_type,scheduled_confirmation_date,final_confirmation_date,contract_end_date,branch,department,designation,reports_to,grade,resignation_letter_date,relieving_date,notice_number_of_days,reason_for_leaving,leave_encashed,encashment_date,reason_for_resignation from `tabEmployee` where name = %s",r[0])
-
- ret = ret and ret[0] or []
- for t in ret:
- r.append(cstr(t))
diff --git a/hr/search_criteria/new_or_left_employees_for_a_month/new_or_left_employees_for_a_month.txt b/hr/search_criteria/new_or_left_employees_for_a_month/new_or_left_employees_for_a_month.txt
deleted file mode 100644
index 86d09b53722..00000000000
--- a/hr/search_criteria/new_or_left_employees_for_a_month/new_or_left_employees_for_a_month.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "harshada@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:51"
- },
- {
- "module": "HR",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Employee\u0001Saved':1,'Employee\u0001Submitted':1,'Employee\u0001Gender':'','Employee\u0001Month of Birth':'','Employee\u0001Status':''}",
- "doctype": "Search Criteria",
- "doc_type": "Employee",
- "name": "__common__",
- "sort_by": "`tabEmployee`.`name`",
- "page_len": 50,
- "criteria_name": "New or left employees for a month",
- "columns": "Employee\u0001ID"
- },
- {
- "name": "new_or_left_employees_for_a_month",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/hr/search_criteria/salary_register/__init__.py b/hr/search_criteria/salary_register/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/hr/search_criteria/salary_register/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/hr/search_criteria/salary_register/salary_register.js b/hr/search_criteria/salary_register/salary_register.js
deleted file mode 100644
index c451b272f75..00000000000
--- a/hr/search_criteria/salary_register/salary_register.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- fld_lst = ['ID','Employee']
-
- for(var i = 0; i.
-
-from __future__ import unicode_literals
-sal_slips_ids = ''
-for r in res:
- if not sal_slips_ids == '': sal_slips_ids +=","
- sal_slips_ids+="'%s'"%r[col_idx['ID']]
-
-earn_heads, ded_heads = [], []
-if res:
- earn_heads =[i[0] for i in sql("select distinct e_type from `tabSalary Slip Earning` where parent in (%s)"%sal_slips_ids)]
- ded_heads =[i[0] for i in sql("select distinct d_type from `tabSalary Slip Deduction` where parent in (%s)"%sal_slips_ids)]
-
-col=[]
-for e in earn_heads:
- l = (len(cstr(e))*9)
- if l < 150 :
- col_width = '150px'
- else:
- col_width = '%spx'%(l)
- col.append([e,'Currency',col_width,''])
-
-col.append(['Arrear Amount','Currency','150px',''])
-col.append(['Encashment Amount','Currency','170px',''])
-col.append(['Gross Pay','Currency','150px',''])
-for d in ded_heads:
- l = (len(cstr(d))*9)
- if l < 150 : col_width = '150px'
- else: col_width = '%spx'%(l)
- col.append([d,'Currency',col_width,''])
-
-col.append(['Total Deduction','Currency','150px',''])
-col.append(['Net Pay','Currency','150px',''])
-
-for c in col:
- colnames.append(c[0])
- coltypes.append(c[1])
- colwidths.append(c[2])
- coloptions.append(c[3])
- col_idx[c[0]] = len(colnames)
-
-grand_tot = 0
-for r in res:
- for i in range(6,len(colnames)):
- if colnames[i] not in ('Arrear Amount','Encashment Amount','Net Pay','Gross Pay','Total Deduction'):
- amt = sql("select e_modified_amount from `tabSalary Slip Earning` where e_type = '%s' and parent = '%s'"%(colnames[i],r[0]))
- if not amt:
- amt = sql("select d_modified_amount from `tabSalary Slip Deduction` where d_type = '%s' and parent = '%s'"%(colnames[i],r[0]))
- amt = amt and amt[0][0] or 0
- r.append(flt(amt))
-
- else:
- fld_nm = cstr(colnames[i]).lower().replace(' ','_')
- tot = sql("select %s from `tabSalary Slip` where name ='%s'"%(fld_nm,r[0]))
- tot = tot and flt(tot[0][0]) or 0
- if colnames[i] == 'Net Pay':
- grand_tot += tot
- r.append(tot)
-
-gt_row = ['' for i in range(len(colnames))]
-gt_row[col_idx['Employee Name']] = 'Grand Totals'
-gt_row[col_idx['Net Pay']-1] = grand_tot
-res.append(gt_row)
\ No newline at end of file
diff --git a/hr/search_criteria/salary_register/salary_register.txt b/hr/search_criteria/salary_register/salary_register.txt
deleted file mode 100644
index aab7f2518e5..00000000000
--- a/hr/search_criteria/salary_register/salary_register.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "harshada@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "module": "HR",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Salary Slip\u0001Submitted':1,'Salary Slip\u0001Month':''}",
- "doctype": "Search Criteria",
- "doc_type": "Salary Slip",
- "name": "__common__",
- "sort_by": "`tabSalary Slip`.`name`",
- "page_len": 50,
- "criteria_name": "Salary Register",
- "columns": "Salary Slip\u0001ID,Salary Slip\u0001Employee,Salary Slip\u0001Employee Name,Salary Slip\u0001Year,Salary Slip\u0001Month,Salary Slip\u0001Total days in month,Salary Slip\u0001Payment days"
- },
- {
- "name": "salary_register",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/hr/search_criteria/salary_slips/__init__.py b/hr/search_criteria/salary_slips/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/hr/search_criteria/salary_slips/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/hr/search_criteria/salary_slips/salary_slips.txt b/hr/search_criteria/salary_slips/salary_slips.txt
deleted file mode 100644
index e1bcccf2590..00000000000
--- a/hr/search_criteria/salary_slips/salary_slips.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "module": "HR",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Salary Slip\u0001Saved':1,'Salary Slip\u0001Submitted':1}",
- "doctype": "Search Criteria",
- "doc_type": "Salary Slip",
- "name": "__common__",
- "sort_by": "`tabSalary Slip`.`name`",
- "page_len": 50,
- "criteria_name": "Salary Slips",
- "columns": "Salary Slip\u0001ID,Salary Slip\u0001Fiscal Year,Salary Slip\u0001Month,Salary Slip\u0001Employee,Salary Slip\u0001Employee Name,Salary Slip\u0001Department,Salary Slip\u0001Designation,Salary Slip\u0001Branch,Salary Slip\u0001Grade,Salary Slip\u0001PF No.,Salary Slip\u0001ESIC No.,Salary Slip\u0001Leave Without Pay,Salary Slip\u0001Bank Name,Salary Slip\u0001Bank Account No.,Salary Slip\u0001Payment days,Salary Slip\u0001Arrear Amount,Salary Slip\u0001Encashment Amount,Salary Slip\u0001Gross Pay,Salary Slip\u0001Total Deduction,Salary Slip\u0001Net Pay"
- },
- {
- "name": "salary_slips",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/hr/search_criteria/salary_structure_details/__init__.py b/hr/search_criteria/salary_structure_details/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/hr/search_criteria/salary_structure_details/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/hr/search_criteria/salary_structure_details/salary_structure_details.txt b/hr/search_criteria/salary_structure_details/salary_structure_details.txt
deleted file mode 100644
index c1ed01bc842..00000000000
--- a/hr/search_criteria/salary_structure_details/salary_structure_details.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "module": "HR",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Salary Structure\u0001Branch':'','Salary Structure\u0001Designation':'','Salary Structure\u0001Department':'','Salary Structure\u0001Grade':'','Salary Structure\u0001Is Active':''}",
- "doctype": "Search Criteria",
- "doc_type": "Salary Structure",
- "name": "__common__",
- "sort_by": "`tabSalary Structure`.`name`",
- "page_len": 50,
- "criteria_name": "Salary Structure Details",
- "columns": "Salary Structure\u0001ID,Salary Structure\u0001Employee,Salary Structure\u0001From Date,Salary Structure\u0001To Date,Salary Structure\u0001Fiscal Year,Salary Structure\u0001Branch,Salary Structure\u0001Designation,Salary Structure\u0001Department,Salary Structure\u0001Grade,Salary Structure\u0001Is Active,Salary Structure\u0001Total Earning,Salary Structure\u0001Total Deduction,Salary Structure\u0001CTC,Salary Structure\u0001Total"
- },
- {
- "name": "salary_structure_details",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/manufacturing/doctype/bom/bom.js b/manufacturing/doctype/bom/bom.js
index 4e8fbc95d16..b1f43f76207 100644
--- a/manufacturing/doctype/bom/bom.js
+++ b/manufacturing/doctype/bom/bom.js
@@ -59,27 +59,22 @@ cur_frm.fields_dict["bom_operations"].grid.on_row_delete = function(cdt, cdn){
set_operation_no(doc);
}
-cur_frm.cscript.item = function(doc, dt, dn) {
- if (doc.item) {
- get_server_fields('get_item_details', doc.item, '', doc, dt, dn, 1);
- }
-}
+cur_frm.add_fetch("item", "description", "description");
+cur_frm.add_fetch("item", "stock_uom", "uom");
cur_frm.cscript.workstation = function(doc,dt,dn) {
var d = locals[dt][dn];
- if (d.workstation) {
- var callback = function(r, rt) {
- calculate_op_cost(doc, dt, dn);
- calculate_total(doc);
- }
- get_server_fields('get_workstation_details', d.workstation,
- 'bom_operations', doc, dt, dn, 1, callback);
- }
+ wn.model.with_doc("Workstation", d.workstation, function(i, r) {
+ d.hour_rate = r.docs[0].hour_rate;
+ refresh_field("hour_rate", dn, "bom_operations");
+ calculate_op_cost(doc);
+ calculate_total(doc);
+ });
}
cur_frm.cscript.hour_rate = function(doc, dt, dn) {
- calculate_op_cost(doc, dt, dn);
+ calculate_op_cost(doc);
calculate_total(doc);
}
@@ -114,7 +109,7 @@ var get_bom_material_detail= function(doc, cdt, cdn) {
$.extend(d, r.message);
refresh_field("bom_materials");
doc = locals[doc.doctype][doc.name];
- calculate_rm_cost(doc, cdt, cdn);
+ calculate_rm_cost(doc);
calculate_total(doc);
},
freeze: true
@@ -124,7 +119,7 @@ var get_bom_material_detail= function(doc, cdt, cdn) {
cur_frm.cscript.qty = function(doc, cdt, cdn) {
- calculate_rm_cost(doc, cdt, cdn);
+ calculate_rm_cost(doc);
calculate_total(doc);
}
@@ -134,12 +129,12 @@ cur_frm.cscript.rate = function(doc, cdt, cdn) {
msgprint("You can not change rate if BOM mentioned agianst any item");
get_bom_material_detail(doc, cdt, cdn);
} else {
- calculate_rm_cost(doc, cdt, cdn);
+ calculate_rm_cost(doc);
calculate_total(doc);
}
}
-var calculate_op_cost = function(doc, dt, dn) {
+var calculate_op_cost = function(doc) {
var op = getchildren('BOM Operation', doc.name, 'bom_operations');
total_op_cost = 0;
for(var i=0;i '%s' cannot be '%s' of '%s'.
- """ % (cstr(b), cstr(d[2]), self.doc.name), raise_exception = 1)
+ """ % (cstr(b[0]), cstr(d[2]), self.doc.name), raise_exception = 1)
if b[0]:
bom_list.append(b[0])
- def update_cost_and_exploded_items(self):
- bom_list = self.traverse_tree()
+ def update_cost_and_exploded_items(self, bom_list=[]):
+ bom_list = self.traverse_tree(bom_list)
for bom in bom_list:
bom_obj = get_obj("BOM", bom, with_children=1)
bom_obj.on_update()
- def traverse_tree(self):
+ return bom_list
+
+ def traverse_tree(self, bom_list=[]):
def _get_children(bom_no):
return [cstr(d[0]) for d in webnotes.conn.sql("""select bom_no from `tabBOM Item`
where parent = %s and ifnull(bom_no, '') != ''""", bom_no)]
- bom_list, count = [self.doc.name], 0
+ count = 0
+ if self.doc.name not in bom_list:
+ bom_list.append(self.doc.name)
+
while(count < len(bom_list)):
for child_bom in _get_children(bom_list[count]):
if child_bom not in bom_list:
@@ -293,9 +305,10 @@ class DocType:
"""Update workstation rate and calculates totals"""
total_op_cost = 0
for d in getlist(self.doclist, 'bom_operations'):
+ if d.workstation and not d.hour_rate:
+ d.hour_rate = webnotes.conn.get_value("Workstation", d.workstation, "hour_rate")
if d.hour_rate and d.time_in_mins:
d.operating_cost = flt(d.hour_rate) * flt(d.time_in_mins) / 60.0
- d.save()
total_op_cost += flt(d.operating_cost)
self.doc.operating_cost = total_op_cost
@@ -307,7 +320,6 @@ class DocType:
d.rate = self.get_bom_unitcost(d.bom_no)
d.amount = flt(d.rate) * flt(d.qty)
d.qty_consumed_per_unit = flt(d.qty) / flt(self.doc.quantity)
- d.save()
total_rm_cost += d.amount
self.doc.raw_material_cost = total_rm_cost
@@ -318,52 +330,50 @@ class DocType:
def get_exploded_items(self):
""" Get all raw materials including items from child bom"""
- self.cur_exploded_items = []
+ self.cur_exploded_items = {}
for d in getlist(self.doclist, 'bom_materials'):
if d.bom_no:
self.get_child_exploded_items(d.bom_no, d.qty)
else:
- self.cur_exploded_items.append({
+ self.add_to_cur_exploded_items(webnotes._dict({
'item_code' : d.item_code,
'description' : d.description,
'stock_uom' : d.stock_uom,
'qty' : flt(d.qty),
- 'rate' : flt(d.rate),
- 'amount' : flt(d.amount),
- 'parent_bom' : d.parent,
- 'mat_detail_no' : d.name,
- 'qty_consumed_per_unit' : flt(d.qty_consumed_per_unit)
- })
+ 'rate' : flt(d.rate),
+ }))
+
+ def add_to_cur_exploded_items(self, args):
+ if self.cur_exploded_items.get(args.item_code):
+ self.cur_exploded_items[args.item_code]["qty"] += args.qty
+ else:
+ self.cur_exploded_items[args.item_code] = args
def get_child_exploded_items(self, bom_no, qty):
""" Add all items from Flat BOM of child BOM"""
child_fb_items = sql("""select item_code, description, stock_uom, qty, rate,
- amount, parent_bom, mat_detail_no, qty_consumed_per_unit
- from `tabBOM Explosion Item` where parent = '%s' and docstatus = 1""" %
- bom_no, as_dict = 1)
+ qty_consumed_per_unit from `tabBOM Explosion Item`
+ where parent = %s and docstatus = 1""", bom_no, as_dict = 1)
+
for d in child_fb_items:
- self.cur_exploded_items.append({
+ self.add_to_cur_exploded_items(webnotes._dict({
'item_code' : d['item_code'],
'description' : d['description'],
'stock_uom' : d['stock_uom'],
'qty' : flt(d['qty_consumed_per_unit'])*qty,
- 'rate' : flt(d['rate']),
- 'amount' : flt(d['amount']),
- 'parent_bom' : d['parent_bom'],
- 'mat_detail_no' : d['mat_detail_no'],
- 'qty_consumed_per_unit' : flt(d['qty_consumed_per_unit'])*qty/flt(self.doc.quantity)
-
- })
+ 'rate' : flt(d['rate']),
+ }))
def add_exploded_items(self):
"Add items to Flat BOM table"
self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details', 1)
for d in self.cur_exploded_items:
- ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item',
- self.doclist)
- for i in d.keys():
- ch.fields[i] = d[i]
+ ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', self.doclist)
+ for i in self.cur_exploded_items[d].keys():
+ ch.fields[i] = self.cur_exploded_items[d][i]
+ ch.amount = flt(ch.qty) * flt(ch.rate)
+ ch.qty_consumed_per_unit = flt(ch.qty) / flt(self.doc.quantity)
ch.docstatus = self.doc.docstatus
ch.save(1)
diff --git a/manufacturing/doctype/bom/test_bom.py b/manufacturing/doctype/bom/test_bom.py
index e742c0c8acb..cb91e78cc55 100644
--- a/manufacturing/doctype/bom/test_bom.py
+++ b/manufacturing/doctype/bom/test_bom.py
@@ -48,134 +48,4 @@ test_records = [
"stock_uom": "No."
}
]
-]
-
-
-
-# import webnotes.model
-# from webnotes.utils import nowdate, flt
-# from accounts.utils import get_fiscal_year
-# from webnotes.model.doclist import DocList
-# import copy
-#
-# company = webnotes.conn.get_default("company")
-#
-#
-# def load_data():
-#
-# # create default warehouse
-# if not webnotes.conn.exists("Warehouse", "Default Warehouse"):
-# webnotes.insert({"doctype": "Warehouse",
-# "warehouse_name": "Default Warehouse",
-# "warehouse_type": "Stores"})
-#
-# # create UOM: Nos.
-# if not webnotes.conn.exists("UOM", "Nos"):
-# webnotes.insert({"doctype": "UOM", "uom_name": "Nos"})
-#
-# from webnotes.tests import insert_test_data
-# # create item groups and items
-# insert_test_data("Item Group",
-# sort_fn=lambda ig: (ig[0].get('parent_item_group'), ig[0].get('name')))
-# insert_test_data("Item")
-#
-# base_bom_fg = [
-# {"doctype": "BOM", "item": "Android Jack D", "quantity": 1,
-# "is_active": "Yes", "is_default": 1, "uom": "Nos"},
-# {"doctype": "BOM Operation", "operation_no": 1, "parentfield": "bom_operations",
-# "opn_description": "Development", "hour_rate": 10, "time_in_mins": 90},
-# {"doctype": "BOM Item", "item_code": "Home Desktop 300", "operation_no": 1,
-# "qty": 2, "rate": 20, "stock_uom": "Nos", "parentfield": "bom_materials"},
-# {"doctype": "BOM Item", "item_code": "Home Desktop 100", "operation_no": 1,
-# "qty": 1, "rate": 300, "stock_uom": "Nos", "parentfield": "bom_materials"},
-# {"doctype": "BOM Item", "item_code": "Nebula 7", "operation_no": 1,
-# "qty": 5, "stock_uom": "Nos", "parentfield": "bom_materials"},
-# ]
-#
-# base_bom_child = [
-# {"doctype": "BOM", "item": "Nebula 7", "quantity": 5,
-# "is_active": "Yes", "is_default": 1, "uom": "Nos"},
-# {"doctype": "BOM Operation", "operation_no": 1, "parentfield": "bom_operations",
-# "opn_description": "Development"},
-# {"doctype": "BOM Item", "item_code": "Android Jack S", "operation_no": 1,
-# "qty": 10, "stock_uom": "Nos", "parentfield": "bom_materials"}
-# ]
-#
-# base_bom_grandchild = [
-# {"doctype": "BOM", "item": "Android Jack S", "quantity": 1,
-# "is_active": "Yes", "is_default": 1, "uom": "Nos"},
-# {"doctype": "BOM Operation", "operation_no": 1, "parentfield": "bom_operations",
-# "opn_description": "Development"},
-# {"doctype": "BOM Item", "item_code": "Home Desktop 300", "operation_no": 1,
-# "qty": 3, "rate": 10, "stock_uom": "Nos", "parentfield": "bom_materials"}
-# ]
-#
-#
-# class TestPurchaseReceipt(unittest.TestCase):
-# def setUp(self):
-# webnotes.conn.begin()
-# load_data()
-#
-# def test_bom_validation(self):
-# # show throw error bacause bom no missing for sub-assembly item
-# bom_fg = copy.deepcopy(base_bom_fg)
-# self.assertRaises(webnotes.ValidationError, webnotes.insert, DocList(bom_fg))
-#
-# # main item is not a manufacturing item
-# bom_fg = copy.deepcopy(base_bom_fg)
-# bom_fg[0]["item"] = "Home Desktop 200"
-# bom_fg.pop(4)
-# self.assertRaises(webnotes.ValidationError, webnotes.insert, DocList(bom_fg))
-#
-# # operation no mentioed in material table not matching with operation table
-# bom_fg = copy.deepcopy(base_bom_fg)
-# bom_fg.pop(4)
-# bom_fg[2]["operation_no"] = 2
-# self.assertRaises(webnotes.ValidationError, webnotes.insert, DocList(bom_fg))
-#
-#
-# def test_bom(self):
-# gc_wrapper = webnotes.insert(DocList(base_bom_grandchild))
-# gc_wrapper.submit()
-#
-# bom_child = copy.deepcopy(base_bom_child)
-# bom_child[2]["bom_no"] = gc_wrapper.doc.name
-# child_wrapper = webnotes.insert(DocList(bom_child))
-# child_wrapper.submit()
-#
-# bom_fg = copy.deepcopy(base_bom_fg)
-# bom_fg[4]["bom_no"] = child_wrapper.doc.name
-# fg_wrapper = webnotes.insert(DocList(bom_fg))
-# fg_wrapper.load_from_db()
-#
-# self.check_bom_cost(fg_wrapper)
-#
-# self.check_flat_bom(fg_wrapper, child_wrapper, gc_wrapper)
-#
-# def check_bom_cost(self, fg_wrapper):
-# expected_values = {
-# "operating_cost": 15,
-# "raw_material_cost": 640,
-# "total_cost": 655
-# }
-#
-# for key in expected_values:
-# self.assertEqual(flt(expected_values[key]), flt(fg_wrapper.doc.fields.get(key)))
-#
-# def check_flat_bom(self, fg_wrapper, child_wrapper, gc_wrapper):
-# expected_flat_bom_items = {
-# ("Home Desktop 300", fg_wrapper.doc.name): (2, 20),
-# ("Home Desktop 100", fg_wrapper.doc.name): (1, 300),
-# ("Home Desktop 300", gc_wrapper.doc.name): (30, 10)
-# }
-#
-# self.assertEqual(len(fg_wrapper.doclist.get({"parentfield": "flat_bom_details"})), 3)
-#
-# for key, val in expected_flat_bom_items.items():
-# flat_bom = fg_wrapper.doclist.get({"parentfield": "flat_bom_details",
-# "item_code": key[0], "parent_bom": key[1]})[0]
-# self.assertEqual(val, (flat_bom.qty, flat_bom.rate))
-#
-#
-# def tearDown(self):
-# webnotes.conn.rollback()
\ No newline at end of file
+]
\ No newline at end of file
diff --git a/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt b/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt
index 07aad7dc66f..3808cdfb00f 100644
--- a/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt
+++ b/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-02-22 01:27:48",
+ "creation": "2013-03-07 11:42:57",
"docstatus": 0,
- "modified": "2013-03-07 07:03:18",
+ "modified": "2013-06-04 13:13:28",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -80,25 +80,6 @@
"oldfieldtype": "Link",
"options": "UOM"
},
- {
- "doctype": "DocField",
- "fieldname": "parent_bom",
- "fieldtype": "Link",
- "hidden": 0,
- "label": "Parent BOM",
- "oldfieldname": "parent_bom",
- "oldfieldtype": "Link",
- "options": "BOM",
- "print_width": "250px",
- "width": "250px"
- },
- {
- "doctype": "DocField",
- "fieldname": "mat_detail_no",
- "fieldtype": "Data",
- "hidden": 1,
- "label": "Mat Detail No"
- },
{
"doctype": "DocField",
"fieldname": "qty_consumed_per_unit",
diff --git a/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
index 177adcda83b..e69c48723d3 100644
--- a/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
+++ b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
@@ -29,9 +29,10 @@ class DocType:
self.validate_bom()
self.update_new_bom()
bom_list = self.get_parent_boms()
+ updated_bom = []
for bom in bom_list:
bom_obj = get_obj("BOM", bom, with_children=1)
- bom_obj.update_cost_and_exploded_items()
+ updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom)
webnotes.msgprint(_("BOM replaced"))
@@ -46,11 +47,7 @@ class DocType:
webnotes.conn.sql("""update `tabBOM Item` set bom_no=%s,
rate=%s, amount=qty*%s where bom_no = %s and docstatus < 2""",
(self.doc.new_bom, current_bom_unitcost, current_bom_unitcost, self.doc.current_bom))
-
- def get_parent_boms(bom_no):
- return [d[0] for d in webnotes.conn.sql("""select distinct parent from
- `tabBOM Item` where ifnull(bom_no, '')=%s and docstatus < 2""", bom_no)]
-
+
def get_parent_boms(self):
return [d[0] for d in webnotes.conn.sql("""select distinct parent
from `tabBOM Item` where ifnull(bom_no, '') = %s and docstatus < 2""",
diff --git a/manufacturing/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py
index a0498e063f5..c76a87f6b86 100644
--- a/manufacturing/doctype/production_order/production_order.py
+++ b/manufacturing/doctype/production_order/production_order.py
@@ -18,9 +18,6 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt, now, nowdate
-from webnotes.model import db_exists
-from webnotes.model.doc import make_autoname
-from webnotes.model.bean import copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint
diff --git a/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/manufacturing/doctype/production_planning_tool/production_planning_tool.py
index 1686478f645..ed7f7bfb3f8 100644
--- a/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -241,40 +241,30 @@ class DocType:
def get_raw_materials(self, bom_dict):
""" Get raw materials considering sub-assembly items
{
- "item_code": [qty_required, description, stock_uom]
+ "item_code": [qty_required, description, stock_uom, min_order_qty]
}
"""
for bom in bom_dict:
if self.doc.use_multi_level_bom:
# get all raw materials with sub assembly childs
- fl_bom_items = sql("""
- select
- item_code,ifnull(sum(qty_consumed_per_unit),0)*%s as qty,
- description, stock_uom, min_order_qty
- from
- (
- select distinct fb.name, fb.description, fb.item_code,
- fb.qty_consumed_per_unit, fb.stock_uom, it.min_order_qty
- from `tabBOM Explosion Item` fb,`tabItem` it
- where it.name = fb.item_code
- and ifnull(it.is_pro_applicable, 'No') = 'No'
- and ifnull(it.is_sub_contracted_item, 'No') = 'No'
- and fb.docstatus<2 and fb.parent=%s
- ) a
- group by item_code,stock_uom
- """ , (flt(bom_dict[bom]), bom))
+ fl_bom_items = sql("""select fb.item_code,
+ ifnull(sum(fb.qty_consumed_per_unit), 0)*%s as qty,
+ fb.description, fb.stock_uom, it.min_order_qty
+ from `tabBOM Explosion Item` fb,`tabItem` it
+ where it.name = fb.item_code and ifnull(it.is_pro_applicable, 'No') = 'No'
+ and ifnull(it.is_sub_contracted_item, 'No') = 'No'
+ and fb.docstatus<2 and fb.parent=%s
+ group by item_code, stock_uom""", (flt(bom_dict[bom]), bom))
else:
# Get all raw materials considering SA items as raw materials,
# so no childs of SA items
- fl_bom_items = sql("""
- select bom_item.item_code,
+ fl_bom_items = sql("""select bom_item.item_code,
ifnull(sum(bom_item.qty_consumed_per_unit), 0) * %s,
bom_item.description, bom_item.stock_uom, item.min_order_qty
from `tabBOM Item` bom_item, tabItem item
where bom_item.parent = %s and bom_item.docstatus < 2
- and bom_item.item_code = item.name
- group by item_code
- """, (flt(bom_dict[bom]), bom))
+ and bom_item.item_code = item.name
+ group by item_code""", (flt(bom_dict[bom]), bom))
self.make_items_dict(fl_bom_items)
def make_items_dict(self, item_list):
@@ -317,9 +307,9 @@ class DocType:
items_to_be_requested = webnotes._dict()
for item in self.item_dict:
- if flt(self.item_dict[item][0]) > item_projected_qty[item]:
+ if flt(self.item_dict[item][0]) > item_projected_qty.get(item, 0):
# shortage
- requested_qty = flt(self.item_dict[item][0]) - item_projected_qty[item]
+ requested_qty = flt(self.item_dict[item][0]) - item_projected_qty.get(item, 0)
# comsider minimum order qty
requested_qty = requested_qty > flt(self.item_dict[item][3]) and \
requested_qty or flt(self.item_dict[item][3])
@@ -379,4 +369,4 @@ class DocType:
webnotes.msgprint("Following Material Request created successfully: \n%s" %
"\n".join(pur_req))
else:
- webnotes.msgprint("Nothing to request")
\ No newline at end of file
+ webnotes.msgprint("Nothing to request")
diff --git a/manufacturing/page/manufacturing_home/manufacturing_home.js b/manufacturing/page/manufacturing_home/manufacturing_home.js
index b7f28edc411..d4841df2fba 100644
--- a/manufacturing/page/manufacturing_home/manufacturing_home.js
+++ b/manufacturing/page/manufacturing_home/manufacturing_home.js
@@ -58,6 +58,17 @@ wn.module_page["Manufacturing"] = [
},
]
},
+ {
+ title: wn._("Reports"),
+ right: true,
+ icon: "icon-list",
+ items: [
+ {
+ "label":wn._("Issued Items Against Production Order"),
+ route: "query-report/Issued Items Against Production Order",
+ },
+ ]
+ }
]
pscript['onload_manufacturing-home'] = function(wrapper) {
diff --git a/manufacturing/report/__init__.py b/manufacturing/report/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/manufacturing/report/issued_items_against_production_order/__init__.py b/manufacturing/report/issued_items_against_production_order/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt b/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt
new file mode 100644
index 00000000000..a5a03bfa00d
--- /dev/null
+++ b/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt
@@ -0,0 +1,23 @@
+[
+ {
+ "creation": "2013-05-03 17:48:46",
+ "docstatus": 0,
+ "modified": "2013-05-07 11:49:56",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "add_total_row": 0,
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "query": "select\n ste.production_order as \"Production Order:Link/Production Order:120\",\n ste.posting_date as \"Issue Date:Date:140\",\n ste_item.item_code as \"Item Code:Link/Item:120\",\n\tste_item.description as \"Description::150\",\n\tste_item.transfer_qty as \"Qty:Float:100\",\n\tste_item.stock_uom as \"UOM:Link/UOM:80\",\n\tste_item.amount as \"Amount:Currency:120\",\n\tste_item.serial_no as \"Serial No:Link/Serial No:80\",\n\tste_item.s_warehouse as \"Source Warehouse:Link/Warehouse:120\",\n\tste_item.t_warehouse as \"Target Warehouse:Link/Warehouse:120\",\n\tpro.production_item as \"Finished Goods:Link/Item:120\", \n\tste.name as \"Stock Entry:Link/Stock Entry:120\"\nfrom\n\t`tabStock Entry` ste, `tabStock Entry Detail` ste_item, `tabProduction Order` pro\nwhere\n\tifnull(ste.production_order, '') != '' and ste.name = ste_item.parent \n\tand ste.production_order = pro.name and ste.docstatus = 1 \n\tand ste.purpose = 'Manufacture/Repack'\norder by ste.posting_date, ste.production_order, ste_item.item_code",
+ "ref_doctype": "Production Order",
+ "report_name": "Issued Items Against Production Order",
+ "report_type": "Query Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Issued Items Against Production Order"
+ }
+]
\ No newline at end of file
diff --git a/manufacturing/search_criteria/__init__.py b/manufacturing/search_criteria/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/manufacturing/search_criteria/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/manufacturing/search_criteria/consumption_against_production/__init__.py b/manufacturing/search_criteria/consumption_against_production/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/manufacturing/search_criteria/consumption_against_production/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/manufacturing/search_criteria/consumption_against_production/consumption_against_production.txt b/manufacturing/search_criteria/consumption_against_production/consumption_against_production.txt
deleted file mode 100644
index 70620ff193f..00000000000
--- a/manufacturing/search_criteria/consumption_against_production/consumption_against_production.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-[
- {
- "owner": "jai@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:50",
- "modified_by": "Administrator",
- "modified": "2012-12-10 18:30:00"
- },
- {
- "add_col": "`tabProduction Order`.consider_sa_items",
- "parent_doc_type": "Stock Entry",
- "module": "Manufacturing",
- "standard": "Yes",
- "sort_order": "DESC",
- "add_tab": "`tabProduction Order`",
- "doc_type": "Stock Entry Detail",
- "name": "__common__",
- "filters": "{'Stock Entry\u0001Submitted':1,'Stock Entry\u0001Purpose':'Production Order','Stock Entry\u0001Process':''}",
- "add_cond": "`tabProduction Order`.name = `tabStock Entry`.production_order",
- "doctype": "Search Criteria",
- "sort_by": "`tabStock Entry`.`name`",
- "page_len": 50,
- "criteria_name": "Consumption Against Production",
- "columns": "Stock Entry\u0001ID,Stock Entry\u0001Production Order,Stock Entry\u0001Process,Stock Entry\u0001Posting Date,Stock Entry\u0001Company,Stock Entry Detail\u0001Source Warehouse,Stock Entry Detail\u0001Target Warehouse,Stock Entry Detail\u0001FG Item,Stock Entry Detail\u0001Item Code,Stock Entry Detail\u0001Description,Stock Entry Detail\u0001Reqd Qty,Stock Entry Detail\u0001Transfer Quantity"
- },
- {
- "name": "consumption_against_production",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/manufacturing/search_criteria/itemwise_production_report/__init__.py b/manufacturing/search_criteria/itemwise_production_report/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/manufacturing/search_criteria/itemwise_production_report/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/manufacturing/search_criteria/itemwise_production_report/itemwise_production_report.js b/manufacturing/search_criteria/itemwise_production_report/itemwise_production_report.js
deleted file mode 100644
index 4998fad3bdd..00000000000
--- a/manufacturing/search_criteria/itemwise_production_report/itemwise_production_report.js
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
-
- //to hide all filters
- this.hide_all_filters();
-
- // to unhide required filters
- this.filter_fields_dict['Stock Entry'+FILTER_SEP +'ID'].df.filter_hide = 0;
- this.filter_fields_dict['Stock Entry'+FILTER_SEP +'Production Order'].df.filter_hide = 0;
-
- this.filter_fields_dict['Stock Entry'+FILTER_SEP +'From Posting Date'].df.filter_hide = 0;
- this.filter_fields_dict['Stock Entry'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
-
- this.filter_fields_dict['Stock Entry Detail'+FILTER_SEP +'Target Warehouse'].df.filter_hide = 0;
-
- this.filter_fields_dict['Stock Entry Detail'+FILTER_SEP +'Item Code'].df.filter_hide = 0;
-}
\ No newline at end of file
diff --git a/manufacturing/search_criteria/itemwise_production_report/itemwise_production_report.txt b/manufacturing/search_criteria/itemwise_production_report/itemwise_production_report.txt
deleted file mode 100644
index 7814fecd5be..00000000000
--- a/manufacturing/search_criteria/itemwise_production_report/itemwise_production_report.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "jai@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-12-10 18:30:00"
- },
- {
- "parent_doc_type": "Stock Entry",
- "module": "Manufacturing",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Stock Entry\u0001Saved':1,'Stock Entry\u0001Submitted':1,'Stock Entry\u0001Purpose':'Production Order','Stock Entry\u0001Process':'Backflush','Stock Entry Detail\u0001FG Item':1}",
- "doc_type": "Stock Entry Detail",
- "name": "__common__",
- "doctype": "Search Criteria",
- "sort_by": "`tabStock Entry`.`name`",
- "page_len": 50,
- "criteria_name": "Itemwise Production Report",
- "columns": "Stock Entry\u0001ID,Stock Entry\u0001Posting Date,Stock Entry\u0001Production Order,Stock Entry\u0001Process,Stock Entry\u0001Company,Stock Entry Detail\u0001Target Warehouse,Stock Entry Detail\u0001Item Code,Stock Entry Detail\u0001Description,Stock Entry Detail\u0001Stock UOM,Stock Entry Detail\u0001Transfer Quantity"
- },
- {
- "name": "itemwise_production_report",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/manufacturing/search_criteria/production_orders_in_process/__init__.py b/manufacturing/search_criteria/production_orders_in_process/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/manufacturing/search_criteria/production_orders_in_process/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/manufacturing/search_criteria/production_orders_in_process/production_orders_in_process.txt b/manufacturing/search_criteria/production_orders_in_process/production_orders_in_process.txt
deleted file mode 100644
index 3a8c8c99d4e..00000000000
--- a/manufacturing/search_criteria/production_orders_in_process/production_orders_in_process.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "jai@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-12-10 18:30:00"
- },
- {
- "module": "Manufacturing",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Production Order\u0001Submitted':1,'Production Order\u0001Origin':'','Production Order\u0001Status':'','Production Order\u0001Consider SA Items':'','Production Order\u0001Fiscal Year':''}",
- "doc_type": "Production Order",
- "name": "__common__",
- "add_cond": "`tabProduction Order`.qty > `tabProduction Order`.produced_qty",
- "doctype": "Search Criteria",
- "sort_by": "`tabProduction Order`.`name`",
- "page_len": 50,
- "criteria_name": "Production Orders In Process",
- "columns": "Production Order\u0001ID,Production Order\u0001Origin,Production Order\u0001Status,Production Order\u0001Posting Date,Production Order\u0001Production Item,Production Order\u0001BOM No,Production Order\u0001Description,Production Order\u0001Stock UOM,Production Order\u0001Qty,Production Order\u0001Produced Qty,Production Order\u0001FG Warehouse,Production Order\u0001WIP Warehouse,Production Order\u0001Consider SA Items,Production Order\u0001Fiscal Year,Production Order\u0001Company"
- },
- {
- "name": "production_orders_in_process",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/master.sql.gz b/master.sql.gz
index f331784cf17..030ee05b2f5 100644
Binary files a/master.sql.gz and b/master.sql.gz differ
diff --git a/patches/april_2013/p05_update_file_data.py b/patches/april_2013/p05_update_file_data.py
new file mode 100644
index 00000000000..39449a62526
--- /dev/null
+++ b/patches/april_2013/p05_update_file_data.py
@@ -0,0 +1,74 @@
+import webnotes, webnotes.utils, os
+from webnotes.modules.export_file import export_to_files
+
+def execute():
+ webnotes.reload_doc("core", "doctype", "file_data")
+ webnotes.reset_perms("File Data")
+
+ singles = get_single_doctypes()
+
+ for doctype in webnotes.conn.sql_list("""select parent from tabDocField where
+ fieldname='file_list'"""):
+ # the other scenario is handled in p07_update_file_data_2
+ if doctype in singles:
+ update_file_list(doctype, singles)
+
+ # export_to_files([["DocType", doctype]])
+
+def get_single_doctypes():
+ return webnotes.conn.sql_list("""select name from tabDocType
+ where ifnull(issingle,0)=1""")
+
+def update_file_list(doctype, singles):
+ if doctype in singles:
+ doc = webnotes.doc(doctype, doctype)
+ if doc.file_list:
+ update_for_doc(doctype, doc)
+ webnotes.conn.set_value(doctype, None, "file_list", None)
+ else:
+ try:
+ for doc in webnotes.conn.sql("""select name, file_list from `tab%s` where
+ ifnull(file_list, '')!=''""" % doctype, as_dict=True):
+ update_for_doc(doctype, doc)
+ webnotes.conn.commit()
+ webnotes.conn.sql("""alter table `tab%s` drop column `file_list`""" % doctype)
+ except Exception, e:
+ print webnotes.getTraceback()
+ if (e.args and e.args[0]!=1054) or not e.args:
+ raise e
+
+def update_for_doc(doctype, doc):
+ for filedata in doc.file_list.split("\n"):
+ if not filedata:
+ continue
+
+ filedata = filedata.split(",")
+ if len(filedata)==2:
+ filename, fileid = filedata[0], filedata[1]
+ else:
+ continue
+
+ exists = True
+ if not (filename.startswith("http://") or filename.startswith("https://")):
+ if not os.path.exists(webnotes.utils.get_path("public", "files", filename)):
+ exists = False
+
+ if exists:
+ if webnotes.conn.exists("File Data", fileid):
+ try:
+ fd = webnotes.bean("File Data", fileid)
+ if not (fd.doc.attached_to_doctype and fd.doc.attached_to_name):
+ fd.doc.attached_to_doctype = doctype
+ fd.doc.attached_to_name = doc.name
+ fd.save()
+ else:
+ fd = webnotes.bean("File Data", copy=fd.doclist)
+ fd.doc.attached_to_doctype = doctype
+ fd.doc.attached_to_name = doc.name
+ fd.doc.name = None
+ fd.insert()
+ except webnotes.DuplicateEntryError:
+ pass
+ else:
+ webnotes.conn.sql("""delete from `tabFile Data` where name=%s""",
+ fileid)
\ No newline at end of file
diff --git a/patches/april_2013/p06_update_file_size.py b/patches/april_2013/p06_update_file_size.py
new file mode 100644
index 00000000000..760c3cb0449
--- /dev/null
+++ b/patches/april_2013/p06_update_file_size.py
@@ -0,0 +1,14 @@
+import webnotes, os, webnotes.utils
+
+def execute():
+ files_path = webnotes.utils.get_path("public", "files")
+ webnotes.conn.auto_commit_on_many_writes = 1
+
+ for f in webnotes.conn.sql("""select name, file_name from
+ `tabFile Data`""", as_dict=True):
+ if f.file_name:
+ filepath = os.path.join(files_path, f.file_name)
+ if os.path.exists(filepath):
+ webnotes.conn.set_value("File Data", f.name, "file_size", os.stat(filepath).st_size)
+
+ webnotes.conn.auto_commit_on_many_writes = 0
\ No newline at end of file
diff --git a/patches/april_2013/p07_update_file_data_2.py b/patches/april_2013/p07_update_file_data_2.py
new file mode 100644
index 00000000000..548ba6cdc4e
--- /dev/null
+++ b/patches/april_2013/p07_update_file_data_2.py
@@ -0,0 +1,19 @@
+import webnotes
+def execute():
+ from patches.april_2013.p05_update_file_data import update_file_list, get_single_doctypes
+
+ webnotes.conn.auto_commit_on_many_writes = 1
+
+ singles = get_single_doctypes()
+ for doctype in webnotes.conn.sql_list("""select table_name from `information_schema`.`columns`
+ where table_schema=%s and column_name='file_list'""", webnotes.conn.cur_db_name):
+ doctype = doctype[3:]
+
+ if not webnotes.conn.exists("DocType", doctype): continue
+
+ update_file_list(doctype, singles)
+
+ webnotes.conn.sql("""delete from `tabCustom Field` where fieldname='file_list'
+ and parent=%s""", doctype)
+
+ webnotes.conn.auto_commit_on_many_writes = 0
\ No newline at end of file
diff --git a/patches/april_2013/p08_price_list_country.py b/patches/april_2013/p08_price_list_country.py
new file mode 100644
index 00000000000..65643cc2399
--- /dev/null
+++ b/patches/april_2013/p08_price_list_country.py
@@ -0,0 +1,5 @@
+import webnotes
+
+def execute():
+ webnotes.reload_doc("Setup", "DocType", "Price List")
+ webnotes.conn.sql("""update `tabPrice List` set valid_for_all_countries=1""")
\ No newline at end of file
diff --git a/patches/april_2013/rebuild_sales_browser.py b/patches/april_2013/rebuild_sales_browser.py
new file mode 100644
index 00000000000..917ae684674
--- /dev/null
+++ b/patches/april_2013/rebuild_sales_browser.py
@@ -0,0 +1,4 @@
+import webnotes
+def execute():
+ from patches.january_2013 import rebuild_tree
+ rebuild_tree.execute()
\ No newline at end of file
diff --git a/patches/august_2012/change_profile_permission.py b/patches/august_2012/change_profile_permission.py
index 27169d8792a..7e945d5d9aa 100644
--- a/patches/august_2012/change_profile_permission.py
+++ b/patches/august_2012/change_profile_permission.py
@@ -31,5 +31,4 @@ def execute():
webnotes.conn.commit()
webnotes.conn.begin()
- import webnotes.model.sync
- webnotes.model.sync.sync('core', 'profile')
\ No newline at end of file
+ webnotes.reload_doc('core', 'doctype', 'profile')
\ No newline at end of file
diff --git a/patches/august_2012/changed_blog_date_format.py b/patches/august_2012/changed_blog_date_format.py
deleted file mode 100644
index df51977be5d..00000000000
--- a/patches/august_2012/changed_blog_date_format.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from __future__ import unicode_literals
-def execute():
- import webnotes
- from webnotes.model.bean import Bean
- Bean("Website Settings", "Website Settings").save()
\ No newline at end of file
diff --git a/patches/august_2012/remove_cash_flow_statement.py b/patches/august_2012/remove_cash_flow_statement.py
deleted file mode 100644
index 739a4f2709e..00000000000
--- a/patches/august_2012/remove_cash_flow_statement.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from __future__ import unicode_literals
-def execute():
- import webnotes
- webnotes.conn.sql("delete from `tabSearch Criteria` where name = 'cash_flow_statement'")
\ No newline at end of file
diff --git a/patches/august_2012/report_supplier_quotations.py b/patches/august_2012/report_supplier_quotations.py
deleted file mode 100644
index 8eaf707c4cc..00000000000
--- a/patches/august_2012/report_supplier_quotations.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from __future__ import unicode_literals
-def execute():
- from webnotes.modules import reload_doc
- reload_doc("buying", "report", "supplier_quotations")
diff --git a/patches/december_2012/deprecate_tds.py b/patches/december_2012/deprecate_tds.py
index e351fd9f754..f3daeb0db77 100644
--- a/patches/december_2012/deprecate_tds.py
+++ b/patches/december_2012/deprecate_tds.py
@@ -15,7 +15,6 @@ def execute():
webnotes.conn.sql("drop table if exists `tab%s`" % dt)
webnotes.conn.begin()
- delete_doc("Search Criteria", "tds_return")
# Add tds entry in tax table for purchase invoice
pi_list = webnotes.conn.sql("""select name from `tabPurchase Invoice`
diff --git a/patches/december_2012/reload_debtors_creditors_ledger.py b/patches/december_2012/reload_debtors_creditors_ledger.py
deleted file mode 100644
index 7f88a6f47d2..00000000000
--- a/patches/december_2012/reload_debtors_creditors_ledger.py
+++ /dev/null
@@ -1,5 +0,0 @@
-def execute():
- import webnotes
- from webnotes.modules import reload_doc
- reload_doc("accounts", "search_criteria", "debtors_ledger")
- reload_doc("accounts", "search_criteria", "creditors_ledger")
\ No newline at end of file
diff --git a/patches/february_2013/p03_material_request.py b/patches/february_2013/p03_material_request.py
index 66b2bf6cbba..d85710d2a89 100644
--- a/patches/february_2013/p03_material_request.py
+++ b/patches/february_2013/p03_material_request.py
@@ -8,8 +8,6 @@ def execute():
webnotes.rename_doc("DocType", "Purchase Request Item", "Material Request Item", force=True)
if not "tabMaterial Request" in tables:
webnotes.rename_doc("DocType", "Purchase Request", "Material Request", force=True)
- webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_bill")
- webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_receive")
webnotes.reload_doc("stock", "doctype", "material_request")
webnotes.reload_doc("stock", "doctype", "material_request_item")
@@ -23,3 +21,7 @@ def execute():
os.system("rm -rf app/hr/doctype/holiday_block_list_allow")
os.system("rm -rf app/hr/doctype/holiday_block_list_date")
+ for dt in ("Purchase Request", "Purchase Request Item"):
+ if webnotes.conn.exists("DocType", dt):
+ webnotes.delete_doc("DocType", dt)
+
\ No newline at end of file
diff --git a/patches/february_2013/remove_sales_order_pending_items.py b/patches/february_2013/remove_sales_order_pending_items.py
deleted file mode 100644
index bde6a7b2409..00000000000
--- a/patches/february_2013/remove_sales_order_pending_items.py
+++ /dev/null
@@ -1,3 +0,0 @@
-def execute():
- import webnotes
- webnotes.delete_doc("Search Criteria", "sales_order_pending_items")
\ No newline at end of file
diff --git a/patches/january_2013/deprecate_stock_search_criteria.py b/patches/january_2013/deprecate_stock_search_criteria.py
deleted file mode 100644
index d51aadb5cf4..00000000000
--- a/patches/january_2013/deprecate_stock_search_criteria.py
+++ /dev/null
@@ -1,9 +0,0 @@
-import webnotes
-
-def execute():
- for sc in ["itemwise_price_list", "itemwise_receipt_details",
- "shortage_to_purchase_request", "stock_aging_report",
- "stock_ledger", "stock_level", "stock_report",
- "custom_test2", "custom_test3", "custom_test4",
- "test_so2", "test_so3"]:
- webnotes.delete_doc("Search Criteria", sc)
\ No newline at end of file
diff --git a/patches/january_2013/remove_support_search_criteria.py b/patches/january_2013/remove_support_search_criteria.py
deleted file mode 100644
index 0443afeeda1..00000000000
--- a/patches/january_2013/remove_support_search_criteria.py
+++ /dev/null
@@ -1,4 +0,0 @@
-import webnotes
-def execute():
- for sc in ["warranty-amc_expiry_details", "warranty-amc_summary"]:
- webnotes.delete_doc("Search Criteria", sc)
\ No newline at end of file
diff --git a/patches/july_2012/address_contact_perms.py b/patches/july_2012/address_contact_perms.py
index 5b79f229373..882cf728a53 100644
--- a/patches/july_2012/address_contact_perms.py
+++ b/patches/july_2012/address_contact_perms.py
@@ -6,7 +6,6 @@ def execute():
where parent in ('Address', 'Contact')""")
webnotes.conn.commit()
- import webnotes.model.sync
- webnotes.model.sync.sync('utilities', 'address')
- webnotes.model.sync.sync('utilities', 'contact')
+ webnotes.reload_doc('utilities', 'doctype', 'address')
+ webnotes.reload_doc('utilities', 'doctype', 'contact')
webnotes.conn.begin()
\ No newline at end of file
diff --git a/patches/july_2012/blog_guest_permission.py b/patches/july_2012/blog_guest_permission.py
deleted file mode 100644
index bc42a9d05c4..00000000000
--- a/patches/july_2012/blog_guest_permission.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from __future__ import unicode_literals
-def execute():
- """allocate read write permission to guest for doctype 'Blog'"""
- import webnotes
- webnotes.conn.sql("""delete from `tabDocPerm` where parent = 'Blog'""")
-
- webnotes.conn.commit()
-
- import webnotes.model.sync
- webnotes.model.sync.sync('website', 'blog', 1)
-
- webnotes.conn.begin()
diff --git a/patches/july_2012/project_patch_repeat.py b/patches/july_2012/project_patch_repeat.py
index bd525229388..b1386614c4c 100644
--- a/patches/july_2012/project_patch_repeat.py
+++ b/patches/july_2012/project_patch_repeat.py
@@ -12,8 +12,6 @@ def execute():
and ifnull(t1.project_name, '') = ''""")
webnotes.conn.commit()
- from webnotes.model.sync import sync
- sync("buying", "purchase_order")
- sync("buying", "purchase_request")
- sync("accounts", "purchase_invoice")
+ webnotes.reload_doc("buying", "doctype", "purchase_order")
+ webnotes.reload_doc("accounts", "doctype", "purchase_invoice")
webnotes.conn.begin()
\ No newline at end of file
diff --git a/patches/july_2012/supplier_quotation.py b/patches/july_2012/supplier_quotation.py
index 49fa14dc9b7..0a1ab35ef9b 100644
--- a/patches/july_2012/supplier_quotation.py
+++ b/patches/july_2012/supplier_quotation.py
@@ -1,13 +1,12 @@
from __future__ import unicode_literals
+import webnotes
+
def execute():
"""sync supplier quotatoin and create supplier quotation mappers"""
- from webnotes.model.sync import sync
- sync('buying', 'supplier_quotation')
- sync('buying', 'supplier_quotation_item')
- sync('buying', 'purchase_request')
- sync('buying', 'purchase_request_item')
- sync('buying', 'purchase_order')
- sync('buying', 'purchase_order_item')
+ webnotes.reload_doc('buying', 'doctype', 'supplier_quotation')
+ webnotes.reload_doc('buying', 'doctype', 'supplier_quotation_item')
+ webnotes.reload_doc('buying', 'doctype', 'purchase_order')
+ webnotes.reload_doc('buying', 'doctype', 'purchase_order_item')
from webnotes.modules import reload_doc
reload_doc('buying', 'DocType Mapper', 'Material Request-Supplier Quotation')
diff --git a/patches/july_2012/sync_trial_balance.py b/patches/july_2012/sync_trial_balance.py
deleted file mode 100644
index 3755ed442bd..00000000000
--- a/patches/july_2012/sync_trial_balance.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from __future__ import unicode_literals
-def execute():
- import webnotes
- from webnotes.modules import reload_doc
- reload_doc('accounts', 'search_criteria', 'trial_balance')
\ No newline at end of file
diff --git a/patches/july_2013/__init__.py b/patches/july_2013/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/patches/july_2013/restore_tree_roots.py b/patches/july_2013/restore_tree_roots.py
new file mode 100644
index 00000000000..ea3a9913ea2
--- /dev/null
+++ b/patches/july_2013/restore_tree_roots.py
@@ -0,0 +1,3 @@
+def execute():
+ from startup.install import import_defaults
+ import_defaults()
\ No newline at end of file
diff --git a/patches/june_2012/cms2.py b/patches/june_2012/cms2.py
index 414af73c007..17b7d23cc1b 100644
--- a/patches/june_2012/cms2.py
+++ b/patches/june_2012/cms2.py
@@ -1,14 +1,11 @@
from __future__ import unicode_literals
def execute():
import webnotes
- import webnotes.model.sync
# sync doctypes required for the patch
- webnotes.model.sync.sync('website', 'web_cache')
- webnotes.model.sync.sync('website', 'web_page')
- webnotes.model.sync.sync('website', 'blog')
- webnotes.model.sync.sync('website', 'website_settings')
- webnotes.model.sync.sync('stock', 'item')
+ webnotes.reload_doc('website', 'doctype', 'web_page')
+ webnotes.reload_doc('website', 'doctype', 'website_settings')
+ webnotes.reload_doc('stock', 'doctype', 'item')
cleanup()
diff --git a/patches/june_2012/copy_uom_for_pur_inv_item.py b/patches/june_2012/copy_uom_for_pur_inv_item.py
index b3742499423..a22146c6a3b 100644
--- a/patches/june_2012/copy_uom_for_pur_inv_item.py
+++ b/patches/june_2012/copy_uom_for_pur_inv_item.py
@@ -2,11 +2,9 @@ from __future__ import unicode_literals
def execute():
import webnotes
- # perform sync
- import webnotes.model.sync
- webnotes.model.sync.sync('buying', 'purchase_order_item')
- webnotes.model.sync.sync('accounts', 'purchase_invoice_item')
- webnotes.model.sync.sync('stock', 'purchase_receipt_item')
+ webnotes.reload_doc('buying', 'doctype', 'purchase_order_item')
+ webnotes.reload_doc('accounts', 'doctype', 'purchase_invoice_item')
+ webnotes.reload_doc('stock', 'doctype', 'purchase_receipt_item')
webnotes.conn.sql("update `tabPurchase Invoice Item` t1, `tabPurchase Order Item` t2 set t1.uom = t2.uom where ifnull(t1.po_detail, '') != '' and t1.po_detail = t2.name")
webnotes.conn.sql("update `tabPurchase Invoice Item` t1, `tabPurchase Receipt Item` t2 set t1.uom = t2.uom where ifnull(t1.pr_detail, '') != '' and t1.pr_detail = t2.name")
\ No newline at end of file
diff --git a/patches/june_2012/reports_list_permission.py b/patches/june_2012/reports_list_permission.py
index a02f4fa37f8..e88e8fbc607 100644
--- a/patches/june_2012/reports_list_permission.py
+++ b/patches/june_2012/reports_list_permission.py
@@ -8,8 +8,6 @@ def execute():
webnotes.conn.commit()
- import webnotes.model.sync
- webnotes.model.sync.sync('core', 'search_criteria')
- webnotes.model.sync.sync('core', 'report')
+ webnotes.reload_doc('core', 'doctype', 'report')
webnotes.conn.begin()
\ No newline at end of file
diff --git a/patches/june_2012/set_recurring_type.py b/patches/june_2012/set_recurring_type.py
index 79dd286fbc3..7fb416ed7e6 100644
--- a/patches/june_2012/set_recurring_type.py
+++ b/patches/june_2012/set_recurring_type.py
@@ -1,7 +1,6 @@
from __future__ import unicode_literals
def execute():
import webnotes
- from webnotes.model.sync import sync
- sync('accounts', 'sales_invoice')
+ webnotes.reload_doc('accounts', 'doctype', 'sales_invoice')
webnotes.conn.sql("update `tabSales Invoice` set recurring_type = 'Monthly' where ifnull(convert_into_recurring_invoice, 0) = 1")
\ No newline at end of file
diff --git a/patches/june_2012/support_ticket_autoreply.py b/patches/june_2012/support_ticket_autoreply.py
index 9fb0534bdd2..32e095665ce 100644
--- a/patches/june_2012/support_ticket_autoreply.py
+++ b/patches/june_2012/support_ticket_autoreply.py
@@ -4,9 +4,8 @@ def execute():
import webnotes
import webnotes.utils
- import webnotes.model.sync
webnotes.conn.commit()
- webnotes.model.sync.sync('setup', 'email_settings')
+ webnotes.reload_doc('setup', 'doctype', 'email_settings')
webnotes.conn.begin()
sync_support_mails = webnotes.utils.cint(webnotes.conn.get_value('Email Settings',
diff --git a/patches/june_2013/__init__.py b/patches/june_2013/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/patches/june_2013/p01_update_bom_exploded_items.py b/patches/june_2013/p01_update_bom_exploded_items.py
new file mode 100644
index 00000000000..f53eb5bc68b
--- /dev/null
+++ b/patches/june_2013/p01_update_bom_exploded_items.py
@@ -0,0 +1,29 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+
+def execute():
+ updated_bom = []
+ for bom in webnotes.conn.sql("select name from tabBOM where docstatus < 2"):
+ if bom[0] not in updated_bom:
+ try:
+ bom_obj = webnotes.get_obj("BOM", bom[0], with_children=1)
+ updated_bom += bom_obj.update_cost_and_exploded_items(bom[0])
+ webnotes.conn.commit()
+ except:
+ pass
\ No newline at end of file
diff --git a/patches/june_2013/p04_fix_event_for_lead_oppty_project.py b/patches/june_2013/p04_fix_event_for_lead_oppty_project.py
new file mode 100644
index 00000000000..971e4c74599
--- /dev/null
+++ b/patches/june_2013/p04_fix_event_for_lead_oppty_project.py
@@ -0,0 +1,20 @@
+import webnotes
+
+def execute():
+ from utilities.transaction_base import delete_events
+
+ # delete orphaned Event User
+ webnotes.conn.sql("""delete from `tabEvent User`
+ where not exists(select name from `tabEvent` where `tabEvent`.name = `tabEvent User`.parent)""")
+
+ for dt in ["Lead", "Opportunity", "Project"]:
+ for ref_name in webnotes.conn.sql_list("""select ref_name
+ from `tabEvent` where ref_type=%s and ifnull(starts_on, '')='' """, dt):
+ if webnotes.conn.exists(dt, ref_name):
+ if dt in ["Lead", "Opportunity"]:
+ webnotes.get_obj(dt, ref_name).add_calendar_event(force=True)
+ else:
+ webnotes.get_obj(dt, ref_name).add_calendar_event()
+ else:
+ # remove events where ref doc doesn't exist
+ delete_events(dt, ref_name)
\ No newline at end of file
diff --git a/patches/september_2012/reload_gross_profit.py b/patches/june_2013/p05_remove_search_criteria_reports.py
similarity index 86%
rename from patches/september_2012/reload_gross_profit.py
rename to patches/june_2013/p05_remove_search_criteria_reports.py
index 0a3f9efed7d..78963dbac1c 100644
--- a/patches/september_2012/reload_gross_profit.py
+++ b/patches/june_2013/p05_remove_search_criteria_reports.py
@@ -15,7 +15,7 @@
# along with this program. If not, see .
from __future__ import unicode_literals
+import webnotes
+
def execute():
- # reload gross profit report
- from webnotes.modules import reload_doc
- reload_doc('selling', 'search_criteria', 'gross_profit')
\ No newline at end of file
+ webnotes.conn.sql("""delete from `tabSearch Criteria` where ifnull(standard, 'No') = 'Yes'""")
\ No newline at end of file
diff --git a/patches/mar_2012/clean_property_setter.py b/patches/mar_2012/clean_property_setter.py
index 08a0a94e1fe..a9c7b81f360 100644
--- a/patches/mar_2012/clean_property_setter.py
+++ b/patches/mar_2012/clean_property_setter.py
@@ -12,8 +12,7 @@ def execute():
clean_docfield_properties()
def change_property_setter_fieldnames():
- import webnotes.model.sync
- webnotes.model.sync.sync('core', 'property_setter')
+ webnotes.reload_doc('core', 'doctype', 'property_setter')
docfield_list = webnotes.conn.sql("""\
SELECT name, fieldname FROM `tabDocField`""", as_list=1)
custom_field_list = webnotes.conn.sql("""\
diff --git a/patches/mar_2012/create_custom_fields.py b/patches/mar_2012/create_custom_fields.py
index d4c1a134538..a91c765e5f2 100644
--- a/patches/mar_2012/create_custom_fields.py
+++ b/patches/mar_2012/create_custom_fields.py
@@ -94,8 +94,7 @@ from webnotes.model.code import get_obj
from webnotes.model.doc import Document
def execute():
- import webnotes.model.sync
- webnotes.model.sync.sync('core', 'custom_field')
+ webnotes.reload_doc('core', 'doctype', 'custom_field')
for f in field_list:
res = webnotes.conn.sql("""SELECT name FROM `tabCustom Field`
WHERE dt=%s AND fieldname=%s""", (f[0], f[1]))
diff --git a/patches/may_2012/cleanup_notification_control.py b/patches/may_2012/cleanup_notification_control.py
index 25a704e1987..1a7730ba5be 100644
--- a/patches/may_2012/cleanup_notification_control.py
+++ b/patches/may_2012/cleanup_notification_control.py
@@ -25,5 +25,4 @@ def execute():
webnotes.conn.commit()
webnotes.conn.begin()
- import webnotes.model.sync
- webnotes.model.sync.sync('setup', 'notification_control')
\ No newline at end of file
+ webnotes.reload_doc('setup', 'doctype', 'notification_control')
\ No newline at end of file
diff --git a/patches/may_2012/cs_server_readonly.py b/patches/may_2012/cs_server_readonly.py
index b68060682cf..51a9b760cf0 100644
--- a/patches/may_2012/cs_server_readonly.py
+++ b/patches/may_2012/cs_server_readonly.py
@@ -27,5 +27,4 @@ def execute():
doc.save()
webnotes.conn.commit()
webnotes.conn.begin()
- import webnotes.model.sync
- webnotes.model.sync.sync('core', 'custom_script')
\ No newline at end of file
+ webnotes.reload_doc('core', 'doctype', 'custom_script')
\ No newline at end of file
diff --git a/patches/may_2012/profile_perm_patch.py b/patches/may_2012/profile_perm_patch.py
index 4423fdb15d6..29fa9c05bed 100644
--- a/patches/may_2012/profile_perm_patch.py
+++ b/patches/may_2012/profile_perm_patch.py
@@ -19,5 +19,4 @@ def execute():
doc.save()
webnotes.conn.commit()
webnotes.conn.begin()
- import webnotes.model.sync
- webnotes.model.sync.sync('core', 'profile')
\ No newline at end of file
+ webnotes.reload_doc('core', 'doctype', 'profile')
\ No newline at end of file
diff --git a/patches/may_2012/reload_customer_address_contact.py b/patches/may_2012/reload_customer_address_contact.py
deleted file mode 100644
index 4aec19d02d6..00000000000
--- a/patches/may_2012/reload_customer_address_contact.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from __future__ import unicode_literals
-def execute():
- import webnotes
- import webnotes.modules
- webnotes.modules.reload_doc('selling', 'search_criteria', 'customer_address_contact')
\ No newline at end of file
diff --git a/patches/may_2012/reload_reports.py b/patches/may_2012/reload_reports.py
deleted file mode 100644
index 1cee3a0061c..00000000000
--- a/patches/may_2012/reload_reports.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from __future__ import unicode_literals
-def execute():
- import webnotes
- from webnotes.modules import reload_doc
- reload_doc('selling', 'search_criteria', 'itemwise_sales_details')
- reload_doc('selling', 'search_criteria', 'itemwise_delivery_details')
-
diff --git a/patches/may_2012/reload_so_pending_items.py b/patches/may_2012/reload_so_pending_items.py
deleted file mode 100644
index 999004e1fe9..00000000000
--- a/patches/may_2012/reload_so_pending_items.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from __future__ import unicode_literals
-def execute():
- import webnotes
- from webnotes.model import delete_doc
- delete_doc("Search Criteria", "sales_order_pending_items1")
-
- webnotes.conn.sql("update `tabSearch Criteria` set module = 'Selling' where module = 'CRM'")
- from webnotes.modules import reload_doc
- reload_doc('selling', 'search_criteria', 'sales_order_pending_items')
\ No newline at end of file
diff --git a/patches/may_2012/remove_communication_log.py b/patches/may_2012/remove_communication_log.py
index e44e6737012..b6e7e7d2761 100644
--- a/patches/may_2012/remove_communication_log.py
+++ b/patches/may_2012/remove_communication_log.py
@@ -1,8 +1,7 @@
from __future__ import unicode_literals
def execute():
import webnotes
- import webnotes.model.sync
- webnotes.model.sync.sync('support', 'communication')
+ webnotes.reload_doc('support', 'doctype', 'communication')
webnotes.conn.commit()
webnotes.conn.begin()
diff --git a/patches/may_2012/std_pf_readonly.py b/patches/may_2012/std_pf_readonly.py
index 83b581325c8..9fbbfe9a3c3 100644
--- a/patches/may_2012/std_pf_readonly.py
+++ b/patches/may_2012/std_pf_readonly.py
@@ -27,5 +27,4 @@ def execute():
doc.save()
webnotes.conn.commit()
webnotes.conn.begin()
- import webnotes.model.sync
- webnotes.model.sync.sync('core', 'print_format')
\ No newline at end of file
+ webnotes.reload_doc('core', 'doctype', 'print_format')
\ No newline at end of file
diff --git a/patches/may_2013/__init__.py b/patches/may_2013/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/patches/may_2013/p01_conversion_factor_and_aii.py b/patches/may_2013/p01_conversion_factor_and_aii.py
new file mode 100644
index 00000000000..2fd0d369a58
--- /dev/null
+++ b/patches/may_2013/p01_conversion_factor_and_aii.py
@@ -0,0 +1,26 @@
+import webnotes
+from webnotes.utils import cint
+from accounts.utils import create_stock_in_hand_jv
+
+def execute():
+ webnotes.conn.auto_commit_on_many_writes = True
+
+ aii_enabled = cint(webnotes.conn.get_value("Global Defaults", None,
+ "auto_inventory_accounting"))
+
+ if aii_enabled:
+ create_stock_in_hand_jv(reverse = True)
+
+ webnotes.conn.sql("""update `tabPurchase Invoice Item` pi_item
+ set conversion_factor = (select ifnull(if(conversion_factor=0, 1, conversion_factor), 1)
+ from `tabUOM Conversion Detail`
+ where parent = pi_item.item_code and uom = pi_item.uom limit 1
+ )
+ where ifnull(conversion_factor, 0)=0""")
+
+ if aii_enabled:
+ create_stock_in_hand_jv()
+
+ webnotes.conn.auto_commit_on_many_writes = False
+
+
\ No newline at end of file
diff --git a/patches/may_2013/p02_update_valuation_rate.py b/patches/may_2013/p02_update_valuation_rate.py
new file mode 100644
index 00000000000..280473ccef7
--- /dev/null
+++ b/patches/may_2013/p02_update_valuation_rate.py
@@ -0,0 +1,47 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+def execute():
+ from stock.stock_ledger import update_entries_after
+ item_warehouse = []
+ # update valuation_rate in transaction
+ doctypes = {"Purchase Receipt": "purchase_receipt_details", "Purchase Invoice": "entries"}
+
+ for dt in doctypes:
+ for d in webnotes.conn.sql("""select name from `tab%s`
+ where modified >= '2013-05-09' and docstatus=1""" % dt):
+ rec = webnotes.get_obj(dt, d[0])
+ rec.update_valuation_rate(doctypes[dt])
+
+ for item in rec.doclist.get({"parentfield": doctypes[dt]}):
+ webnotes.conn.sql("""update `tab%s Item` set valuation_rate = %s
+ where name = %s"""% (dt, '%s', '%s'), tuple([item.valuation_rate, item.name]))
+
+ if dt == "Purchase Receipt":
+ webnotes.conn.sql("""update `tabStock Ledger Entry` set incoming_rate = %s
+ where voucher_detail_no = %s""", (item.valuation_rate, item.name))
+ if [item.item_code, item.warehouse] not in item_warehouse:
+ item_warehouse.append([item.item_code, item.warehouse])
+
+ for d in item_warehouse:
+ try:
+ update_entries_after({"item_code": d[0], "warehouse": d[1],
+ "posting_date": "2013-01-01", "posting_time": "00:05:00"})
+ webnotes.conn.commit()
+ except:
+ pass
\ No newline at end of file
diff --git a/patches/may_2013/p03_update_support_ticket.py b/patches/may_2013/p03_update_support_ticket.py
new file mode 100644
index 00000000000..7dc5854b44e
--- /dev/null
+++ b/patches/may_2013/p03_update_support_ticket.py
@@ -0,0 +1,27 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+def execute():
+ webnotes.reload_doc("support", "doctype", "support_ticket")
+ webnotes.reload_doc("core", "doctype", "communication")
+ for d in webnotes.conn.sql("""select name, raised_by from `tabSupport Ticket`
+ where docstatus < 2""", as_dict=True):
+ tic = webnotes.get_obj("Support Ticket", d.name)
+ tic.set_lead_contact(d.raised_by)
+ webnotes.conn.sql("""update `tabSupport Ticket` set lead = %s, contact = %s, company = %s
+ where name = %s""", (tic.doc.lead, tic.doc.contact, tic.doc.company, d.name))
\ No newline at end of file
diff --git a/hr/search_criteria/employee_information/employee_information.py b/patches/may_2013/p04_reorder_level.py
similarity index 76%
rename from hr/search_criteria/employee_information/employee_information.py
rename to patches/may_2013/p04_reorder_level.py
index 6e0887270f1..8f4d669bc56 100644
--- a/hr/search_criteria/employee_information/employee_information.py
+++ b/patches/may_2013/p04_reorder_level.py
@@ -15,9 +15,9 @@
# along with this program. If not, see .
from __future__ import unicode_literals
-for c in range(0,len(colnames)):
- l = (len(colnames[c])*9)
- if l < 150 : col_width = '150px'
- else: col_width = '%spx'%(l)
-
- colwidths[c] = col_width
\ No newline at end of file
+import webnotes
+def execute():
+ webnotes.reload_doc("Setup", "DocType", "Global Defaults")
+
+ if webnotes.conn.exists({"doctype": "Item", "email_notify": 1}):
+ webnotes.conn.set_value("Global Defaults", None, "reorder_email_notify", 1)
\ No newline at end of file
diff --git a/accounts/search_criteria/business_associate_commission_report/business_associate_commission_report.py b/patches/may_2013/p05_update_cancelled_gl_entries.py
similarity index 65%
rename from accounts/search_criteria/business_associate_commission_report/business_associate_commission_report.py
rename to patches/may_2013/p05_update_cancelled_gl_entries.py
index 6aa7529ca3d..59eed7e66f0 100644
--- a/accounts/search_criteria/business_associate_commission_report/business_associate_commission_report.py
+++ b/patches/may_2013/p05_update_cancelled_gl_entries.py
@@ -15,13 +15,15 @@
# along with this program. If not, see .
from __future__ import unicode_literals
-colwidths[col_idx['Business Associate']] = '200px'
+import webnotes
+from webnotes.utils import cint
-coltypes[col_idx['Average Commission Rate']] = 'Currency'
-colwidths[col_idx['Average Commission Rate']] = '200px'
-
-coltypes[col_idx['Net Total']] = 'Currency'
-colwidths[col_idx['Net Total']] = '150px'
-
-coltypes[col_idx['Total Commission']] = 'Currency'
-colwidths[col_idx['Total Commission']] = '150px'
\ No newline at end of file
+def execute():
+ aii_enabled = cint(webnotes.conn.get_value("Global Defaults", None,
+ "auto_inventory_accounting"))
+
+ if aii_enabled:
+ webnotes.conn.sql("""update `tabGL Entry` gle set is_cancelled = 'Yes'
+ where voucher_type = 'Delivery Note'
+ and exists(select name from `tabDelivery Note`
+ where name = gle.voucher_no and docstatus = 2)""")
\ No newline at end of file
diff --git a/accounts/search_criteria/cost_center_wise_expense/cost_center_wise_expense.py b/patches/may_2013/repost_stock_for_no_posting_time.py
similarity index 62%
rename from accounts/search_criteria/cost_center_wise_expense/cost_center_wise_expense.py
rename to patches/may_2013/repost_stock_for_no_posting_time.py
index 1c7350128ce..489511c53ee 100644
--- a/accounts/search_criteria/cost_center_wise_expense/cost_center_wise_expense.py
+++ b/patches/may_2013/repost_stock_for_no_posting_time.py
@@ -14,17 +14,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-# Add columns
-# -----------
from __future__ import unicode_literals
-row_list = [['Cost Center','Data','160px'],
- ['Account','Data','160px'],
- ['Debit','Currency','120px'],
- ['Credit','Currency','120px'],
- ['Expense','Currency','120px']]
-
-for r in row_list:
- colnames.append(r[0])
- coltypes.append(r[1])
- colwidths.append(r[2])
- col_idx[r[0]] = len(colnames)-1
\ No newline at end of file
+def execute():
+ import webnotes
+ from stock.stock_ledger import update_entries_after
+
+ res = webnotes.conn.sql("""select distinct item_code, warehouse from `tabStock Ledger Entry`
+ where posting_time = '00:00'""")
+
+ i=0
+ for d in res:
+ try:
+ update_entries_after({ "item_code": d[0], "warehouse": d[1] })
+ except:
+ pass
+ i += 1
+ if i%20 == 0:
+ webnotes.conn.sql("commit")
+ webnotes.conn.sql("start transaction")
\ No newline at end of file
diff --git a/patches/october_2012/update_account_property.py b/patches/october_2012/update_account_property.py
index efe0649d222..a9d365faf86 100644
--- a/patches/october_2012/update_account_property.py
+++ b/patches/october_2012/update_account_property.py
@@ -11,4 +11,4 @@ def execute():
for acc in roots:
webnotes.conn.sql("""update tabAccount set debit_or_credit = %(debit_or_credit)s,
is_pl_account = %(is_pl_account)s, company = %(company)s
- where lft > %(lft)s and rgt < %(rgt)s""", acc, debug=1)
\ No newline at end of file
+ where lft > %(lft)s and rgt < %(rgt)s""", acc)
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index f6a599694d7..812f641fcb2 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -38,19 +38,15 @@ patch_list = [
"patches.may_2012.cleanup_property_setter",
"patches.may_2012.rename_prev_doctype",
"patches.may_2012.cleanup_notification_control",
- "patches.may_2012.renamedt_in_custom_search_criteria",
"patches.may_2012.stock_reco_patch",
- "patches.may_2012.reload_reports",
"patches.may_2012.page_role_series_fix",
"patches.may_2012.reload_sales_invoice_pf",
"patches.may_2012.std_pf_readonly",
- "patches.may_2012.reload_so_pending_items",
"patches.may_2012.customize_form_cleanup",
"patches.may_2012.cs_server_readonly",
"patches.may_2012.clear_session_cache",
"patches.may_2012.same_purchase_rate_patch",
"patches.may_2012.create_report_manager_role",
- "patches.may_2012.reload_customer_address_contact",
"patches.may_2012.profile_perm_patch",
"patches.may_2012.remove_euro_currency",
"patches.may_2012.remove_communication_log",
@@ -74,17 +70,13 @@ patch_list = [
"patches.july_2012.auth_table",
"patches.july_2012.remove_event_role_owner_match",
"patches.july_2012.deprecate_bulk_rename",
- "patches.july_2012.blog_guest_permission",
"patches.july_2012.bin_permission",
"patches.july_2012.project_patch_repeat",
"patches.july_2012.repost_stock_due_to_wrong_packing_list",
"patches.july_2012.supplier_quotation",
- "patches.august_2012.report_supplier_quotations",
"patches.august_2012.task_allocated_to_assigned",
"patches.august_2012.change_profile_permission",
- "patches.august_2012.changed_blog_date_format",
"patches.august_2012.repost_billed_amt",
- "patches.august_2012.remove_cash_flow_statement",
"patches.september_2012.stock_report_permissions_for_accounts",
"patches.september_2012.communication_delete_permission",
"patches.september_2012.all_permissions_patch",
@@ -93,7 +85,6 @@ patch_list = [
"patches.september_2012.plot_patch",
"patches.september_2012.event_permission",
"patches.september_2012.repost_stock",
- "patches.september_2012.reload_gross_profit",
"patches.september_2012.rebuild_trees",
"patches.september_2012.deprecate_account_balance",
"patches.september_2012.profile_delete_permission",
@@ -127,7 +118,6 @@ patch_list = [
"patches.december_2012.expense_leave_reload",
"patches.december_2012.repost_ordered_qty",
"patches.december_2012.repost_projected_qty",
- "patches.december_2012.reload_debtors_creditors_ledger",
"patches.december_2012.website_cache_refactor",
"patches.december_2012.production_cleanup",
"patches.december_2012.fix_default_print_format",
@@ -142,8 +132,6 @@ patch_list = [
"patches.december_2012.remove_project_mapper",
"patches.december_2012.update_print_width",
"patches.january_2013.remove_bad_permissions",
- "patches.january_2013.deprecate_stock_search_criteria",
- "patches.january_2013.remove_support_search_criteria",
"patches.january_2013.holiday_list_patch",
"patches.january_2013.stock_reconciliation_patch",
"patches.january_2013.report_permission",
@@ -154,12 +142,12 @@ patch_list = [
"patches.january_2013.remove_tds_entry_from_gl_mapper",
"patches.january_2013.update_number_format",
"patches.january_2013.purchase_price_list",
+ "execute:webnotes.reload_doc('core', 'doctype', 'print_format') #2013-01",
"execute:webnotes.reload_doc('accounts','Print Format','Payment Receipt Voucher')",
"patches.january_2013.update_fraction_for_usd",
"patches.january_2013.enable_currencies",
"patches.january_2013.remove_unwanted_permission",
"patches.january_2013.remove_landed_cost_master",
- "execute:webnotes.reload_doc('core', 'doctype', 'print_format')",
"patches.january_2013.reload_print_format",
"patches.january_2013.rebuild_tree",
"execute:webnotes.reload_doc('core','doctype','docfield') #2013-01-28",
@@ -167,7 +155,6 @@ patch_list = [
"patches.february_2013.remove_gl_mapper",
"patches.february_2013.reload_bom_replace_tool_permission",
"patches.february_2013.payment_reconciliation_reset_values",
- "patches.february_2013.remove_sales_order_pending_items",
"patches.february_2013.account_negative_balance",
"patches.february_2013.remove_account_utils_folder",
"patches.february_2013.update_company_in_leave_application",
@@ -191,14 +178,11 @@ patch_list = [
"execute:webnotes.delete_doc('DocType', 'Service Quotation Detail')",
"patches.february_2013.p06_material_request_mappers",
"execute:webnotes.delete_doc('Page', 'Query Report')",
- "execute:webnotes.delete_doc('Search Criteria', 'employeewise_balance_leave_report')",
- "execute:webnotes.delete_doc('Search Criteria', 'employee_leave_balance_report')",
"patches.february_2013.repost_reserved_qty",
"execute:webnotes.reload_doc('core', 'doctype', 'report') # 2013-02-25",
"execute:webnotes.conn.sql(\"update `tabReport` set report_type=if(ifnull(query, '')='', 'Report Builder', 'Query Report') where is_standard='No'\")",
"execute:webnotes.conn.sql(\"update `tabReport` set report_name=name where ifnull(report_name,'')='' and is_standard='No'\")",
"patches.february_2013.p08_todo_query_report",
- "execute:webnotes.delete_doc('Search Criteria', 'gross_profit') # 2013-02-26",
'execute:webnotes.reload_doc("accounts", "Print Format", "Sales Invoice Classic") # 2013-02-26',
'execute:webnotes.reload_doc("accounts", "Print Format", "Sales Invoice Modern") # 2013-02-26',
'execute:webnotes.reload_doc("accounts", "Print Format", "Sales Invoice Spartan") # 2013-02-26',
@@ -212,7 +196,6 @@ patch_list = [
"execute:webnotes.delete_doc('DocType', 'Attendance Control Panel')",
"patches.march_2013.p02_get_global_default",
"patches.march_2013.p03_rename_blog_to_blog_post",
- "execute:webnotes.reload_doc('hr', 'search_criteria', 'monthly_attendance_details')",
"patches.march_2013.p04_pos_update_stock_check",
"patches.march_2013.p05_payment_reconciliation",
"patches.march_2013.p06_remove_sales_purchase_return_tool",
@@ -238,9 +221,29 @@ patch_list = [
'execute:webnotes.reload_doc("selling", "Print Format", "Quotation Modern") # 2013-04-02',
'execute:webnotes.reload_doc("selling", "Print Format", "Quotation Spartan") # 2013-04-02',
"patches.april_2013.p04_reverse_modules_list",
- "execute:webnotes.delete_doc('Search Criteria', 'time_log_summary')",
"patches.april_2013.p04_update_role_in_pages",
+ "patches.april_2013.p05_update_file_data",
+ "patches.april_2013.p06_update_file_size",
"patches.april_2013.p05_fixes_in_reverse_modules",
"execute:webnotes.delete_doc('DocType Mapper', 'Delivery Note-Packing Slip')",
+ "execute:webnotes.reload_doc('Stock', 'DocType', 'Delivery Note Item')",
"patches.april_2013.p06_default_cost_center",
-]
\ No newline at end of file
+ "execute:webnotes.reset_perms('File Data')",
+ "patches.april_2013.p07_update_file_data_2",
+ "patches.april_2013.rebuild_sales_browser",
+ "patches.april_2013.p08_price_list_country",
+ "patches.may_2013.repost_stock_for_no_posting_time",
+ "patches.may_2013.p01_conversion_factor_and_aii",
+ "patches.may_2013.p02_update_valuation_rate",
+ "patches.may_2013.p03_update_support_ticket",
+ "patches.may_2013.p04_reorder_level",
+ "patches.may_2013.p05_update_cancelled_gl_entries",
+ "patches.june_2013.p01_update_bom_exploded_items",
+ "execute:webnotes.delete_doc('DocType', 'System Console')",
+ "patches.june_2013.p04_fix_event_for_lead_oppty_project",
+ "patches.june_2013.p05_remove_search_criteria_reports",
+ "execute:webnotes.delete_doc('DocType', 'Update Delivery Date')",
+ "execute:webnotes.reload_doc('accounts', 'DocType Mapper', 'Purchase Order-Purchase Invoice') # 2013-07-04 3:00",
+ "execute:webnotes.reload_doc('accounts', 'DocType Mapper', 'Purchase Receipt-Purchase Invoice') # 2013-07-04 3:00",
+ "execute:webnotes.delete_doc('Report', 'Sales Orders Pending To Be Delivered')",
+]
diff --git a/patches/september_2012/repost_stock.py b/patches/september_2012/repost_stock.py
index 972070137ae..deb218637e9 100644
--- a/patches/september_2012/repost_stock.py
+++ b/patches/september_2012/repost_stock.py
@@ -22,7 +22,7 @@ def execute():
i=0
for d in res:
try:
- update_entries_after({ "item_code": d[0], "warehouse": d[1] })
+ update_entries_after({ "item_code": d[0], "warehouse": d[1]})
except:
pass
i += 1
diff --git a/projects/doctype/project/project.py b/projects/doctype/project/project.py
index 1de551c7535..84a216c3490 100644
--- a/projects/doctype/project/project.py
+++ b/projects/doctype/project/project.py
@@ -18,24 +18,18 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt, getdate
-from webnotes.model import db_exists
-from webnotes.model.doc import Document
-from webnotes.model.bean import copy_doclist
from webnotes import msgprint
-
-sql = webnotes.conn.sql
-
-
+from utilities.transaction_base import delete_events
class DocType:
- def __init__(self, doc, doclist=[]):
+ def __init__(self, doc, doclist=None):
self.doc = doc
self.doclist = doclist
# Get Customer Details along with its primary contact details
# ==============================================================
def get_customer_details(self):
- details =sql("select address, territory, customer_group,customer_name from `tabCustomer` where name=%s and docstatus!=2",(self.doc.customer),as_dict=1)
+ details =webnotes.conn.sql("select address, territory, customer_group,customer_name from `tabCustomer` where name=%s and docstatus!=2",(self.doc.customer),as_dict=1)
if details:
ret = {
'customer_address' : details and details[0]['address'] or '',
@@ -44,7 +38,7 @@ class DocType:
'customer_name' : details and details[0]['customer_name'] or ''
}
#get primary contact details(this is done separately coz. , if join query used & no primary contact thn it would not be able to fetch customer details)
- contact_det = sql("select contact_name, phone, email_id from `tabContact` where customer_name='%s' and is_customer=1 and is_primary_contact=1 and docstatus!=2" %(self.doc.customer), as_dict = 1)
+ contact_det = webnotes.conn.sql("select contact_name, phone, email_id from `tabContact` where customer_name='%s' and is_customer=1 and is_primary_contact=1 and docstatus!=2" %(self.doc.customer), as_dict = 1)
ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
ret['contact_no'] = contact_det and contact_det[0]['phone'] or ''
ret['email_id'] = contact_det and contact_det[0]['email_id'] or ''
@@ -52,21 +46,7 @@ class DocType:
else:
msgprint("Customer : %s does not exist in system." % (self.doc.customer))
raise Exception
-
- # Get customer's contact person details
- # ==============================================================
- def get_contact_details(self):
- contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s' and docstatus != 2" %(self.doc,contact_person,self.doc.customer), as_dict=1)
- if contact:
- ret = {
- 'contact_no' : contact and contact[0]['contact_no'] or '',
- 'email_id' : contact and contact[0]['email_id'] or ''
- }
- return ret
- else:
- msgprint("Contact Person : %s does not exist in the system." % (self.doc,contact_person))
- raise Exception
-
+
#calculate gross profit
#=============================================
def get_gross_profit(self):
@@ -86,20 +66,26 @@ class DocType:
raise Exception
def on_update(self):
- # update milestones
- webnotes.conn.sql("""delete from tabEvent where ref_type='Project' and ref_name=%s""",
- self.doc.name)
- for d in self.doclist:
- if d.doctype=='Project Milestone' and d.docstatus!=2:
- self.add_calendar_event(d.milestone, d.milestone_date)
+ self.add_calendar_event()
- def add_calendar_event(self, milestone, date):
- """ Add calendar event for task in calendar of Allocated person"""
- event = Document('Event')
- event.description = milestone + ' for ' + self.doc.name
- event.event_date = date
- event.event_hour = '10:00'
- event.event_type = 'Public'
- event.ref_type = 'Project'
- event.ref_name = self.doc.name
- event.save(1)
+ def add_calendar_event(self):
+ # delete any earlier event for this project
+ delete_events(self.doc.doctype, self.doc.name)
+
+ # add events
+ for milestone in self.doclist.get({"parentfield": "project_milestones"}):
+ if milestone.milestone_date:
+ description = (milestone.milestone or "Milestone") + " for " + self.doc.name
+ webnotes.bean({
+ "doctype": "Event",
+ "owner": self.doc.owner,
+ "subject": description,
+ "description": description,
+ "starts_on": milestone.milestone_date + " 10:00:00",
+ "event_type": "Private",
+ "ref_type": self.doc.doctype,
+ "ref_name": self.doc.name
+ }).insert()
+
+ def on_trash(self):
+ delete_events(self.doc.doctype, self.doc.name)
\ No newline at end of file
diff --git a/projects/doctype/task/task.txt b/projects/doctype/task/task.txt
index f0e0f2327d9..85d6aaa2ba9 100644
--- a/projects/doctype/task/task.txt
+++ b/projects/doctype/task/task.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-01-10 16:34:17",
+ "creation": "2013-01-29 19:25:50",
"docstatus": 0,
"modified": "2013-01-29 16:27:52",
"modified_by": "Administrator",
@@ -249,15 +249,6 @@
"label": "Company",
"options": "Company"
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"doctype": "DocPerm"
}
diff --git a/projects/doctype/time_log/time_log.js b/projects/doctype/time_log/time_log.js
index a6023320f16..22f9610b8ff 100644
--- a/projects/doctype/time_log/time_log.js
+++ b/projects/doctype/time_log/time_log.js
@@ -1,5 +1,9 @@
-$.extend(cur_frm.cscript, {
- refresh: function(doc) {
-
+wn.provide("erpnext.projects");
+
+erpnext.projects.TimeLog = wn.ui.form.Controller.extend({
+ setup: function() {
+ this.frm.set_query("task", erpnext.queries.task);
}
-});
\ No newline at end of file
+});
+
+cur_frm.cscript = new erpnext.projects.TimeLog({frm: cur_frm});
\ No newline at end of file
diff --git a/projects/doctype/time_log/time_log.txt b/projects/doctype/time_log/time_log.txt
index 09c04c5167a..897d6be7db8 100644
--- a/projects/doctype/time_log/time_log.txt
+++ b/projects/doctype/time_log/time_log.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-03-06 14:08:07",
+ "creation": "2013-04-03 16:38:41",
"docstatus": 0,
"modified": "2013-04-03 15:51:32",
"modified_by": "Administrator",
@@ -185,17 +185,6 @@
"permlevel": 0,
"read_only": 0
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 0
- },
{
"doctype": "DocField",
"fieldname": "amended_from",
diff --git a/projects/page/projects_home/projects_home.js b/projects/page/projects_home/projects_home.js
index cfde6b30d21..fd13a673670 100644
--- a/projects/page/projects_home/projects_home.js
+++ b/projects/page/projects_home/projects_home.js
@@ -60,6 +60,11 @@ wn.module_page["Projects"] = [
route: "query-report/Daily Time Log Summary",
doctype: "Time Log"
},
+ {
+ "label":wn._("Project wise Stock Tracking"),
+ route: "query-report/Project wise Stock Tracking",
+ doctype: "Project"
+ },
]
}]
diff --git a/projects/report/daily_time_log_summary/daily_time_log_summary.py b/projects/report/daily_time_log_summary/daily_time_log_summary.py
index 22e48077b59..8c1e2668cd2 100644
--- a/projects/report/daily_time_log_summary/daily_time_log_summary.py
+++ b/projects/report/daily_time_log_summary/daily_time_log_summary.py
@@ -1,5 +1,6 @@
from __future__ import unicode_literals
import webnotes
+from webnotes.utils import flt
def execute(filters=None):
if not filters:
@@ -18,17 +19,29 @@ def execute(filters=None):
time_logs = webnotes.conn.sql("""select * from `tabTime Log`
where docstatus < 2 %s order by owner asc""" % (conditions, ), filters, as_dict=1)
- data = []
if time_logs:
profiles = [time_logs[0].owner]
+ data = []
+ total_hours = total_employee_hours = count = 0
for tl in time_logs:
if tl.owner not in profiles:
profiles.append(tl.owner)
- data.append([])
-
+ data.append(["", "", "", "Total", total_employee_hours, "", "", "", "", ""])
+ total_employee_hours = 0
+
data.append([tl.name, profile_map[tl.owner], tl.from_time, tl.to_time, tl.hours,
tl.activity_type, tl.task, task_map.get(tl.task), tl.project, tl.status])
+
+ count += 1
+ total_hours += flt(tl.hours)
+ total_employee_hours += flt(tl.hours)
+
+ if count == len(time_logs):
+ data.append(["", "", "", "Total Hours", total_employee_hours, "", "", "", "", ""])
+
+ if total_hours:
+ data.append(["", "", "", "Grand Total", total_hours, "", "", "", "", ""])
return columns, data
diff --git a/projects/report/project_wise_stock_tracking/__init__.py b/projects/report/project_wise_stock_tracking/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.py b/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.py
new file mode 100644
index 00000000000..7c702e41cb4
--- /dev/null
+++ b/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.py
@@ -0,0 +1,90 @@
+# 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 .
+
+import webnotes
+
+def execute(filters=None):
+ columns = get_columns()
+ proj_details = get_project_details()
+ pr_item_map = get_purchased_items_cost()
+ se_item_map = get_issued_items_cost()
+ dn_item_map = get_delivered_items_cost()
+
+ data = []
+ for project in proj_details:
+ data.append([project.name, pr_item_map.get(project.name, 0),
+ se_item_map.get(project.name, 0), dn_item_map.get(project.name, 0),
+ project.project_name, project.status, project.company,
+ project.customer, project.project_value, project.project_start_date,
+ project.completion_date])
+
+ return columns, data
+
+def get_columns():
+ return ["Project Id:Link/Project:140", "Cost of Purchased Items:Currency:160",
+ "Cost of Issued Items:Currency:160", "Cost of Delivered Items:Currency:160",
+ "Project Name::120", "Project Status::120", "Company:Link/Company:100",
+ "Customer:Link/Customer:140", "Project Value:Currency:120",
+ "Project Start Date:Date:120", "Completion Date:Date:120"]
+
+def get_project_details():
+ return webnotes.conn.sql(""" select name, project_name, status, company, customer, project_value,
+ project_start_date, completion_date from tabProject where docstatus < 2""", as_dict=1)
+
+def get_purchased_items_cost():
+ pr_items = webnotes.conn.sql("""select project_name, sum(amount) as amount
+ from `tabPurchase Receipt Item` where ifnull(project_name, '') != ''
+ and docstatus = 1 group by project_name""", as_dict=1)
+
+ pr_item_map = {}
+ for item in pr_items:
+ pr_item_map.setdefault(item.project_name, item.amount)
+
+ return pr_item_map
+
+def get_issued_items_cost():
+ se_items = webnotes.conn.sql("""select se.project_name, sum(se_item.amount) as amount
+ from `tabStock Entry` se, `tabStock Entry Detail` se_item
+ where se.name = se_item.parent and se.docstatus = 1 and ifnull(se_item.t_warehouse, '') = ''
+ and ifnull(se.project_name, '') != '' group by se.project_name""", as_dict=1)
+
+ se_item_map = {}
+ for item in se_items:
+ se_item_map.setdefault(item.project_name, item.amount)
+
+ return se_item_map
+
+def get_delivered_items_cost():
+ dn_items = webnotes.conn.sql("""select dn.project_name, sum(dn_item.amount) as amount
+ from `tabDelivery Note` dn, `tabDelivery Note Item` dn_item
+ where dn.name = dn_item.parent and dn.docstatus = 1 and ifnull(dn.project_name, '') != ''
+ group by dn.project_name""", as_dict=1)
+
+ si_items = webnotes.conn.sql("""select si.project_name, sum(si_item.amount) as amount
+ from `tabSales Invoice` si, `tabSales Invoice Item` si_item
+ where si.name = si_item.parent and si.docstatus = 1 and ifnull(si.update_stock, 0) = 1
+ and ifnull(si.is_pos, 0) = 1 and ifnull(si.project_name, '') != ''
+ group by si.project_name""", as_dict=1)
+
+
+ dn_item_map = {}
+ for item in dn_items:
+ dn_item_map.setdefault(item.project_name, item.amount)
+
+ for item in si_items:
+ dn_item_map.setdefault(item.project_name, item.amount)
+
+ return dn_item_map
\ No newline at end of file
diff --git a/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.txt b/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.txt
new file mode 100644
index 00000000000..89f5085351f
--- /dev/null
+++ b/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-03 17:37:41",
+ "docstatus": 0,
+ "modified": "2013-06-03 17:37:41",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Project",
+ "report_name": "Project wise Stock Tracking ",
+ "report_type": "Report Builder"
+ },
+ {
+ "doctype": "Report",
+ "name": "Project wise Stock Tracking"
+ }
+]
\ No newline at end of file
diff --git a/projects/search_criteria/__init__.py b/projects/search_criteria/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/projects/search_criteria/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/projects/search_criteria/projectwise_delivered_qty_and_costs/__init__.py b/projects/search_criteria/projectwise_delivered_qty_and_costs/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/projects/search_criteria/projectwise_delivered_qty_and_costs/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/projects/search_criteria/projectwise_delivered_qty_and_costs/projectwise_delivered_qty_and_costs.js b/projects/search_criteria/projectwise_delivered_qty_and_costs/projectwise_delivered_qty_and_costs.js
deleted file mode 100644
index c8b42dc2c3e..00000000000
--- a/projects/search_criteria/projectwise_delivered_qty_and_costs/projectwise_delivered_qty_and_costs.js
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.hide_all_filters();
-
- //this.add_filter({fieldname:'item_code', label:'Item Code', fieldtype:'Link', options:'Item',ignore : 1,parent:'Delivery Note Item'});
-
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Project Name'].df.filter_hide = 0;
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Company'].df.filter_hide = 0;
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Fiscal Year'].df.filter_hide = 0;
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Customer'].df.filter_hide = 0;
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Customer Name'].df.filter_hide = 0;
-
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Project Name'].df.in_first_page = 1;
-
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
-}
diff --git a/projects/search_criteria/projectwise_delivered_qty_and_costs/projectwise_delivered_qty_and_costs.txt b/projects/search_criteria/projectwise_delivered_qty_and_costs/projectwise_delivered_qty_and_costs.txt
deleted file mode 100644
index b2ecb6c1ce9..00000000000
--- a/projects/search_criteria/projectwise_delivered_qty_and_costs/projectwise_delivered_qty_and_costs.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-[
- {
- "owner": "harshada@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "parent_doc_type": "Delivery Note",
- "module": "Projects",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Delivery Note\u0001Submitted':1,'Delivery Note\u0001Status':'Submitted','Delivery Note\u0001Fiscal Year':''}",
- "doc_type": "Delivery Note Item",
- "name": "__common__",
- "add_cond": "IFNULL(`tabDelivery Note`.`project_name`,\"\")!=\"\"",
- "doctype": "Search Criteria",
- "sort_by": "`tabDelivery Note`.`name`",
- "page_len": 50,
- "criteria_name": "Projectwise Delivered Qty and Costs",
- "columns": "Delivery Note\u0001ID,Delivery Note\u0001Project Name,Delivery Note\u0001Customer,Delivery Note\u0001Customer Name,Delivery Note Item\u0001Item Code,Delivery Note Item\u0001Item Name,Delivery Note Item\u0001Quantity,Delivery Note\u0001Posting Date,Delivery Note\u0001% Billed,Delivery Note Item\u0001Amount*"
- },
- {
- "name": "projectwise_delivered_qty_and_costs",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/projects/search_criteria/projectwise_pending_qty_and_costs/__init__.py b/projects/search_criteria/projectwise_pending_qty_and_costs/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/projects/search_criteria/projectwise_pending_qty_and_costs/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/projects/search_criteria/projectwise_pending_qty_and_costs/projectwise_pending_qty_and_costs.js b/projects/search_criteria/projectwise_pending_qty_and_costs/projectwise_pending_qty_and_costs.js
deleted file mode 100644
index ce56077bd74..00000000000
--- a/projects/search_criteria/projectwise_pending_qty_and_costs/projectwise_pending_qty_and_costs.js
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.hide_all_filters();
-
- //this.add_filter({fieldname:'item_code', label:'Item Code', fieldtype:'Link', options:'Item',ignore : 1,parent:'Sales Order Item'});
-
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Project Name'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Customer'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Customer Name'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Project Name'].df.in_first_page = 1;
-
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
-}
diff --git a/projects/search_criteria/projectwise_pending_qty_and_costs/projectwise_pending_qty_and_costs.txt b/projects/search_criteria/projectwise_pending_qty_and_costs/projectwise_pending_qty_and_costs.txt
deleted file mode 100644
index 37b62944e8f..00000000000
--- a/projects/search_criteria/projectwise_pending_qty_and_costs/projectwise_pending_qty_and_costs.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-[
- {
- "owner": "ashwini@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "add_col": "SUM(`tabSales Order Item`.`qty` - `tabSales Order Item`.`delivered_qty`) AS 'Pending Qty'\nSUM((`tabSales Order Item`.`qty` - `tabSales Order Item`.`delivered_qty`)* `tabSales Order Item`.basic_rate) AS 'Pending Amount'",
- "parent_doc_type": "Sales Order",
- "module": "Projects",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Sales Order\u0001Submitted':1,'Sales Order\u0001Status':'Submitted','Sales Order\u0001Fiscal Year':''}",
- "doc_type": "Sales Order Item",
- "name": "__common__",
- "add_cond": "`tabSales Order Item`.`qty` > `tabSales Order Item`.`delivered_qty`\nIFNULL(`tabSales Order`.`project_name`,\"\")!=\"\"\n`tabSales Order`.order_type = 'Sales'",
- "doctype": "Search Criteria",
- "sort_by": "`tabSales Order`.`name`",
- "page_len": 50,
- "criteria_name": "Projectwise Pending Qty and Costs",
- "columns": "Sales Order\u0001ID,Sales Order\u0001Project Name,Sales Order\u0001Customer,Sales Order\u0001Customer Name,Sales Order Item\u0001Item Code,Sales Order Item\u0001Item Name,Sales Order\u0001% Delivered,Sales Order\u0001% Billed,Sales Order\u0001Sales Order Date,Sales Order\u0001Expected Delivery Date"
- },
- {
- "name": "projectwise_pending_qty_and_costs",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/projects/search_criteria/projectwise_purchase_details/__init__.py b/projects/search_criteria/projectwise_purchase_details/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/projects/search_criteria/projectwise_purchase_details/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/projects/search_criteria/projectwise_purchase_details/projectwise_purchase_details.js b/projects/search_criteria/projectwise_purchase_details/projectwise_purchase_details.js
deleted file mode 100644
index bd4be54e78d..00000000000
--- a/projects/search_criteria/projectwise_purchase_details/projectwise_purchase_details.js
+++ /dev/null
@@ -1,108 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- //hide all filters
- //------------------------------------------------
- this.hide_all_filters();
-
- //add filters
- //------------------------------------------------
- this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Purchase Order'+NEWLINE+'Purchase Invoice'+NEWLINE+'Purchase Receipt',report_default:'Purchase Order',ignore : 1,parent:'Purchase Order', single_select:1});
-
- this.add_filter({fieldname:'purchase_order', label:'Purchase Order', fieldtype:'Link', options:'Purchase Order', ignore : 1, parent:'Purchase Order'});
- this.add_filter({fieldname:'purchase_receipt', label:'Purchase Receipt',fieldtype:'Link', options:'Purchase Receipt',ignore : 1, parent:'Purchase Order'});
- this.add_filter({fieldname:'purchase_invoice', label:'Purchase Invoice',fieldtype:'Link', options:'Purchase Invoice',ignore : 1, parent:'Purchase Order'});
-
- //unhide filters
- //------------------------------------------------
- this.filter_fields_dict['Purchase Order'+FILTER_SEP +'Project Name'].df.filter_hide = 0;
- this.filter_fields_dict['Purchase Order'+FILTER_SEP +'Company'].df.filter_hide = 0;
- this.filter_fields_dict['Purchase Order'+FILTER_SEP +'Fiscal Year'].df.filter_hide = 0;
-
- //move filter field in first page
- //------------------------------------------------
- this.filter_fields_dict['Purchase Order'+FILTER_SEP +'Based On'].df.in_first_page = 1;
- this.filter_fields_dict['Purchase Order'+FILTER_SEP +'Project Name'].df.in_first_page = 1;
- this.filter_fields_dict['Purchase Order'+FILTER_SEP +'Purchase Order'].df.in_first_page = 1;
- this.filter_fields_dict['Purchase Order'+FILTER_SEP +'Purchase Invoice'].df.in_first_page = 1;
- this.filter_fields_dict['Purchase Order'+FILTER_SEP +'Purchase Receipt'].df.in_first_page = 1;
-
- // default values
- //------------------------------------------------
- this.filter_fields_dict['Purchase Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
- this.filter_fields_dict['Purchase Order'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
-}
-
-//hide select columns field
-//------------------------------------------------
-this.mytabs.items['Select Columns'].hide();
-
-
-report.get_query = function() {
-
- //get filter values
- based_on = this.filter_fields_dict['Purchase Order'+FILTER_SEP+'Based On'].get_value();
- purchase_order = this.filter_fields_dict['Purchase Order'+FILTER_SEP+'Purchase Order'].get_value();
- purchase_invoice = this.filter_fields_dict['Purchase Order'+FILTER_SEP+'Purchase Invoice'].get_value();
- purchase_receipt = this.filter_fields_dict['Purchase Order'+FILTER_SEP+'Purchase Receipt'].get_value();
- project_name = this.filter_fields_dict['Purchase Order'+FILTER_SEP+'Project Name'].get_value();
- company = this.filter_fields_dict['Purchase Order'+FILTER_SEP+'Company'].get_value();
- fy = this.filter_fields_dict['Purchase Order'+FILTER_SEP+'Fiscal Year'].get_value();
-
- // make query based on transaction
- //-------------------------------------------------------------------------------------------
-
- var cond = '';
- //for purchase order
- if(based_on == 'Purchase Order'){
-
- if(purchase_order) cond += ' AND `tabPurchase Order`.name = "'+purchase_order+'"';
- if(project_name) cond += ' AND `tabPurchase Order`.project_name = "'+project_name+'"';
- if(company) cond += ' AND `tabPurchase Order`.company = "'+company+'"';
- if(fy !='') cond += ' AND `tabPurchase Order`.fiscal_year = "'+fy+'"';
-
- var q = 'SELECT DISTINCT `tabPurchase Order`.name, `tabPurchase Order`.status, `tabPurchase Order`.project_name, `tabPurchase Order`.supplier,`tabPurchase Order`.supplier_name,`tabPurchase Order`.per_received, `tabPurchase Order`.per_billed, `tabPurchase Order`.grand_total FROM `tabPurchase Order` WHERE IFNULL(`tabPurchase Order`.project_name,"") != ""'+cond+' AND `tabPurchase Order`.docstatus != 2';
- return q;
- }
-
- //for purchase receipt
- else if(based_on == 'Purchase Receipt'){
- if(purchase_order) cond += ' t2.purchase_order = "'+purchase_order+'" AND ';
- if(purchase_receipt) cond += ' t1.name = "'+purchase_receipt+'" AND ';
- if(project_name) cond += ' t1.project_name = "'+project_name+'" AND ';
- if(company) cond += ' t1.company = "'+company+'" AND ';
- if(fy !='') cond += ' t1.fiscal_year = "'+fy+'" AND ';
-
-
- var q = 'SELECT DISTINCT t1.name, t1.status, t1.project_name, t1.supplier, t1.supplier_name,t1.grand_total FROM `tabPurchase Receipt` t1, `tabPurchase Receipt Item` t2 WHERE '+cond +'IFNULL(t1.project_name,"") !="" AND t1.docstatus != 2 AND t1.name = t2.parent';
-
- return q;
- }
- //for purchase invoice
- else if(based_on == 'Purchase Invoice'){
- if(purchase_order) cond += ' t2.purchase_order = "'+purchase_order+'" AND ';
- if(purchase_receipt) cond += ' t2.purchase_receipt = "'+purchase_receipt+'" AND';
- if(purchase_invoice) cond += ' t1.name = "'+purchase_invoice+'" AND';
- if(project_name) cond += ' t1.project_name = "'+project_name+'" AND ';
- if(company) cond += ' t1.company = "'+company+'" AND ';
- if(fy !='') cond += ' t1.fiscal_year = "'+fy+'" AND ';
-
- var q = 'SELECT DISTINCT t1.name , t1.credit_to , t1.project_name, t1.supplier, t1.supplier_name , t1.grand_total FROM `tabPurchase Invoice` t1, `tabPurchase Invoice Item` t2 WHERE '+cond +'IFNULL(t1.project_name,"") !="" AND t1.docstatus != 2 AND t1.name = t2.parent';
-
- return q;
- }
-}
\ No newline at end of file
diff --git a/projects/search_criteria/projectwise_purchase_details/projectwise_purchase_details.py b/projects/search_criteria/projectwise_purchase_details/projectwise_purchase_details.py
deleted file mode 100644
index ed82cebc791..00000000000
--- a/projects/search_criteria/projectwise_purchase_details/projectwise_purchase_details.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-from __future__ import unicode_literals
-based_on = filter_values.get('based_on')
-# make default columns
-#for r in res:
-col = []
-if based_on == 'Purchase Order':
- col = [['Purchase Order ID','Link','Purchase Order'],['Status','Data',''],['Project Name','Link','Project'],['Supplier','Link','Supplier'],['Supplier Name','Data',''],['% Received','Data',''],['% Billed','Data',''],['Grand Total','Currency','']]
-
-elif based_on == 'Purchase Invoice':
- col = [['Purchase Receipt ID','Link','Purchase Invoice'],['Status','Data',''],['Project Name','Link','Project'],['Supplier','Link','Supplier'],['Supplier Name','Data',''],['Grand Total','Currency','']]
-
-elif based_on == 'Purchase Receipt':
- col = [['Purchase Invoice ID','Link','Purchase Receipt'],['Credit To','Data',''],['Project Name','Link','Project'],['Supplier','Link','Supplier'],['Supplier Name','Data',''],['Grand Total','Currency','']]
-
-
-for c in col:
- colnames.append(c[0])
- coltypes.append(c[1])
- coloptions.append(c[2])
- l = (len(c[0])*9)
- if l < 150 : col_width = '150px'
- else: col_width = '%spx'%(l)
- colwidths.append(col_width)
- col_idx[c[0]] = len(colnames)-1
\ No newline at end of file
diff --git a/projects/search_criteria/projectwise_purchase_details/projectwise_purchase_details.txt b/projects/search_criteria/projectwise_purchase_details/projectwise_purchase_details.txt
deleted file mode 100644
index cb88f584e07..00000000000
--- a/projects/search_criteria/projectwise_purchase_details/projectwise_purchase_details.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-[
- {
- "owner": "ashwini@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "doc_type": "Purchase Order",
- "name": "__common__",
- "module": "Projects",
- "doctype": "Search Criteria",
- "sort_order": "DESC",
- "filters": "{'Purchase Order\u0001Status':'','Purchase Order\u0001Fiscal Year':''}",
- "page_len": 50,
- "criteria_name": "Projectwise Purchase Details",
- "standard": "Yes"
- },
- {
- "name": "projectwise_purchase_details",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/projects/search_criteria/projectwise_sales_details/__init__.py b/projects/search_criteria/projectwise_sales_details/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/projects/search_criteria/projectwise_sales_details/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/projects/search_criteria/projectwise_sales_details/projectwise_sales_details.js b/projects/search_criteria/projectwise_sales_details/projectwise_sales_details.js
deleted file mode 100644
index 4e92c3c4637..00000000000
--- a/projects/search_criteria/projectwise_sales_details/projectwise_sales_details.js
+++ /dev/null
@@ -1,112 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- //hide all filters
- //------------------------------------------------
- this.hide_all_filters();
-
- //add filters
- //------------------------------------------------
- this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice',report_default:'Sales Order',ignore : 1,parent:'Sales Order', single_select:1});
-
- this.add_filter({fieldname:'sales_order', label:'Sales Order', fieldtype:'Link', options:'Sales Order', ignore : 1, parent:'Sales Order'});
- this.add_filter({fieldname:'delivery_note', label:'Delivery Note', fieldtype:'Link', options:'Delivery Note',ignore : 1, parent:'Sales Order'});
- this.add_filter({fieldname:'sales_invoice', label:'Sales Invoice',fieldtype:'Link', options:'Sales Invoice',ignore : 1, parent:'Sales Order'});
-
- //unhide filters
- //------------------------------------------------
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Project Name'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Customer'].df.filter_hide = 0;
-
- //move filter field in first page
- //------------------------------------------------
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Based On'].df.in_first_page = 1;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Project Name'].df.in_first_page = 1;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Sales Order'].df.in_first_page = 1;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Delivery Note'].df.in_first_page = 1;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Sales Invoice'].df.in_first_page = 1;
-
- // default values
- //------------------------------------------------
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
-
-}
-
-//hide select columns field
-//------------------------------------------------
-//this.mytabs.items['Select Columns'].hide();
-
-
-report.get_query = function() {
-
- //get filter values
- based_on = this.filter_fields_dict['Sales Order'+FILTER_SEP+'Based On'].get_value();
- sales_order = this.filter_fields_dict['Sales Order'+FILTER_SEP+'Sales Order'].get_value();
- delivery_note = this.filter_fields_dict['Sales Order'+FILTER_SEP+'Delivery Note'].get_value();
- sales_invoice = this.filter_fields_dict['Sales Order'+FILTER_SEP+'Sales Invoice'].get_value();
- project_name = this.filter_fields_dict['Sales Order'+FILTER_SEP+'Project Name'].get_value();
- company = this.filter_fields_dict['Sales Order'+FILTER_SEP+'Company'].get_value();
- fy = this.filter_fields_dict['Sales Order'+FILTER_SEP+'Fiscal Year'].get_value();
-
- // make query based on transaction
- //-------------------------------------------------------------------------------------------
-
- var cond = '';
- //for sales order
- if(based_on == 'Sales Order'){
-
- if(sales_order) cond += ' AND `tabSales Order`.name = "'+sales_order+'"';
- if(project_name) cond += ' AND `tabSales Order`.project_name = "'+project_name+'"';
- if(company) cond += ' AND `tabSales Order`.company = "'+company+'"';
- if(fy) cond += ' AND `tabSales Order`.fiscal_year = "'+fy+'"';
-
- var q = 'SELECT DISTINCT `tabSales Order`.name, `tabSales Order`.order_type, `tabSales Order`.status, `tabSales Order`.project_name, `tabSales Order`.customer,`tabSales Order`.customer_name,`tabSales Order`.per_delivered, `tabSales Order`.per_billed, `tabSales Order`.grand_total FROM `tabSales Order` WHERE IFNULL(`tabSales Order`.project_name,"") != ""'+cond+' AND `tabSales Order`.docstatus != 2';
- return q;
- }
-
- //for delivery note
- else if(based_on == 'Delivery Note'){
- if(sales_order) cond += ' t1.name = t2.parent AND t2.prevdoc_docname = "'+sales_order+'" AND ';
- if(delivery_note) cond += ' t1.name = "'+delivery_note+'" AND ';
- if(project_name) cond += ' t1.project_name = "'+project_name+'" AND ';
- if(company) cond += ' t1.company = "'+company+'" AND ';
- if(fy) cond += ' t1.fiscal_year = "'+fy+'" AND ';
-
- var q = 'SELECT DISTINCT t1.name, t1.status, t1.project_name, t1.customer, t1.customer_name, t1.per_billed, t1.per_installed, t1.grand_total FROM `tabDelivery Note` t1, `tabDelivery Note Item` t2 WHERE '+cond+' IFNULL(t1.project_name,"") !="" AND t1.docstatus != 2';
-
- return q;
- }
-
- //for sales invoice
- else if(based_on == 'Sales Invoice'){
- if(sales_order) cond += ' t2.sales_order = "'+sales_order+'" AND ';
- if(delivery_note) cond += ' t2.delivery_note = "'+delivery_note+'" AND ';
- if(sales_invoice) cond += ' t1.name = "'+sales_invoice+'" AND ';
- if(project_name) cond += ' t1.project_name = "'+project_name+'" AND ';
- if(company) cond += ' t1.company = "'+company+'" AND ';
- if(fy) cond += ' t1.fiscal_year = "'+fy+'" AND ';
-
-
- var q = 'SELECT DISTINCT t1.name , t1.debit_to , t1.project_name , t1.customer , t1.customer_name , t1.grand_total FROM `tabSales Invoice` t1, `tabSales Invoice Item` t2 WHERE '+cond +'IFNULL(t1.project_name,"") !="" AND t1.docstatus != 2 AND t1.name = t2.parent';
-
- return q;
- }
-
-}
\ No newline at end of file
diff --git a/projects/search_criteria/projectwise_sales_details/projectwise_sales_details.py b/projects/search_criteria/projectwise_sales_details/projectwise_sales_details.py
deleted file mode 100644
index 50ade660a32..00000000000
--- a/projects/search_criteria/projectwise_sales_details/projectwise_sales_details.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-from __future__ import unicode_literals
-based_on = filter_values.get('based_on')
-
-cols=[]
-
-if based_on == 'Sales Order':
- cols = [['Sales Order No','Link','150px','Sales Order'], ['Order Type','Data','100px',''], ['Status','Data','100px',''], ['Project Name','Link','150px','Project'], ['Customer','Link','150px','Customer'], ['Customer Name','Data','200px',''], ['% Delivered','Currency','100px',''], ['% Billed','Currency','100px',''], ['Grand Total','Currency','150px','']]
-
-elif based_on == 'Delivery Note':
- cols = [['Delivery Note No','Link','150px','Delivery Note'], ['Status','Data','100px',''], ['Project Name','Link','200px','Project'], ['Customer','Link','150px','Customer'], ['Customer Name','Data','200px',''], ['% Installed','Currency','100px',''], ['% Billed','Currency','100px',''], ['Grand Total','Currency','150px','']]
-
-elif based_on == 'Sales Invoice':
- cols = [['Sales Invoice No','Link','150px','Sales Invoice'], ['Debit To','Data','150px',''], ['Project Name','Link','200px','Project'], ['Customer','Link','150px','Customer'], ['Customer Name','Data','200px',''], ['Grand Total','Currency','150px','']]
-
-
-for c in cols:
- colnames.append(c[0])
- coltypes.append(c[1])
- colwidths.append(c[2])
- coloptions.append(c[3])
- col_idx[c[0]] = len(colnames)-1
\ No newline at end of file
diff --git a/projects/search_criteria/projectwise_sales_details/projectwise_sales_details.txt b/projects/search_criteria/projectwise_sales_details/projectwise_sales_details.txt
deleted file mode 100644
index 11a50a6e0bb..00000000000
--- a/projects/search_criteria/projectwise_sales_details/projectwise_sales_details.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-[
- {
- "owner": "harshada@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "doc_type": "Sales Order",
- "name": "__common__",
- "module": "Projects",
- "doctype": "Search Criteria",
- "sort_order": "DESC",
- "filters": "{'Sales Order\u0001Saved':1,'Sales Order\u0001Submitted':1,'Sales Order\u0001Status':''}",
- "page_len": 50,
- "criteria_name": "Projectwise Sales Details",
- "standard": "Yes"
- },
- {
- "name": "projectwise_sales_details",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/projects/search_criteria/projectwise_sales_orders/__init__.py b/projects/search_criteria/projectwise_sales_orders/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/projects/search_criteria/projectwise_sales_orders/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/projects/search_criteria/projectwise_sales_orders/projectwise_sales_orders.txt b/projects/search_criteria/projectwise_sales_orders/projectwise_sales_orders.txt
deleted file mode 100644
index 29919e6d12a..00000000000
--- a/projects/search_criteria/projectwise_sales_orders/projectwise_sales_orders.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "harshada@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "module": "Projects",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Sales Order\u0001Saved':1,'Sales Order\u0001Submitted':1,'Sales Order\u0001Status':'','Sales Order\u0001Fiscal Year':''}",
- "doc_type": "Sales Order",
- "name": "__common__",
- "add_cond": "ifnull(`tabSales Order`.project_name ,'') != ''",
- "doctype": "Search Criteria",
- "sort_by": "`tabSales Order`.`name`",
- "page_len": 50,
- "criteria_name": "Projectwise Sales Orders",
- "columns": "Sales Order\u0001ID,Sales Order\u0001Status,Sales Order\u0001Project Name,Sales Order\u0001Customer,Sales Order\u0001Sales Order Date,Sales Order\u0001Expected Delivery Date,Sales Order\u0001Quotation No,Sales Order\u0001% Delivered,Sales Order\u0001% Billed,Sales Order\u0001Grand Total*"
- },
- {
- "name": "projectwise_sales_orders",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/projects/search_criteria/timesheet_report/__init__.py b/projects/search_criteria/timesheet_report/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/projects/search_criteria/timesheet_report/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/projects/search_criteria/timesheet_report/timesheet_report.js b/projects/search_criteria/timesheet_report/timesheet_report.js
deleted file mode 100644
index 12d9680146c..00000000000
--- a/projects/search_criteria/timesheet_report/timesheet_report.js
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.filter_fields_dict['Timesheet Detail'+FILTER_SEP +'Project Name'].df.in_first_page = 1;
- this.filter_fields_dict['Timesheet Detail'+FILTER_SEP +'Task Id'].df.in_first_page = 1;
-this.filter_fields_dict['Timesheet'+FILTER_SEP +'Timesheet by'].df.filter_hide = 1;
-}
-
-//this.mytabs.items['Select Columns'].hide()
\ No newline at end of file
diff --git a/projects/search_criteria/timesheet_report/timesheet_report.txt b/projects/search_criteria/timesheet_report/timesheet_report.txt
deleted file mode 100644
index 14bbe084d3f..00000000000
--- a/projects/search_criteria/timesheet_report/timesheet_report.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "ashwini@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:53",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:53"
- },
- {
- "parent_doc_type": "Timesheet",
- "module": "Projects",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Timesheet\u0001Saved':1,'Timesheet\u0001Submitted':1}",
- "doc_type": "Timesheet Detail",
- "name": "__common__",
- "doctype": "Search Criteria",
- "sort_by": "`tabTimesheet`.`name`",
- "page_len": 50,
- "criteria_name": "Timesheet Report",
- "columns": "Timesheet\u0001ID,Timesheet\u0001Timesheet Date,Timesheet\u0001Timesheet by,Timesheet Detail\u0001Project Name,Timesheet Detail\u0001Task Id,Timesheet Detail\u0001Task Name,Timesheet Detail\u0001Actual Start Time,Timesheet Detail\u0001Actual End Time,Timesheet Detail\u0001Total Hours (Actual)"
- },
- {
- "name": "timesheet_report",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/projects/utils.py b/projects/utils.py
index a7a016ab3e0..e37a21c2c49 100644
--- a/projects/utils.py
+++ b/projects/utils.py
@@ -5,4 +5,25 @@ import webnotes
@webnotes.whitelist()
def get_time_log_list(doctype, txt, searchfield, start, page_len, filters):
- return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"], debug=True)
\ No newline at end of file
+ return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"])
+
+@webnotes.whitelist()
+def query_task(doctype, txt, searchfield, start, page_len, filters):
+ from webnotes.widgets.reportview import build_match_conditions
+
+ search_string = "%%%s%%" % txt
+ order_by_string = "%s%%" % txt
+ match_conditions = build_match_conditions("Task")
+ match_conditions = ("and" + match_conditions) if match_conditions else ""
+
+ return webnotes.conn.sql("""select name, subject from `tabTask`
+ where (`%s` like %s or `subject` like %s) %s
+ order by
+ case when `subject` like %s then 0 else 1 end,
+ case when `%s` like %s then 0 else 1 end,
+ `%s`,
+ subject
+ limit %s, %s""" %
+ (searchfield, "%s", "%s", match_conditions, "%s",
+ searchfield, "%s", searchfield, "%s", "%s"),
+ (search_string, search_string, order_by_string, order_by_string, start, page_len))
\ No newline at end of file
diff --git a/public/js/complete_setup.js b/public/js/complete_setup.js
index f5d06722c61..37c2fba52e5 100644
--- a/public/js/complete_setup.js
+++ b/public/js/complete_setup.js
@@ -40,7 +40,7 @@ $.extend(erpnext.complete_setup, {
{fieldname:'country', label: 'Country', reqd:1,
options: "", fieldtype: 'Select'},
{fieldname:'currency', label: 'Default Currency', reqd:1,
- options: "Currency", fieldtype: 'Link'},
+ options: "", fieldtype: 'Select'},
{fieldname:'timezone', label: 'Time Zone', reqd:1,
options: "", fieldtype: 'Select'},
{fieldname:'industry', label: 'Industry', reqd:1,
@@ -55,11 +55,17 @@ $.extend(erpnext.complete_setup, {
}
wn.call({
- method:"webnotes.country_info.get_all",
+ method:"webnotes.country_info.get_country_timezone_info",
callback: function(data) {
- erpnext.country_info = data.message;
+ erpnext.country_info = data.message.country_info;
+ erpnext.all_timezones = data.message.all_timezones;
d.get_input("country").empty()
- .add_options([""].concat(keys(data.message).sort()));
+ .add_options([""].concat(keys(erpnext.country_info).sort()));
+ d.get_input("currency").empty()
+ .add_options(wn.utils.unique([""].concat($.map(erpnext.country_info,
+ function(opts, country) { return opts.currency; }))).sort());
+ d.get_input("timezone").empty()
+ .add_options([""].concat(erpnext.all_timezones));
}
})
@@ -69,12 +75,17 @@ $.extend(erpnext.complete_setup, {
if(!data) return;
$(this).set_working();
$c_obj('Setup Control','setup_account',data,function(r, rt){
- sys_defaults = r.message;
- user_fullname = r.message.user_fullname;
- wn.boot.user_info[user].fullname = user_fullname;
- d.hide();
- $('header').toggle(true);
- wn.container.wntoolbar.set_user_name();
+ if(!r.exc) {
+ sys_defaults = r.message;
+ user_fullname = r.message.user_fullname;
+ wn.boot.user_info[user].fullname = user_fullname;
+ d.hide();
+ $('header').toggle(true);
+ wn.container.wntoolbar.set_user_name();
+
+ setTimeout(function() { window.location.reload(); }, 3000);
+ }
+
});
};
@@ -82,19 +93,15 @@ $.extend(erpnext.complete_setup, {
var country = d.fields_dict.country.input.value;
var $timezone = $(d.fields_dict.timezone.input);
$timezone.empty();
+ // add country specific timezones first
if(country){
- var timezone_list = erpnext.country_info[country].timezones;
- if(timezone_list.length==0) {
- timezone_list = $.map(erpnext.country_info, function(m) {
- return m.timezones
- });
- }
- $timezone.empty().add_options(timezone_list);
-
- console.log(d.get_input("currency"))
+ var timezone_list = erpnext.country_info[country].timezones || [];
+ $timezone.add_options(timezone_list.sort());
d.get_input("currency").val(erpnext.country_info[country].currency);
}
+ // add all timezones at the end, so that user has the option to change it to any timezone
+ $timezone.add_options([""].concat(erpnext.all_timezones));
};
@@ -127,5 +134,5 @@ $.extend(erpnext.complete_setup, {
'Finance', 'Food and Beverage', 'Government', 'Healthcare', 'Hospitality',
'Information Technology', 'Insurance', 'Machinery', 'Manufacturing', 'Media',
'Not For Profit', 'Recreation', 'Retail', 'Shipping', 'Technology',
- 'Telecommunications', 'Transportation', 'Trading', 'Utilities', 'Other'],
+ 'Telecommunications', 'Transportation', 'Trading', 'Utilities', 'Other'],
});
\ No newline at end of file
diff --git a/public/js/purchase_trends_filters.js b/public/js/purchase_trends_filters.js
new file mode 100644
index 00000000000..117b9de1f7e
--- /dev/null
+++ b/public/js/purchase_trends_filters.js
@@ -0,0 +1,39 @@
+var get_filters = function(){
+ return [
+ {
+ "fieldname":"period",
+ "label": "Period",
+ "fieldtype": "Select",
+ "options": ["Monthly", "Quarterly", "Half-Yearly", "Yearly"].join("\n"),
+ "default": "Monthly"
+ },
+ {
+ "fieldname":"based_on",
+ "label": "Based On",
+ "fieldtype": "Select",
+ "options": ["Item", "Item Group", "Supplier", "Supplier Type", "Project"].join("\n"),
+ "default": "Item"
+ },
+ {
+ "fieldname":"group_by",
+ "label": "Group By",
+ "fieldtype": "Select",
+ "options": ["Item", "Supplier"].join("\n"),
+ "default": ""
+ },
+ {
+ "fieldname":"fiscal_year",
+ "label": "Fiscal Year",
+ "fieldtype": "Link",
+ "options":'Fiscal Year',
+ "default": sys_defaults.fiscal_year
+ },
+ {
+ "fieldname":"company",
+ "label": "Company",
+ "fieldtype": "Link",
+ "options": "Company",
+ "default": sys_defaults.company
+ },
+ ];
+}
\ No newline at end of file
diff --git a/public/js/queries.js b/public/js/queries.js
index 9809cd980d0..24ddc135903 100644
--- a/public/js/queries.js
+++ b/public/js/queries.js
@@ -160,4 +160,8 @@ erpnext.queries.bom = function(opts) {
: "")
+ " LIMIT 50"
-}
\ No newline at end of file
+}
+
+erpnext.queries.task = function() {
+ return { query: "projects.utils.query_task" };
+};
\ No newline at end of file
diff --git a/public/js/sales_trends_filters.js b/public/js/sales_trends_filters.js
new file mode 100644
index 00000000000..f461d08b54f
--- /dev/null
+++ b/public/js/sales_trends_filters.js
@@ -0,0 +1,39 @@
+var get_filters = function(){
+ return[
+ {
+ "fieldname":"period",
+ "label": "Period",
+ "fieldtype": "Select",
+ "options": ["Monthly", "Quarterly", "Half-Yearly", "Yearly"].join("\n"),
+ "default": "Monthly"
+ },
+ {
+ "fieldname":"based_on",
+ "label": "Based On",
+ "fieldtype": "Select",
+ "options": ["Item", "Item Group", "Customer", "Customer Group", "Territory", "Project"].join("\n"),
+ "default": "Item"
+ },
+ {
+ "fieldname":"group_by",
+ "label": "Group By",
+ "fieldtype": "Select",
+ "options": ["Item", "Customer"].join("\n"),
+ "default": ""
+ },
+ {
+ "fieldname":"fiscal_year",
+ "label": "Fiscal Year",
+ "fieldtype": "Link",
+ "options":'Fiscal Year',
+ "default": sys_defaults.fiscal_year
+ },
+ {
+ "fieldname":"company",
+ "label": "Company",
+ "fieldtype": "Link",
+ "options": "Company",
+ "default": sys_defaults.company
+ },
+ ];
+}
\ No newline at end of file
diff --git a/public/js/stock_analytics.js b/public/js/stock_analytics.js
index c3ed1cb232f..91384f61ed9 100644
--- a/public/js/stock_analytics.js
+++ b/public/js/stock_analytics.js
@@ -162,6 +162,8 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
} else {
break;
}
+
+ me.round_item_values(item);
}
}
},
diff --git a/selling/doctype/customer/customer.js b/selling/doctype/customer/customer.js
index 403b83f5823..40a7846430e 100644
--- a/selling/doctype/customer/customer.js
+++ b/selling/doctype/customer/customer.js
@@ -57,7 +57,7 @@ cur_frm.cscript.make_address = function() {
if(!cur_frm.address_list) {
cur_frm.address_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['address_html'].wrapper,
- page_length: 2,
+ page_length: 5,
new_doctype: "Address",
custom_new_doc: function(doctype) {
var address = wn.model.make_new_doc_and_get_name('Address');
@@ -88,7 +88,7 @@ cur_frm.cscript.make_contact = function() {
if(!cur_frm.contact_list) {
cur_frm.contact_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['contact_html'].wrapper,
- page_length: 2,
+ page_length: 5,
custom_new_doc: function(doctype) {
var contact = wn.model.make_new_doc_and_get_name('Contact');
contact = locals['Contact'][contact];
diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py
index 7e16341a4a3..65ac865304b 100644
--- a/selling/doctype/customer/customer.py
+++ b/selling/doctype/customer/customer.py
@@ -115,18 +115,20 @@ class DocType(TransactionBase):
if not webnotes.conn.exists("Account", (self.doc.name + " - " + abbr)):
parent_account = self.get_receivables_group()
# create
- from accounts.utils import add_ac
- ac = add_ac({
- 'account_name':self.doc.name,
+ ac_bean = webnotes.bean({
+ "doctype": "Account",
+ 'account_name': self.doc.name,
'parent_account': parent_account,
'group_or_ledger':'Ledger',
'company':self.doc.company,
- 'account_type':'',
- 'tax_rate':'0',
'master_type':'Customer',
- 'master_name':self.doc.name
+ 'master_name':self.doc.name,
+ "freeze_account": "No"
})
- msgprint("Account Head: %s created" % ac)
+ ac_bean.ignore_permissions = True
+ ac_bean.insert()
+
+ msgprint("Account Head: %s created" % ac_bean.doc.name)
else :
msgprint("Please Select Company under which you want to create account head")
@@ -216,35 +218,16 @@ class DocType(TransactionBase):
if self.doc.lead_name:
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
- def on_rename(self, new, old):
+ def on_rename(self, new, old, merge=False):
#update customer_name if not naming series
if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name':
- update_fields = [
- ('Customer', 'name'),
- ('Address', 'customer'),
- ('Contact', 'customer'),
- ('Customer Issue', 'customer'),
- ('Delivery Note', 'customer'),
- ('Opportunity', 'customer'),
- ('Installation Note', 'customer'),
- ('Maintenance Schedule', 'customer'),
- ('Maintenance Visit', 'customer'),
- ('Project', 'customer'),
- ('Quotation', 'customer'),
- ('Sales Invoice', 'customer'),
- ('Sales Order', 'customer'),
- ('Serial No', 'customer'),
- ('Shipping Address', 'customer'),
- ('Stock Entry', 'customer'),
- ('Support Ticket', 'customer')]
- for rec in update_fields:
- sql("""update `tab%s` set customer_name = %s
- where `%s` = %s""" % (rec[0], "%s" ,rec[1], "%s"), (new, old))
+ webnotes.conn.sql("""update `tabCustomer` set customer_name = %s where name = %s""",
+ (new, old))
for account in webnotes.conn.sql("""select name, account_name from
tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1):
if account.account_name != new:
- webnotes.rename_doc("Account", account.name, new)
+ webnotes.rename_doc("Account", account.name, new, merge=merge)
#update master_name in doctype account
webnotes.conn.sql("""update `tabAccount` set master_name = %s,
diff --git a/selling/doctype/customer/customer.txt b/selling/doctype/customer/customer.txt
index a221daa599b..d7cecdd1bfc 100644
--- a/selling/doctype/customer/customer.txt
+++ b/selling/doctype/customer/customer.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-01-23 19:57:18",
+ "creation": "2013-06-11 14:26:44",
"docstatus": 0,
- "modified": "2013-01-29 16:28:03",
+ "modified": "2013-06-11 14:27:57",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -270,7 +270,7 @@
"label": "Credit Days",
"oldfieldname": "credit_days",
"oldfieldtype": "Int",
- "permlevel": 2
+ "permlevel": 1
},
{
"doctype": "DocField",
@@ -280,7 +280,7 @@
"oldfieldname": "credit_limit",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
- "permlevel": 2
+ "permlevel": 1
},
{
"doctype": "DocField",
@@ -339,7 +339,7 @@
},
{
"doctype": "DocPerm",
- "permlevel": 2,
+ "permlevel": 1,
"role": "Sales User"
},
{
@@ -355,7 +355,7 @@
},
{
"doctype": "DocPerm",
- "permlevel": 2,
+ "permlevel": 1,
"role": "Sales Master Manager",
"write": 1
}
diff --git a/selling/doctype/customer/test_customer.py b/selling/doctype/customer/test_customer.py
index 551b03f0be7..806585f1e1a 100644
--- a/selling/doctype/customer/test_customer.py
+++ b/selling/doctype/customer/test_customer.py
@@ -1,4 +1,60 @@
+from __future__ import unicode_literals
+import webnotes
+import unittest
+
+class TestCustomer(unittest.TestCase):
+ def test_rename(self):
+ self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"),
+ (("_Test Customer 1",),))
+
+ webnotes.rename_doc("Customer", "_Test Customer 1", "_Test Customer 1 Renamed")
+
+ self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1 Renamed"),
+ (("_Test Customer 1 Renamed",),))
+ self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"), ())
+
+ def test_merge(self):
+ from webnotes.test_runner import make_test_records
+ make_test_records("Sales Invoice")
+
+ # clear transactions for new name
+ webnotes.conn.sql("""delete from `tabSales Invoice` where customer='_Test Customer 1'""")
+
+ # check if they exist
+ self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"),
+ (("_Test Customer",),))
+ self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"),
+ (("_Test Customer 1",),))
+ self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"),
+ (("_Test Customer - _TC",),))
+ self.assertEqual(webnotes.conn.exists("Account", "_Test Customer 1 - _TC"),
+ (("_Test Customer 1 - _TC",),))
+
+ # check if transactions exists
+ self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
+ where customer='_Test Customer'""", )[0][0], 0)
+ self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
+ where debit_to='_Test Customer - _TC'""", )[0][0], 0)
+
+ webnotes.rename_doc("Customer", "_Test Customer", "_Test Customer 1", merge=True)
+
+ # check that no transaction exists for old name
+ self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
+ where customer='_Test Customer 1'""", )[0][0], 0)
+ self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
+ where debit_to='_Test Customer 1 - _TC'""", )[0][0], 0)
+
+ # check that transactions exist for new name
+ self.assertEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
+ where customer='_Test Customer'""", )[0][0], 0)
+ self.assertEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
+ where debit_to='_Test Customer - _TC'""", )[0][0], 0)
+
+ # check that old name doesn't exist
+ self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"), ())
+ self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"), ())
+
test_records = [
[{
"doctype": "Customer",
@@ -7,5 +63,13 @@ test_records = [
"customer_group": "_Test Customer Group",
"territory": "_Test Territory",
"company": "_Test Company"
+ }],
+ [{
+ "doctype": "Customer",
+ "customer_name": "_Test Customer 1",
+ "customer_type": "Individual",
+ "customer_group": "_Test Customer Group",
+ "territory": "_Test Territory",
+ "company": "_Test Company"
}]
]
\ No newline at end of file
diff --git a/selling/doctype/installation_note/installation_note.py b/selling/doctype/installation_note/installation_note.py
index b0e1d966d9a..ea20d51d64d 100644
--- a/selling/doctype/installation_note/installation_note.py
+++ b/selling/doctype/installation_note/installation_note.py
@@ -18,9 +18,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, getdate
-from webnotes.model import db_exists
-from webnotes.model.doc import make_autoname
-from webnotes.model.bean import getlist, copy_doclist
+from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
from stock.utils import get_valid_serial_nos
@@ -37,9 +35,6 @@ class DocType(TransactionBase):
self.tname = 'Installation Note Item'
self.fname = 'installed_item_details'
- def autoname(self):
- self.doc.name = make_autoname(self.doc.naming_series+'.#####')
-
def validate(self):
self.validate_fiscal_year()
self.validate_installation_date()
diff --git a/selling/doctype/installation_note/installation_note.txt b/selling/doctype/installation_note/installation_note.txt
index 52917e0b019..9dd851d5836 100644
--- a/selling/doctype/installation_note/installation_note.txt
+++ b/selling/doctype/installation_note/installation_note.txt
@@ -1,13 +1,13 @@
[
{
- "creation": "2013-01-10 16:34:18",
+ "creation": "2013-04-30 13:13:06",
"docstatus": 0,
- "modified": "2013-01-22 14:56:02",
+ "modified": "2013-05-09 14:43:28",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
- "autoname": "IN/.####",
+ "autoname": "naming_series:",
"doctype": "DocType",
"is_submittable": 1,
"module": "Selling",
@@ -33,6 +33,7 @@
"permlevel": 0,
"read": 1,
"report": 1,
+ "role": "Sales User",
"submit": 1,
"write": 1
},
@@ -302,15 +303,6 @@
"options": "Installation Note Item"
},
{
- "doctype": "DocPerm",
- "role": "System Manager"
- },
- {
- "doctype": "DocPerm",
- "role": "Sales User"
- },
- {
- "doctype": "DocPerm",
- "role": "Sales Manager"
+ "doctype": "DocPerm"
}
]
\ No newline at end of file
diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js
index d8d322d3249..118b4c723e2 100644
--- a/selling/doctype/lead/lead.js
+++ b/selling/doctype/lead/lead.js
@@ -104,7 +104,17 @@ cur_frm.cscript['Create Customer'] = function(){
'from_to_list':"[['Lead', 'Customer']]"
},
function(r,rt) {
- loaddoc("Customer", n);
+ wn.model.with_doctype("Customer", function() {
+ var customer = wn.model.get_doc("Customer", n);
+ var customer_copy = $.extend({}, customer);
+
+ var updated = wn.model.set_default_values(customer_copy);
+ $.each(updated, function(i, f) {
+ if(!customer[f]) customer[f] = customer_copy[f];
+ });
+
+ loaddoc("Customer", n);
+ });
}
);
}
diff --git a/selling/doctype/lead/lead.py b/selling/doctype/lead/lead.py
index 571cdfd5168..a54343a907f 100644
--- a/selling/doctype/lead/lead.py
+++ b/selling/doctype/lead/lead.py
@@ -17,8 +17,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes import _
-from webnotes.utils import cstr, validate_email_add
-from webnotes.model.doc import Document, addchild
+from webnotes.utils import cstr, validate_email_add, cint
from webnotes import session, msgprint
sql = webnotes.conn.sql
@@ -30,6 +29,13 @@ class DocType(SellingController):
self.doc = doc
self.doclist = doclist
+ self._prev = webnotes._dict({
+ "contact_date": webnotes.conn.get_value("Lead", self.doc.name, "contact_date") if \
+ (not cint(self.doc.fields.get("__islocal"))) else None,
+ "contact_by": webnotes.conn.get_value("Lead", self.doc.name, "contact_by") if \
+ (not cint(self.doc.fields.get("__islocal"))) else None,
+ })
+
def onload(self):
self.add_communication_list()
@@ -55,12 +61,18 @@ class DocType(SellingController):
msgprint('Please enter valid email id.')
raise Exception
-
def on_update(self):
- if self.doc.contact_date:
- self.add_calendar_event()
-
self.check_email_id_is_unique()
+ self.add_calendar_event()
+
+ def add_calendar_event(self, opts=None, force=False):
+ super(DocType, self).add_calendar_event({
+ "owner": self.doc.lead_owner,
+ "subject": ('Contact ' + cstr(self.doc.lead_name)),
+ "description": ('Contact ' + cstr(self.doc.lead_name)) + \
+ (self.doc.contact_by and ('. By : ' + cstr(self.doc.contact_by)) or '') + \
+ (self.doc.remark and ('.To Discuss : ' + cstr(self.doc.remark)) or '')
+ }, force)
def check_email_id_is_unique(self):
if self.doc.email_id:
@@ -71,27 +83,6 @@ class DocType(SellingController):
items = [e[0] for e in email_list if e[0]!=self.doc.name]
webnotes.msgprint(_("""Email Id must be unique, already exists for: """) + \
", ".join(items), raise_exception=True)
-
- def add_calendar_event(self):
- # delete any earlier event by this lead
- sql("delete from tabEvent where ref_type='Lead' and ref_name=%s", self.doc.name)
-
- # create new event
- ev = Document('Event')
- ev.owner = self.doc.lead_owner
- ev.description = ('Contact ' + cstr(self.doc.lead_name)) + \
- (self.doc.contact_by and ('. By : ' + cstr(self.doc.contact_by)) or '') + \
- (self.doc.remark and ('.To Discuss : ' + cstr(self.doc.remark)) or '')
- ev.event_date = self.doc.contact_date
- ev.event_hour = '10:00'
- ev.event_type = 'Private'
- ev.ref_type = 'Lead'
- ev.ref_name = self.doc.name
- ev.save(1)
-
- event_user = addchild(ev, 'event_individuals', 'Event User')
- event_user.person = self.doc.contact_by
- event_user.save()
def get_sender(self, comm):
return webnotes.conn.get_value('Sales Email Settings',None,'email_id')
@@ -100,3 +91,5 @@ class DocType(SellingController):
webnotes.conn.sql("""update tabCommunication set lead=null where lead=%s""", self.doc.name)
webnotes.conn.sql("""update `tabSupport Ticket` set lead='' where lead=%s""",
self.doc.name)
+
+ self.delete_events()
\ No newline at end of file
diff --git a/selling/doctype/opportunity/opportunity.py b/selling/doctype/opportunity/opportunity.py
index 75a7cd270d2..9fb061b228e 100644
--- a/selling/doctype/opportunity/opportunity.py
+++ b/selling/doctype/opportunity/opportunity.py
@@ -17,9 +17,7 @@
from __future__ import unicode_literals
import webnotes
-from webnotes.utils import add_days, cstr, getdate
-from webnotes.model import db_exists
-from webnotes.model.doc import Document, addchild
+from webnotes.utils import add_days, cstr, getdate, cint
from webnotes.model.bean import getlist
from webnotes import msgprint
@@ -34,6 +32,13 @@ class DocType(TransactionBase):
self.fname = 'enq_details'
self.tname = 'Opportunity Item'
+ self._prev = webnotes._dict({
+ "contact_date": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_date") if \
+ (not cint(self.doc.fields.get("__islocal"))) else None,
+ "contact_by": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_by") if \
+ (not cint(self.doc.fields.get("__islocal"))) else None,
+ })
+
def onload(self):
self.add_communication_list()
@@ -84,48 +89,34 @@ class DocType(TransactionBase):
def on_update(self):
# Add to calendar
if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
- if self.doc.contact_by:
- self.add_calendar_event()
webnotes.conn.set(self.doc, 'contact_date_ref',self.doc.contact_date)
- webnotes.conn.set(self.doc, 'status', 'Draft')
- def add_calendar_event(self):
- desc=''
- user_lst =[]
+ self.add_calendar_event()
+
+ def add_calendar_event(self, opts=None, force=False):
+ if not opts:
+ opts = webnotes._dict()
+
+ opts.description = ""
+
if self.doc.customer:
if self.doc.contact_person:
- desc = 'Contact '+cstr(self.doc.contact_person)
+ opts.description = 'Contact '+cstr(self.doc.contact_person)
else:
- desc = 'Contact customer '+cstr(self.doc.customer)
+ opts.description = 'Contact customer '+cstr(self.doc.customer)
elif self.doc.lead:
if self.doc.contact_display:
- desc = 'Contact '+cstr(self.doc.contact_display)
+ opts.description = 'Contact '+cstr(self.doc.contact_display)
else:
- desc = 'Contact lead '+cstr(self.doc.lead)
- desc = desc+ '. By : ' + cstr(self.doc.contact_by)
+ opts.description = 'Contact lead '+cstr(self.doc.lead)
+
+ opts.subject = opts.description
+ opts.description += '. By : ' + cstr(self.doc.contact_by)
if self.doc.to_discuss:
- desc = desc+' To Discuss : ' + cstr(self.doc.to_discuss)
+ opts.description += ' To Discuss : ' + cstr(self.doc.to_discuss)
- ev = Document('Event')
- ev.description = desc
- ev.event_date = self.doc.contact_date
- ev.event_hour = '10:00'
- ev.event_type = 'Private'
- ev.ref_type = 'Opportunity'
- ev.ref_name = self.doc.name
- ev.save(1)
-
- user_lst.append(self.doc.owner)
-
- chk = sql("select t1.name from `tabProfile` t1, `tabSales Person` t2 where t2.email_id = t1.name and t2.name=%s",self.doc.contact_by)
- if chk:
- user_lst.append(chk[0][0])
-
- for d in user_lst:
- ch = addchild(ev, 'event_individuals', 'Event User')
- ch.person = d
- ch.save(1)
+ super(DocType, self).add_calendar_event(opts, force)
def set_last_contact_date(self):
if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date:
@@ -159,6 +150,9 @@ class DocType(TransactionBase):
self.set_last_contact_date()
self.validate_item_details()
self.validate_lead_cust()
+
+ if not self.doc.status:
+ self.doc.status = "Draft"
def on_submit(self):
webnotes.conn.set(self.doc, 'status', 'Submitted')
@@ -180,3 +174,6 @@ class DocType(TransactionBase):
webnotes.conn.set(self.doc, 'status', 'Opportunity Lost')
webnotes.conn.set(self.doc, 'order_lost_reason', arg)
return 'true'
+
+ def on_trash(self):
+ self.delete_events()
\ No newline at end of file
diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt
index feda14c5917..4115be833b4 100644
--- a/selling/doctype/quotation/quotation.txt
+++ b/selling/doctype/quotation/quotation.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-04-03 09:10:44",
+ "creation": "2013-05-22 12:10:46",
"docstatus": 0,
- "modified": "2013-04-03 09:58:02",
+ "modified": "2013-05-22 16:54:07",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -833,12 +833,11 @@
"width": "100px"
},
{
- "description": "Keep a track on communications regarding this Quotation. This will help you remember earlier communications in case the Customer comes back again",
"doctype": "DocField",
"fieldname": "communication_history",
"fieldtype": "Section Break",
- "label": "Communication History",
"oldfieldtype": "Section Break",
+ "options": "Simple",
"print_hide": 1,
"read_only": 0
},
@@ -869,28 +868,23 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
- "role": "Sales Manager",
+ "role": "Sales User",
"submit": 1,
"write": 1
},
+ {
+ "doctype": "DocPerm",
+ "role": "Customer"
+ },
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
- "role": "Sales User",
+ "role": "Sales Manager",
"submit": 1,
"write": 1
},
- {
- "amend": 0,
- "cancel": 0,
- "create": 0,
- "doctype": "DocPerm",
- "role": "Customer",
- "submit": 0,
- "write": 0
- },
{
"amend": 1,
"cancel": 1,
diff --git a/selling/doctype/quotation_item/quotation_item.txt b/selling/doctype/quotation_item/quotation_item.txt
index dccc5037643..bcb9281cb96 100644
--- a/selling/doctype/quotation_item/quotation_item.txt
+++ b/selling/doctype/quotation_item/quotation_item.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-02-22 01:27:52",
+ "creation": "2013-03-07 11:42:57",
"docstatus": 0,
- "modified": "2013-03-07 07:03:29",
+ "modified": "2013-05-22 12:08:32",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -37,6 +37,7 @@
"options": "Item",
"print_hide": 0,
"print_width": "150px",
+ "read_only": 0,
"reqd": 1,
"search_index": 1,
"width": "150px"
@@ -60,6 +61,7 @@
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "150px",
+ "read_only": 0,
"reqd": 1,
"search_index": 1,
"width": "150px"
@@ -73,6 +75,7 @@
"oldfieldtype": "Small Text",
"print_hide": 0,
"print_width": "300px",
+ "read_only": 0,
"reqd": 1,
"width": "300px"
},
@@ -87,6 +90,7 @@
"oldfieldtype": "Currency",
"print_hide": 0,
"print_width": "100px",
+ "read_only": 0,
"reqd": 1,
"search_index": 0,
"width": "100px"
@@ -115,6 +119,7 @@
"options": "currency",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"reqd": 0,
"width": "100px"
},
@@ -128,6 +133,7 @@
"oldfieldtype": "Float",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"width": "100px"
},
{
@@ -142,6 +148,7 @@
"options": "currency",
"print_hide": 0,
"print_width": "100px",
+ "read_only": 0,
"reqd": 0,
"search_index": 0,
"width": "100px"
@@ -188,6 +195,7 @@
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"reqd": 0,
"search_index": 0,
"width": "100px"
@@ -291,6 +299,7 @@
"oldfieldname": "page_break",
"oldfieldtype": "Check",
"print_hide": 1,
+ "read_only": 0,
"report_hide": 1
}
]
\ No newline at end of file
diff --git a/accounts/search_criteria/__init__.py b/selling/doctype/sales_bom/__init__.py
similarity index 100%
rename from accounts/search_criteria/__init__.py
rename to selling/doctype/sales_bom/__init__.py
diff --git a/stock/doctype/sales_bom/locale/_messages_doc.json b/selling/doctype/sales_bom/locale/_messages_doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/_messages_doc.json
rename to selling/doctype/sales_bom/locale/_messages_doc.json
diff --git a/stock/doctype/sales_bom/locale/ar-doc.json b/selling/doctype/sales_bom/locale/ar-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/ar-doc.json
rename to selling/doctype/sales_bom/locale/ar-doc.json
diff --git a/stock/doctype/sales_bom/locale/de-doc.json b/selling/doctype/sales_bom/locale/de-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/de-doc.json
rename to selling/doctype/sales_bom/locale/de-doc.json
diff --git a/stock/doctype/sales_bom/locale/es-doc.json b/selling/doctype/sales_bom/locale/es-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/es-doc.json
rename to selling/doctype/sales_bom/locale/es-doc.json
diff --git a/stock/doctype/sales_bom/locale/fr-doc.json b/selling/doctype/sales_bom/locale/fr-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/fr-doc.json
rename to selling/doctype/sales_bom/locale/fr-doc.json
diff --git a/stock/doctype/sales_bom/locale/hi-doc.json b/selling/doctype/sales_bom/locale/hi-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/hi-doc.json
rename to selling/doctype/sales_bom/locale/hi-doc.json
diff --git a/stock/doctype/sales_bom/locale/hr-doc.json b/selling/doctype/sales_bom/locale/hr-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/hr-doc.json
rename to selling/doctype/sales_bom/locale/hr-doc.json
diff --git a/stock/doctype/sales_bom/locale/nl-doc.json b/selling/doctype/sales_bom/locale/nl-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/nl-doc.json
rename to selling/doctype/sales_bom/locale/nl-doc.json
diff --git a/stock/doctype/sales_bom/locale/pt-BR-doc.json b/selling/doctype/sales_bom/locale/pt-BR-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/pt-BR-doc.json
rename to selling/doctype/sales_bom/locale/pt-BR-doc.json
diff --git a/stock/doctype/sales_bom/locale/pt-doc.json b/selling/doctype/sales_bom/locale/pt-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/pt-doc.json
rename to selling/doctype/sales_bom/locale/pt-doc.json
diff --git a/stock/doctype/sales_bom/locale/sr-doc.json b/selling/doctype/sales_bom/locale/sr-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/sr-doc.json
rename to selling/doctype/sales_bom/locale/sr-doc.json
diff --git a/stock/doctype/sales_bom/locale/ta-doc.json b/selling/doctype/sales_bom/locale/ta-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/ta-doc.json
rename to selling/doctype/sales_bom/locale/ta-doc.json
diff --git a/stock/doctype/sales_bom/locale/th-doc.json b/selling/doctype/sales_bom/locale/th-doc.json
similarity index 100%
rename from stock/doctype/sales_bom/locale/th-doc.json
rename to selling/doctype/sales_bom/locale/th-doc.json
diff --git a/stock/doctype/sales_bom/sales_bom.js b/selling/doctype/sales_bom/sales_bom.js
similarity index 100%
rename from stock/doctype/sales_bom/sales_bom.js
rename to selling/doctype/sales_bom/sales_bom.js
diff --git a/stock/doctype/sales_bom/sales_bom.py b/selling/doctype/sales_bom/sales_bom.py
similarity index 100%
rename from stock/doctype/sales_bom/sales_bom.py
rename to selling/doctype/sales_bom/sales_bom.py
diff --git a/stock/doctype/sales_bom/sales_bom.txt b/selling/doctype/sales_bom/sales_bom.txt
similarity index 94%
rename from stock/doctype/sales_bom/sales_bom.txt
rename to selling/doctype/sales_bom/sales_bom.txt
index 031f2559196..bf8fa479c22 100644
--- a/stock/doctype/sales_bom/sales_bom.txt
+++ b/selling/doctype/sales_bom/sales_bom.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-01-10 16:34:29",
+ "creation": "2013-06-20 11:53:21",
"docstatus": 0,
- "modified": "2013-01-22 14:57:23",
+ "modified": "2013-06-25 16:43:18",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -11,7 +11,7 @@
"doctype": "DocType",
"document_type": "Master",
"is_submittable": 0,
- "module": "Stock",
+ "module": "Selling",
"name": "__common__"
},
{
@@ -23,7 +23,6 @@
"permlevel": 0
},
{
- "amend": 0,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Sales BOM",
@@ -74,6 +73,7 @@
"reqd": 1
},
{
+ "amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
@@ -81,6 +81,7 @@
"write": 1
},
{
+ "amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
@@ -88,6 +89,7 @@
"write": 0
},
{
+ "amend": 0,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
diff --git a/stock/doctype/sales_bom/test_sales_bom.py b/selling/doctype/sales_bom/test_sales_bom.py
similarity index 100%
rename from stock/doctype/sales_bom/test_sales_bom.py
rename to selling/doctype/sales_bom/test_sales_bom.py
diff --git a/accounts/search_criteria/accounts_payable/__init__.py b/selling/doctype/sales_bom_item/__init__.py
similarity index 100%
rename from accounts/search_criteria/accounts_payable/__init__.py
rename to selling/doctype/sales_bom_item/__init__.py
diff --git a/stock/doctype/sales_bom_item/locale/_messages_doc.json b/selling/doctype/sales_bom_item/locale/_messages_doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/_messages_doc.json
rename to selling/doctype/sales_bom_item/locale/_messages_doc.json
diff --git a/stock/doctype/sales_bom_item/locale/ar-doc.json b/selling/doctype/sales_bom_item/locale/ar-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/ar-doc.json
rename to selling/doctype/sales_bom_item/locale/ar-doc.json
diff --git a/stock/doctype/sales_bom_item/locale/de-doc.json b/selling/doctype/sales_bom_item/locale/de-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/de-doc.json
rename to selling/doctype/sales_bom_item/locale/de-doc.json
diff --git a/stock/doctype/sales_bom_item/locale/es-doc.json b/selling/doctype/sales_bom_item/locale/es-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/es-doc.json
rename to selling/doctype/sales_bom_item/locale/es-doc.json
diff --git a/stock/doctype/sales_bom_item/locale/fr-doc.json b/selling/doctype/sales_bom_item/locale/fr-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/fr-doc.json
rename to selling/doctype/sales_bom_item/locale/fr-doc.json
diff --git a/stock/doctype/sales_bom_item/locale/hi-doc.json b/selling/doctype/sales_bom_item/locale/hi-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/hi-doc.json
rename to selling/doctype/sales_bom_item/locale/hi-doc.json
diff --git a/stock/doctype/sales_bom_item/locale/hr-doc.json b/selling/doctype/sales_bom_item/locale/hr-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/hr-doc.json
rename to selling/doctype/sales_bom_item/locale/hr-doc.json
diff --git a/stock/doctype/sales_bom_item/locale/nl-doc.json b/selling/doctype/sales_bom_item/locale/nl-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/nl-doc.json
rename to selling/doctype/sales_bom_item/locale/nl-doc.json
diff --git a/stock/doctype/sales_bom_item/locale/pt-BR-doc.json b/selling/doctype/sales_bom_item/locale/pt-BR-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/pt-BR-doc.json
rename to selling/doctype/sales_bom_item/locale/pt-BR-doc.json
diff --git a/stock/doctype/sales_bom_item/locale/pt-doc.json b/selling/doctype/sales_bom_item/locale/pt-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/pt-doc.json
rename to selling/doctype/sales_bom_item/locale/pt-doc.json
diff --git a/stock/doctype/sales_bom_item/locale/sr-doc.json b/selling/doctype/sales_bom_item/locale/sr-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/sr-doc.json
rename to selling/doctype/sales_bom_item/locale/sr-doc.json
diff --git a/stock/doctype/sales_bom_item/locale/ta-doc.json b/selling/doctype/sales_bom_item/locale/ta-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/ta-doc.json
rename to selling/doctype/sales_bom_item/locale/ta-doc.json
diff --git a/stock/doctype/sales_bom_item/locale/th-doc.json b/selling/doctype/sales_bom_item/locale/th-doc.json
similarity index 100%
rename from stock/doctype/sales_bom_item/locale/th-doc.json
rename to selling/doctype/sales_bom_item/locale/th-doc.json
diff --git a/stock/doctype/sales_bom_item/sales_bom_item.py b/selling/doctype/sales_bom_item/sales_bom_item.py
similarity index 100%
rename from stock/doctype/sales_bom_item/sales_bom_item.py
rename to selling/doctype/sales_bom_item/sales_bom_item.py
diff --git a/stock/doctype/sales_bom_item/sales_bom_item.txt b/selling/doctype/sales_bom_item/sales_bom_item.txt
similarity index 93%
rename from stock/doctype/sales_bom_item/sales_bom_item.txt
rename to selling/doctype/sales_bom_item/sales_bom_item.txt
index 98285af1048..f7906b72d8b 100644
--- a/stock/doctype/sales_bom_item/sales_bom_item.txt
+++ b/selling/doctype/sales_bom_item/sales_bom_item.txt
@@ -1,15 +1,15 @@
[
{
- "creation": "2013-02-22 01:28:03",
+ "creation": "2013-05-23 16:55:51",
"docstatus": 0,
- "modified": "2013-03-07 07:03:30",
+ "modified": "2013-06-26 13:45:41",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "DocType",
"istable": 1,
- "module": "Stock",
+ "module": "Selling",
"name": "__common__"
},
{
diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py
index 7b1528bafe2..549128f1ea1 100644
--- a/selling/doctype/sales_common/sales_common.py
+++ b/selling/doctype/sales_common/sales_common.py
@@ -132,6 +132,7 @@ class DocType(TransactionBase):
where name = %s and (ifnull(end_of_life,'')='' or end_of_life > now()
or end_of_life = '0000-00-00') and (is_sales_item = 'Yes'
or is_service_item = 'Yes')""", args['item_code'], as_dict=1)
+
tax = webnotes.conn.sql("""select tax_type, tax_rate from `tabItem Tax`
where parent = %s""", args['item_code'])
t = {}
@@ -167,8 +168,9 @@ class DocType(TransactionBase):
ret['export_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
ret['base_ref_rate'] = flt(base_ref_rate)
ret['basic_rate'] = flt(base_ref_rate)
-
+
if ret['warehouse'] or ret['reserved_warehouse']:
+
av_qty = self.get_available_qty({'item_code': args['item_code'], 'warehouse': ret['warehouse'] or ret['reserved_warehouse']})
ret.update(av_qty)
@@ -179,7 +181,7 @@ class DocType(TransactionBase):
(args['item_code'], obj.doc.customer))
if customer_item_code_row and customer_item_code_row[0][0]:
ret['customer_item_code'] = customer_item_code_row[0][0]
-
+
return ret
@@ -374,7 +376,7 @@ class DocType(TransactionBase):
msgprint("Please Enter Appropriate Conversion Rate for Customer's Currency to Base Currency (%s --> %s)" % (obj.doc.currency, default_currency), raise_exception = 1)
if (obj.doc.price_list_currency == default_currency and flt(obj.doc.plc_conversion_rate) != 1.00) or not obj.doc.plc_conversion_rate or (obj.doc.price_list_currency != default_currency and flt(obj.doc.plc_conversion_rate) == 1.00):
- msgprint("Please Enter Appropriate Conversion Rate for Price List Currency to Base Currency ( (%s --> %s)" % (obj.doc.price_list_currency, default_currency), raise_exception = 1)
+ msgprint("Please Enter Appropriate Conversion Rate for Price List Currency to Base Currency (%s --> %s)" % (obj.doc.price_list_currency, default_currency), raise_exception = 1)
diff --git a/selling/doctype/sales_order/sales_order.js b/selling/doctype/sales_order/sales_order.js
index 86a6994eb9d..d50f06d8481 100644
--- a/selling/doctype/sales_order/sales_order.js
+++ b/selling/doctype/sales_order/sales_order.js
@@ -130,6 +130,29 @@ cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
}
+cur_frm.fields_dict.shipping_address_name.get_query = cur_frm.fields_dict['customer_address'].get_query;
+
+cur_frm.cscript.shipping_address_name = function() {
+ if(cur_frm.doc.shipping_address_name) {
+ wn.model.with_doc("Address", cur_frm.doc.shipping_address_name, function(name) {
+ var address = wn.model.get_doc("Address", name);
+
+ var out = $.map(["address_line1", "address_line2", "city"],
+ function(f) { return address[f]; });
+
+ var state_pincode = $.map(["state", "pincode"], function(f) { return address[f]; }).join(" ");
+ if(state_pincode) out.push(state_pincode);
+
+ if(address["country"]) out.push(address["country"]);
+
+ out.concat($.map([["Phone:", address["phone"]], ["Fax:", address["fax"]]],
+ function(val) { return val[1] ? val.join(" ") : null; }));
+
+ cur_frm.set_value("shipping_address", out.join("\n"));
+ });
+ }
+};
+
cur_frm.cscript.pull_quotation_details = function(doc,dt,dn) {
var callback = function(r,rt){
var doc = locals[cur_frm.doctype][cur_frm.docname];
diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py
index 6a52e5a0fa9..c8db1f919f1 100644
--- a/selling/doctype/sales_order/sales_order.py
+++ b/selling/doctype/sales_order/sales_order.py
@@ -217,7 +217,10 @@ class DocType(SellingController):
self.validate_proj_cust()
self.validate_po()
#self.validate_reference_value()
- self.validate_for_items()
+
+ if self.doc.docstatus == 1:
+ self.validate_for_items()
+
sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.check_active_sales_items(self)
sales_com_obj.check_conversion_rate(self)
diff --git a/selling/doctype/sales_order/sales_order.txt b/selling/doctype/sales_order/sales_order.txt
index e6f762e107d..a8989701e73 100644
--- a/selling/doctype/sales_order/sales_order.txt
+++ b/selling/doctype/sales_order/sales_order.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-01-22 15:24:17",
+ "creation": "2013-06-18 12:39:59",
"docstatus": 0,
- "modified": "2013-01-29 17:14:58",
+ "modified": "2013-06-18 17:49:11",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -203,7 +203,7 @@
"label": "Shipping Address Name",
"options": "Address",
"print_hide": 1,
- "read_only": 1
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -951,15 +951,6 @@
"options": "Sales Team",
"print_hide": 1
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"amend": 1,
"cancel": 1,
@@ -981,14 +972,12 @@
"write": 1
},
{
- "amend": 0,
- "cancel": 0,
- "create": 0,
+ "doctype": "DocPerm",
+ "role": "Accounts User"
+ },
+ {
"doctype": "DocPerm",
"match": "customer",
- "report": 0,
- "role": "Customer",
- "submit": 0,
- "write": 0
+ "role": "Customer"
}
]
\ No newline at end of file
diff --git a/selling/doctype/sales_order_item/sales_order_item.txt b/selling/doctype/sales_order_item/sales_order_item.txt
index fff2d080f3b..c65ac0d9385 100644
--- a/selling/doctype/sales_order_item/sales_order_item.txt
+++ b/selling/doctype/sales_order_item/sales_order_item.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-02-22 01:27:52",
+ "creation": "2013-03-07 11:42:58",
"docstatus": 0,
- "modified": "2013-03-07 07:03:30",
+ "modified": "2013-05-22 12:09:03",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -35,6 +35,7 @@
"oldfieldtype": "Link",
"options": "Item",
"print_width": "150px",
+ "read_only": 0,
"reqd": 1,
"search_index": 1,
"width": "150px"
@@ -57,6 +58,7 @@
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "150",
+ "read_only": 0,
"reqd": 1,
"width": "150"
},
@@ -69,6 +71,7 @@
"oldfieldname": "description",
"oldfieldtype": "Small Text",
"print_width": "300px",
+ "read_only": 0,
"reqd": 1,
"search_index": 1,
"width": "300px"
@@ -82,6 +85,7 @@
"oldfieldname": "qty",
"oldfieldtype": "Currency",
"print_width": "100px",
+ "read_only": 0,
"reqd": 1,
"width": "100px"
},
@@ -109,6 +113,7 @@
"options": "currency",
"print_hide": 1,
"print_width": "70px",
+ "read_only": 0,
"reqd": 0,
"width": "70px"
},
@@ -122,6 +127,7 @@
"oldfieldtype": "Float",
"print_hide": 1,
"print_width": "70px",
+ "read_only": 0,
"width": "70px"
},
{
@@ -134,6 +140,7 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_width": "100px",
+ "read_only": 0,
"reqd": 0,
"width": "100px"
},
@@ -176,6 +183,7 @@
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"reqd": 0,
"width": "100px"
},
@@ -206,6 +214,7 @@
"options": "Warehouse",
"print_hide": 1,
"print_width": "150px",
+ "read_only": 0,
"reqd": 0,
"width": "150px"
},
@@ -329,6 +338,7 @@
"hidden": 0,
"in_filter": 1,
"label": "Quotation No.",
+ "no_copy": 1,
"oldfieldname": "prevdoc_docname",
"oldfieldtype": "Link",
"options": "Quotation",
@@ -345,6 +355,7 @@
"oldfieldname": "page_break",
"oldfieldtype": "Check",
"print_hide": 1,
+ "read_only": 0,
"report_hide": 1
},
{
diff --git a/selling/doctype/sms_center/sms_center.py b/selling/doctype/sms_center/sms_center.py
index c5db7383f72..8b404e6a4d0 100644
--- a/selling/doctype/sms_center/sms_center.py
+++ b/selling/doctype/sms_center/sms_center.py
@@ -24,7 +24,7 @@ from webnotes.model.code import get_obj
from webnotes import msgprint
sql = webnotes.conn.sql
-
+
# ----------
class DocType:
@@ -35,27 +35,27 @@ class DocType:
def create_receiver_list(self):
rec, where_clause = '', ''
if self.doc.send_to == 'All Customer Contact':
- where_clause = self.doc.customer and " and customer = '%s'" % self.doc.customer or " and ifnull(is_customer, 0) = 1"
+ where_clause = self.doc.customer and " and customer = '%s'" % self.doc.customer or " and ifnull(customer, '') != ''"
if self.doc.send_to == 'All Supplier Contact':
- where_clause = self.doc.supplier and " and ifnull(is_supplier, 0) = 1 and supplier = '%s'" % self.doc.supplier or " and ifnull(is_supplier, 0) = 1"
+ where_clause = self.doc.supplier and " and ifnull(is_supplier, 0) = 1 and supplier = '%s'" % self.doc.supplier or " and ifnull(supplier, '') != ''"
if self.doc.send_to == 'All Sales Partner Contact':
- where_clause = self.doc.sales_partner and " and ifnull(is_sales_partner, 0) = 1 and sales_aprtner = '%s'" % self.doc.sales_partner or " and ifnull(is_sales_partner, 0) = 1"
+ where_clause = self.doc.sales_partner and " and ifnull(is_sales_partner, 0) = 1 and sales_partner = '%s'" % self.doc.sales_partner or " and ifnull(sales_partner, '') != ''"
+
if self.doc.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']:
rec = sql("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause)
elif self.doc.send_to == 'All Lead (Open)':
rec = sql("select lead_name, mobile_no from tabLead where ifnull(mobile_no,'')!='' and docstatus != 2 and status = 'Open'")
elif self.doc.send_to == 'All Employee (Active)':
- where_clause = self.doc.department and " and t1.department = '%s'" % self.doc.department or ""
- where_clause += self.doc.branch and " and t1.branch = '%s'" % self.doc.branch or ""
- rec = sql("select t1.employee_name, t2.cell_number from `tabEmployee` t1, `tabEmployee Profile` t2 where t2.employee = t1.name and t1.status = 'Active' and t1.docstatus != 2 and ifnull(t2.cell_number,'')!='' %s" % where_clause)
+ where_clause = self.doc.department and " and department = '%s'" % self.doc.department or ""
+ where_clause += self.doc.branch and " and branch = '%s'" % self.doc.branch or ""
+ rec = sql("select employee_name, cell_number from `tabEmployee` where status = 'Active' and docstatus < 2 and ifnull(cell_number,'')!='' %s" % where_clause)
elif self.doc.send_to == 'All Sales Person':
rec = sql("select sales_person_name, mobile_no from `tabSales Person` where docstatus != 2 and ifnull(mobile_no,'')!=''")
-
rec_list = ''
for d in rec:
rec_list += d[0] + ' - ' + d[1] + '\n'
self.doc.receiver_list = rec_list
-
+ webnotes.errprint(rec_list)
def get_receiver_nos(self):
receiver_nos = []
for d in self.doc.receiver_list.split('\n'):
diff --git a/selling/locale/_messages_js.json b/selling/locale/_messages_js.json
new file mode 100644
index 00000000000..0637a088a01
--- /dev/null
+++ b/selling/locale/_messages_js.json
@@ -0,0 +1 @@
+[]
\ No newline at end of file
diff --git a/selling/locale/_messages_py.json b/selling/locale/_messages_py.json
new file mode 100644
index 00000000000..f5b4a010f5f
--- /dev/null
+++ b/selling/locale/_messages_py.json
@@ -0,0 +1,7 @@
+[
+ "is not a Stock Item",
+ "Item",
+ "Please check",
+ "reached its end of life on",
+ "is a cancelled Item"
+]
\ No newline at end of file
diff --git a/selling/locale/ar-py.json b/selling/locale/ar-py.json
new file mode 100644
index 00000000000..b8dd151cf97
--- /dev/null
+++ b/selling/locale/ar-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "\u0628\u0646\u062f",
+ "Please check": "\u064a\u0631\u062c\u0649 \u0645\u0631\u0627\u062c\u0639\u0629",
+ "is a cancelled Item": "\u0647\u0648 \u0628\u0646\u062f \u0625\u0644\u063a\u0627\u0621",
+ "is not a Stock Item": "\u0644\u064a\u0633 \u0627\u0644\u0625\u063a\u0644\u0627\u0642 \u0644\u0644\u0633\u0647\u0645",
+ "reached its end of life on": "\u0648\u0635\u0644 \u0625\u0644\u0649 \u0646\u0647\u0627\u064a\u062a\u0647 \u0645\u0646 \u0627\u0644\u062d\u064a\u0627\u0629 \u0639\u0644\u0649"
+}
\ No newline at end of file
diff --git a/selling/locale/de-py.json b/selling/locale/de-py.json
new file mode 100644
index 00000000000..68b58d7a4b2
--- /dev/null
+++ b/selling/locale/de-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "Artikel",
+ "Please check": "Bitte \u00fcberpr\u00fcfen Sie",
+ "is a cancelled Item": "ist ein gestempeltes",
+ "is not a Stock Item": "ist kein Lagerartikel",
+ "reached its end of life on": "erreichte Ende des Lebens auf"
+}
\ No newline at end of file
diff --git a/selling/locale/es-py.json b/selling/locale/es-py.json
new file mode 100644
index 00000000000..7d145d1e4ce
--- /dev/null
+++ b/selling/locale/es-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "Art\u00edculo",
+ "Please check": "Por favor, compruebe",
+ "is a cancelled Item": "Es un Tema cancelado",
+ "is not a Stock Item": "no es un elemento de serie",
+ "reached its end of life on": "llegado al final de su vida en la"
+}
\ No newline at end of file
diff --git a/selling/locale/fr-py.json b/selling/locale/fr-py.json
new file mode 100644
index 00000000000..c466df4c7f9
--- /dev/null
+++ b/selling/locale/fr-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "Article",
+ "Please check": "S'il vous pla\u00eet v\u00e9rifier",
+ "is a cancelled Item": "est un \u00e9l\u00e9ment annul\u00e9e",
+ "is not a Stock Item": "n'est pas un \u00e9l\u00e9ment de Stock",
+ "reached its end of life on": "atteint la fin de sa vie sur"
+}
\ No newline at end of file
diff --git a/selling/locale/hi-py.json b/selling/locale/hi-py.json
new file mode 100644
index 00000000000..58d4e654111
--- /dev/null
+++ b/selling/locale/hi-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "\u092e\u0926",
+ "Please check": "\u0915\u0943\u092a\u092f\u093e \u091c\u093e\u0901\u091a \u0915\u0930\u0947\u0902",
+ "is a cancelled Item": "\u0930\u0926\u094d\u0926 \u0906\u0907\u091f\u092e",
+ "is not a Stock Item": "\u0938\u094d\u091f\u0949\u0915 \u0906\u0907\u091f\u092e \u0928\u0939\u0940\u0902 \u0939\u0948",
+ "reached its end of life on": "\u092a\u0930 \u0905\u092a\u0928\u0947 \u091c\u0940\u0935\u0928 \u0915\u0947 \u0905\u0902\u0924 \u0924\u0915 \u092a\u0939\u0941\u0901\u091a"
+}
\ No newline at end of file
diff --git a/selling/locale/hr-py.json b/selling/locale/hr-py.json
new file mode 100644
index 00000000000..24f60bb1c48
--- /dev/null
+++ b/selling/locale/hr-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "Stavka",
+ "Please check": "Molimo provjerite",
+ "is a cancelled Item": "je otkazan artikla",
+ "is not a Stock Item": "nije katalo\u0161ki artikla",
+ "reached its end of life on": "dosegla svoj kraj \u017eivota na"
+}
\ No newline at end of file
diff --git a/selling/locale/nl-py.json b/selling/locale/nl-py.json
new file mode 100644
index 00000000000..7964d37f6e2
--- /dev/null
+++ b/selling/locale/nl-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "Item",
+ "Please check": "Controleer",
+ "is a cancelled Item": "is een geannuleerde artikel",
+ "is not a Stock Item": "is niet een Stock Item",
+ "reached its end of life on": "het einde van zijn leven op"
+}
\ No newline at end of file
diff --git a/selling/locale/pt-BR-py.json b/selling/locale/pt-BR-py.json
new file mode 100644
index 00000000000..0bf350cad03
--- /dev/null
+++ b/selling/locale/pt-BR-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "Item",
+ "Please check": "Por favor, verifique",
+ "is a cancelled Item": "\u00e9 um Item cancelado",
+ "is not a Stock Item": "n\u00e3o \u00e9 um Item de Estoque",
+ "reached its end of life on": "chegou ao fim de vida em"
+}
\ No newline at end of file
diff --git a/selling/locale/pt-py.json b/selling/locale/pt-py.json
new file mode 100644
index 00000000000..cfcbcec8dfa
--- /dev/null
+++ b/selling/locale/pt-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "Item",
+ "Please check": "Por favor, verifique",
+ "is a cancelled Item": "\u00e9 um item cancelado",
+ "is not a Stock Item": "n\u00e3o \u00e9 um item de estoque",
+ "reached its end of life on": "chegou ao fim da vida na"
+}
\ No newline at end of file
diff --git a/selling/locale/sr-py.json b/selling/locale/sr-py.json
new file mode 100644
index 00000000000..ed1672fc6c3
--- /dev/null
+++ b/selling/locale/sr-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "\u0421\u0442\u0430\u0432\u043a\u0430",
+ "Please check": "\u041c\u043e\u043b\u0438\u043c\u043e \u0432\u0430\u0441 \u0434\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u0435",
+ "is a cancelled Item": "\u0458\u0435 \u043e\u0442\u043a\u0430\u0437\u0430\u043d\u0430 \u0448\u0438\u0444\u0440\u0430",
+ "is not a Stock Item": "\u043d\u0438\u0458\u0435 \u0431\u0435\u0440\u0437\u0430 \u0448\u0438\u0444\u0440\u0430",
+ "reached its end of life on": "\u0434\u043e\u0441\u0442\u0438\u0433\u0430\u043e \u0441\u0432\u043e\u0458 \u043a\u0440\u0430\u0458 \u0436\u0438\u0432\u043e\u0442\u0430 \u043d\u0430"
+}
\ No newline at end of file
diff --git a/selling/locale/ta-py.json b/selling/locale/ta-py.json
new file mode 100644
index 00000000000..355cc0e7ced
--- /dev/null
+++ b/selling/locale/ta-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "\u0b89\u0bb0\u0bc1\u0baa\u0bcd\u0baa\u0b9f\u0bbf",
+ "Please check": "\u0b9a\u0bb0\u0bbf\u0baa\u0bbe\u0bb0\u0bcd\u0b95\u0bcd\u0b95\u0bb5\u0bc1\u0bae\u0bcd",
+ "is a cancelled Item": "\u0b92\u0bb0\u0bc1 \u0bb0\u0ba4\u0bcd\u0ba4\u0bc1 \u0b89\u0bb0\u0bc1\u0baa\u0bcd\u0baa\u0b9f\u0bbf \u0b89\u0bb3\u0bcd\u0bb3\u0ba4\u0bc1",
+ "is not a Stock Item": "\u0b92\u0bb0\u0bc1 \u0baa\u0b99\u0bcd\u0b95\u0bc1 \u0baa\u0bc6\u0bbe\u0bb0\u0bc1\u0bb3\u0bcd \u0b85\u0bb2\u0bcd\u0bb2",
+ "reached its end of life on": "\u0bb5\u0bbe\u0bb4\u0bcd\u0b95\u0bcd\u0b95\u0bc8 \u0b85\u0ba4\u0ba9\u0bcd \u0b87\u0bb1\u0bc1\u0ba4\u0bbf\u0baf\u0bbf\u0bb2\u0bcd \u0b85\u0b9f\u0bc8\u0ba8\u0bcd\u0ba4\u0ba4\u0bc1"
+}
\ No newline at end of file
diff --git a/selling/locale/th-py.json b/selling/locale/th-py.json
new file mode 100644
index 00000000000..5f31a593737
--- /dev/null
+++ b/selling/locale/th-py.json
@@ -0,0 +1,7 @@
+{
+ "Item": "\u0e0a\u0e34\u0e49\u0e19",
+ "Please check": "\u0e01\u0e23\u0e38\u0e13\u0e32\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a",
+ "is a cancelled Item": "\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23\u0e22\u0e01\u0e40\u0e25\u0e34\u0e01\u0e40\u0e1b\u0e47\u0e19",
+ "is not a Stock Item": "\u0e44\u0e21\u0e48\u0e44\u0e14\u0e49\u0e40\u0e1b\u0e47\u0e19\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23\u0e2a\u0e15\u0e47\u0e2d\u0e01",
+ "reached its end of life on": "\u0e16\u0e36\u0e07\u0e08\u0e38\u0e14\u0e2a\u0e34\u0e49\u0e19\u0e2a\u0e38\u0e14\u0e02\u0e2d\u0e07\u0e0a\u0e35\u0e27\u0e34\u0e15\u0e40\u0e21\u0e37\u0e48\u0e2d"
+}
\ No newline at end of file
diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js
index 994bb4a5550..e912fd8b611 100644
--- a/selling/page/selling_home/selling_home.js
+++ b/selling/page/selling_home/selling_home.js
@@ -137,11 +137,6 @@ wn.module_page["Selling"] = [
"label":wn._("Sales Analytics"),
page: "sales-analytics"
},
- {
- "label":wn._("Trend Analyzer"),
- route: "Report/Profile/Trend Analyzer",
- doctype: "Sales Order"
- },
]
},
{
@@ -154,8 +149,47 @@ wn.module_page["Selling"] = [
route: "query-report/Customer Addresses And Contacts"
},
{
- "label":wn._("Sales Orders Pending to be Delivered"),
- route: "query-report/Sales Orders Pending To Be Delivered"
+ "label":wn._("Ordered Items To Be Delivered"),
+ route: "query-report/Ordered Items To Be Delivered",
+ },
+ {
+ "label":wn._("Sales Person-wise Transaction Summary"),
+ route: "query-report/Sales Person-wise Transaction Summary"
+ },
+ {
+ "label":wn._("Item-wise Sales History"),
+ route: "query-report/Item-wise Sales History"
+ },
+ {
+ "label":wn._("Territory Target Variance (Item Group-Wise)"),
+ route: "query-report/Territory Target Variance Item Group-Wise"
+ },
+ {
+ "label":wn._("Sales Person Target Variance (Item Group-Wise)"),
+ route: "query-report/Sales Person Target Variance Item Group-Wise"
+ },
+ {
+ "label":wn._("Customers Not Buying Since Long Time"),
+ route: "query-report/Customers Not Buying Since Long Time",
+ doctype: "Sales Order"
+ },
+ {
+ "label":wn._("Quotation Trend"),
+ route: "query-report/Quotation Trends",
+ doctype: "Quotation"
+ },
+ {
+ "label":wn._("Sales Order Trend"),
+ route: "query-report/Sales Order Trends",
+ doctype: "Sales Order"
+ },
+ {
+ "label":wn._("Available Stock for Packing Items"),
+ route: "query-report/Available Stock for Packing Items",
+ },
+ {
+ "label":wn._("Pending SO Items For Purchase Request"),
+ route: "query-report/Pending SO Items For Purchase Request"
},
]
}
diff --git a/selling/report/available_stock_for_packing_items/__init__.py b/selling/report/available_stock_for_packing_items/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.py b/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.py
new file mode 100644
index 00000000000..171c3bb8d9a
--- /dev/null
+++ b/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.py
@@ -0,0 +1,92 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import flt
+
+def execute(filters=None):
+ if not filters: filters = {}
+
+ columns = get_columns()
+ iwq_map = get_item_warehouse_quantity_map()
+ item_map = get_item_details()
+
+ data = []
+ for sbom, warehouse in iwq_map.items():
+ total = 0
+ total_qty = 0
+
+ for wh, item_qty in warehouse.items():
+ total += 1
+ row = [sbom, item_map.get(sbom).item_name, item_map.get(sbom).description,
+ item_map.get(sbom).stock_uom, wh]
+ available_qty = min(item_qty.values())
+ total_qty += flt(available_qty)
+ row += [available_qty]
+
+ if available_qty:
+ data.append(row)
+ if (total == len(warehouse)):
+ row = ["", "", "Total", "", "", total_qty]
+ data.append(row)
+
+ return columns, data
+
+def get_columns():
+ columns = ["Item Code:Link/Item:100", "Item Name::100", "Description::120", \
+ "UOM:Link/UOM:80", "Warehouse:Link/Warehouse:100", "Quantity::100"]
+
+ return columns
+
+def get_sales_bom_items():
+ sbom_item_map = {}
+ for sbom in webnotes.conn.sql("""select parent, item_code, qty from `tabSales BOM Item`
+ where docstatus < 2""", as_dict=1):
+ sbom_item_map.setdefault(sbom.parent, {}).setdefault(sbom.item_code, sbom.qty)
+
+ return sbom_item_map
+
+def get_item_details():
+ item_map = {}
+ for item in webnotes.conn.sql("""select name, item_name, description, stock_uom
+ from `tabItem`""", as_dict=1):
+ item_map.setdefault(item.name, item)
+
+ return item_map
+
+def get_item_warehouse_quantity():
+ iwq_map = {}
+ bin = webnotes.conn.sql("""select item_code, warehouse, actual_qty from `tabBin`
+ where actual_qty > 0""")
+ for item, wh, qty in bin:
+ iwq_map.setdefault(item, {}).setdefault(wh, qty)
+
+ return iwq_map
+
+def get_item_warehouse_quantity_map():
+ sbom_map = {}
+ iwq_map = get_item_warehouse_quantity()
+ sbom_item_map = get_sales_bom_items()
+
+ for sbom, sbom_items in sbom_item_map.items():
+ for item, child_qty in sbom_items.items():
+ for wh, qty in iwq_map.get(item, {}).items():
+ avail_qty = flt(qty) / flt(child_qty)
+ sbom_map.setdefault(sbom, {}).setdefault(wh, {}) \
+ .setdefault(item, avail_qty)
+
+ return sbom_map
\ No newline at end of file
diff --git a/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt b/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt
new file mode 100644
index 00000000000..5cf413393f4
--- /dev/null
+++ b/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-21 13:40:05",
+ "docstatus": 0,
+ "modified": "2013-06-21 15:06:40",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Sales BOM",
+ "report_name": "Available Stock for Packing Items",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Available Stock for Packing Items"
+ }
+]
\ No newline at end of file
diff --git a/selling/report/customers_not_buying_since_long_time/__init__.py b/selling/report/customers_not_buying_since_long_time/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.js b/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.js
new file mode 100644
index 00000000000..65d63484a5e
--- /dev/null
+++ b/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.js
@@ -0,0 +1,10 @@
+wn.query_reports["Customers Not Buying Since Long Time"] = {
+ "filters": [
+ {
+ "fieldname":"days_since_last_order",
+ "label": "Days Since Last Order",
+ "fieldtype": "Int",
+ "default": 60
+ }
+ ]
+}
\ No newline at end of file
diff --git a/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.py b/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.py
new file mode 100644
index 00000000000..08809a7619a
--- /dev/null
+++ b/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.py
@@ -0,0 +1,75 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import getdate, cint
+
+def execute(filters=None):
+ if not filters: filters ={}
+
+ days_since_last_order = filters.get("days_since_last_order")
+ if cint(days_since_last_order) <= 0:
+ webnotes.msgprint("Please mention positive value in 'Days Since Last Order' field",raise_exception=1)
+
+ columns = get_columns()
+ customers = get_so_details()
+
+ data = []
+ for cust in customers:
+ if cust[8] >= days_since_last_order:
+ cust.insert(7,get_last_so_amt(cust[0]))
+ data.append(cust)
+ return columns, data
+
+def get_so_details():
+ return webnotes.conn.sql("""select
+ cust.name,
+ cust.customer_name,
+ cust.territory,
+ cust.customer_group,
+ count(distinct(so.name)) as 'num_of_order',
+ sum(net_total) as 'total_order_value',
+ sum(if(so.status = "Stopped",
+ so.net_total * so.per_delivered/100,
+ so.net_total)) as 'total_order_considered',
+ max(so.transaction_date) as 'last_sales_order_date',
+ DATEDIFF(CURDATE(), max(so.transaction_date)) as 'days_since_last_order'
+ from `tabCustomer` cust, `tabSales Order` so
+ where cust.name = so.customer and so.docstatus = 1
+ group by cust.name
+ order by 'days_since_last_order' desc """,as_list=1)
+
+def get_last_so_amt(customer):
+ res = webnotes.conn.sql("""select net_total from `tabSales Order`
+ where customer ='%(customer)s' and docstatus = 1 order by transaction_date desc
+ limit 1""" % {'customer':customer})
+
+ return res and res[0][0] or 0
+
+def get_columns():
+ return [
+ "Customer:Link/Customer:120",
+ "Customer Name:Data:120",
+ "Territory::120",
+ "Customer Group::120",
+ "Number of Order::120",
+ "Total Order Value:Currency:120",
+ "Total Order Considered:Currency:160",
+ "Last Order Amount:Currency:160",
+ "Last Sales Order Date:Date:160",
+ "Days Since Last Order::160"
+ ]
\ No newline at end of file
diff --git a/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.txt b/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.txt
new file mode 100644
index 00000000000..4d94377aa97
--- /dev/null
+++ b/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-07 12:27:07",
+ "docstatus": 0,
+ "modified": "2013-06-07 12:27:07",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Sales Order",
+ "report_name": "Customers Not Buying Since Long Time ",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Customers Not Buying Since Long Time"
+ }
+]
\ No newline at end of file
diff --git a/selling/report/item_wise_sales_history/__init__.py b/selling/report/item_wise_sales_history/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/selling/report/item_wise_sales_history/item_wise_sales_history.txt b/selling/report/item_wise_sales_history/item_wise_sales_history.txt
new file mode 100644
index 00000000000..adbfe692547
--- /dev/null
+++ b/selling/report/item_wise_sales_history/item_wise_sales_history.txt
@@ -0,0 +1,24 @@
+[
+ {
+ "creation": "2013-05-23 17:42:24",
+ "docstatus": 0,
+ "modified": "2013-05-24 12:20:17",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "add_total_row": 1,
+ "disabled": 0,
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Float:100\",\n\tso_item.stock_uom as \"UOM:Link/UOM:80\",\n\tso_item.basic_rate as \"Rate:Currency:120\",\n\tso_item.amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n so.project_name as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Float:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc",
+ "ref_doctype": "Sales Order",
+ "report_name": "Item-wise Sales History",
+ "report_type": "Query Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Item-wise Sales History"
+ }
+]
\ No newline at end of file
diff --git a/selling/report/pending_so_items_for_purchase_request/__init__.py b/selling/report/pending_so_items_for_purchase_request/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.txt b/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.txt
new file mode 100644
index 00000000000..e0c450a254e
--- /dev/null
+++ b/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-06-21 16:46:45",
+ "docstatus": 0,
+ "modified": "2013-06-21 16:55:54",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "query": "select \n so_item.item_code as \"Item Code:Link/Item:120\",\n so_item.item_name as \"Item Name::120\",\n so_item.description as \"Description::120\",\n so.`name` as \"S.O. No.:Link/Sales Order:120\",\n so.`transaction_date` as \"Date:Date:120\",\n mr.name as \"Material Request:Link/Material Request:120\",\n so.customer as \"Customer:Link/Customer:120\",\n so.territory as \"Terretory:Link/Territory:120\",\n sum(so_item.qty) as \"SO Qty:Float:100 \",\n sum(mr_item.qty) as \"Requested Qty:Float:100\"\nfrom\n `tabSales Order` so, `tabSales Order Item` so_item, \n `tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n so_item.`parent` = so.`name` and mr_item.sales_order_no = so.name\n and mr_item.parent = mr.name \n and so.docstatus = 1 and so.status != \"Stopped\" \n and mr.docstatus = 1 and mr.status != \"Stopped\"\ngroup by so.name, so_item.item_code\norder by so.name desc, so_item.item_code asc",
+ "ref_doctype": "Sales Order",
+ "report_name": "Pending SO Items For Purchase Request",
+ "report_type": "Query Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Pending SO Items For Purchase Request"
+ }
+]
\ No newline at end of file
diff --git a/selling/report/quotation_trends/__init__.py b/selling/report/quotation_trends/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/selling/report/quotation_trends/quotation_trends.js b/selling/report/quotation_trends/quotation_trends.js
new file mode 100644
index 00000000000..2f9f23666c2
--- /dev/null
+++ b/selling/report/quotation_trends/quotation_trends.js
@@ -0,0 +1,5 @@
+wn.require("app/js/sales_trends_filters.js");
+
+wn.query_reports["Quotation Trends"] = {
+ filters: get_filters()
+ }
\ No newline at end of file
diff --git a/buying/search_criteria/pending_po_items_to_receive/pending_po_items_to_receive.py b/selling/report/quotation_trends/quotation_trends.py
similarity index 74%
rename from buying/search_criteria/pending_po_items_to_receive/pending_po_items_to_receive.py
rename to selling/report/quotation_trends/quotation_trends.py
index e7ada4ff977..29f9ef82c2f 100644
--- a/buying/search_criteria/pending_po_items_to_receive/pending_po_items_to_receive.py
+++ b/selling/report/quotation_trends/quotation_trends.py
@@ -15,5 +15,13 @@
# along with this program. If not, see .
from __future__ import unicode_literals
-colwidths[col_idx['Pending Quantity To Receive']] = '200px'
-colwidths[col_idx['Pending Amount To Receive']] = '200px'
+import webnotes
+from controllers.trends import get_columns, get_data
+
+def execute(filters=None):
+ if not filters: filters ={}
+ data = []
+ conditions = get_columns(filters, "Quotation")
+ data = get_data(filters, conditions)
+
+ return conditions["columns"], data
\ No newline at end of file
diff --git a/selling/report/quotation_trends/quotation_trends.txt b/selling/report/quotation_trends/quotation_trends.txt
new file mode 100644
index 00000000000..eebffcf84b7
--- /dev/null
+++ b/selling/report/quotation_trends/quotation_trends.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-06-07 16:01:16",
+ "docstatus": 0,
+ "modified": "2013-06-12 16:31:23",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "add_total_row": 0,
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Quotation",
+ "report_name": "Quotation Trends",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Quotation Trends"
+ }
+]
\ No newline at end of file
diff --git a/selling/report/sales_order_trends/__init__.py b/selling/report/sales_order_trends/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/selling/report/sales_order_trends/sales_order_trends.js b/selling/report/sales_order_trends/sales_order_trends.js
new file mode 100644
index 00000000000..458fee6ed3b
--- /dev/null
+++ b/selling/report/sales_order_trends/sales_order_trends.js
@@ -0,0 +1,5 @@
+wn.require("app/js/sales_trends_filters.js");
+
+wn.query_reports["Sales Order Trends"] = {
+ filters: get_filters()
+ }
\ No newline at end of file
diff --git a/selling/report/sales_order_trends/sales_order_trends.py b/selling/report/sales_order_trends/sales_order_trends.py
new file mode 100644
index 00000000000..ac7c3ab97b2
--- /dev/null
+++ b/selling/report/sales_order_trends/sales_order_trends.py
@@ -0,0 +1,27 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from controllers.trends import get_columns,get_data
+
+def execute(filters=None):
+ if not filters: filters ={}
+ data = []
+ conditions = get_columns(filters, "Sales Order")
+ data = get_data(filters, conditions)
+
+ return conditions["columns"], data
\ No newline at end of file
diff --git a/selling/report/sales_order_trends/sales_order_trends.txt b/selling/report/sales_order_trends/sales_order_trends.txt
new file mode 100644
index 00000000000..16ee9ca46b3
--- /dev/null
+++ b/selling/report/sales_order_trends/sales_order_trends.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-13 18:43:30",
+ "docstatus": 0,
+ "modified": "2013-06-13 18:43:30",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Sales Order",
+ "report_name": "Sales Order Trends",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Sales Order Trends"
+ }
+]
\ No newline at end of file
diff --git a/selling/report/sales_orders_pending_to_be_delivered/sales_orders_pending_to_be_delivered.txt b/selling/report/sales_orders_pending_to_be_delivered/sales_orders_pending_to_be_delivered.txt
deleted file mode 100644
index c145f4ea393..00000000000
--- a/selling/report/sales_orders_pending_to_be_delivered/sales_orders_pending_to_be_delivered.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-[
- {
- "creation": "2013-02-21 14:26:46",
- "docstatus": 0,
- "modified": "2013-02-22 15:53:24",
- "modified_by": "Administrator",
- "owner": "Administrator"
- },
- {
- "doctype": "Report",
- "is_standard": "Yes",
- "name": "__common__",
- "query": "select \n `tabSales Order`.`name` as \"S.O. No.:Link/Sales Order:120\",\n `tabSales Order`.`transaction_date` as \"S.O. Date:Date\",\n `tabSales Order`.`delivery_date` as \"Expected Delivery Date:Date\",\n `tabSales Order`.`customer` as \"Customer:Link/Customer:120\",\n `tabSales Order Item`.item_code as \"Item Code:Link/Item:120\",\n `tabSales Order Item`.description as \"Description\",\n `tabSales Order Item`.qty as \"Qty:Float\",\n `tabSales Order Item`.delivered_qty as \"Delivered Qty:Float\",\n `tabSales Order`.`po_no` as \"P.O. No.\"\nfrom\n `tabSales Order`, `tabSales Order Item`\nwhere\n `tabSales Order Item`.`parent` = `tabSales Order`.`name`\n and `tabSales Order`.docstatus = 1\n and `tabSales Order`.status != \"Stopped\"\n and ifnull(`tabSales Order Item`.delivered_qty,0) < ifnull(`tabSales Order Item`.qty,0)\norder by `tabSales Order`.transaction_date asc",
- "ref_doctype": "Sales Order",
- "report_name": "Sales Orders Pending To Be Delivered",
- "report_type": "Query Report"
- },
- {
- "doctype": "Report",
- "name": "Sales Orders Pending To Be Delivered"
- }
-]
\ No newline at end of file
diff --git a/selling/report/sales_person_target_variance_item_group_wise/__init__.py b/selling/report/sales_person_target_variance_item_group_wise/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js
new file mode 100644
index 00000000000..c7a5d668c48
--- /dev/null
+++ b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js
@@ -0,0 +1,25 @@
+wn.query_reports["Sales Person Target Variance Item Group-Wise"] = {
+ "filters": [
+ {
+ fieldname: "fiscal_year",
+ label: "Fiscal Year",
+ fieldtype: "Link",
+ options: "Fiscal Year",
+ default: sys_defaults.fiscal_year
+ },
+ {
+ fieldname: "period",
+ label: "Period",
+ fieldtype: "Select",
+ options: "Monthly\nQuarterly\nHalf-Yearly\nYearly",
+ default: "Monthly"
+ },
+ {
+ fieldname: "target_on",
+ label: "Target On",
+ fieldtype: "Select",
+ options: "Quantity\nAmount",
+ default: "Quantity"
+ },
+ ]
+}
\ No newline at end of file
diff --git a/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
new file mode 100644
index 00000000000..ae3819c2cb1
--- /dev/null
+++ b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
@@ -0,0 +1,143 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes import _, msgprint
+from webnotes.utils import flt
+import time
+from accounts.utils import get_fiscal_year
+from controllers.trends import get_period_date_ranges, get_period_month_ranges
+
+def execute(filters=None):
+ if not filters: filters = {}
+
+ columns = get_columns(filters)
+ period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
+ sim_map = get_salesperson_item_month_map(filters)
+
+ precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2
+
+ data = []
+
+ for salesperson, salesperson_items in sim_map.items():
+ for item_group, monthwise_data in salesperson_items.items():
+ row = [salesperson, item_group]
+ totals = [0, 0, 0]
+ for relevant_months in period_month_ranges:
+ period_data = [0, 0, 0]
+ for month in relevant_months:
+ month_data = monthwise_data.get(month, {})
+ for i, fieldname in enumerate(["target", "achieved", "variance"]):
+ value = flt(month_data.get(fieldname), precision)
+ period_data[i] += value
+ totals[i] += value
+ period_data[2] = period_data[0] - period_data[1]
+ row += period_data
+ totals[2] = totals[0] - totals[1]
+ row += totals
+ data.append(row)
+
+ return columns, sorted(data, key=lambda x: (x[0], x[1]))
+
+def get_columns(filters):
+ for fieldname in ["fiscal_year", "period", "target_on"]:
+ if not filters.get(fieldname):
+ label = (" ".join(fieldname.split("_"))).title()
+ msgprint(_("Please specify") + ": " + label,
+ raise_exception=True)
+
+ columns = ["Sales Person:Link/Sales Person:80", "Item Group:Link/Item Group:80"]
+
+ group_months = False if filters["period"] == "Monthly" else True
+
+ for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]):
+ for label in ["Target (%s)", "Achieved (%s)", "Variance (%s)"]:
+ if group_months:
+ columns.append(label % (from_date.strftime("%b") + " - " + to_date.strftime("%b")))
+ else:
+ columns.append(label % from_date.strftime("%b"))
+
+ return columns + ["Total Target::80", "Total Achieved::80", "Total Variance::80"]
+
+#Get sales person & item group details
+def get_salesperson_details(filters):
+ return webnotes.conn.sql("""select sp.name, td.item_group, td.target_qty,
+ td.target_amount, sp.distribution_id
+ from `tabSales Person` sp, `tabTarget Detail` td
+ where td.parent=sp.name and td.fiscal_year=%s and
+ ifnull(sp.distribution_id, '')!='' order by sp.name""",
+ (filters["fiscal_year"]), as_dict=1)
+
+#Get target distribution details of item group
+def get_target_distribution_details(filters):
+ target_details = {}
+
+ for d in webnotes.conn.sql("""select bdd.month, bdd.percentage_allocation \
+ from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd, \
+ `tabTerritory` t where bdd.parent=bd.name and t.distribution_id=bd.name and \
+ bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
+ target_details.setdefault(d.month, d)
+
+ return target_details
+
+#Get achieved details from sales order
+def get_achieved_details(filters):
+ start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
+
+ return webnotes.conn.sql("""select soi.item_code, soi.qty, soi.amount, so.transaction_date,
+ st.sales_person, MONTHNAME(so.transaction_date) as month_name
+ from `tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st
+ where soi.parent=so.name and so.docstatus=1 and
+ st.parent=so.name and so.transaction_date>=%s and
+ so.transaction_date<=%s""" % ('%s', '%s'),
+ (start_date, end_date), as_dict=1)
+
+def get_salesperson_item_month_map(filters):
+ salesperson_details = get_salesperson_details(filters)
+ tdd = get_target_distribution_details(filters)
+ achieved_details = get_achieved_details(filters)
+
+ sim_map = {}
+
+ for sd in salesperson_details:
+ for month in tdd:
+ sim_map.setdefault(sd.name, {}).setdefault(sd.item_group, {})\
+ .setdefault(month, webnotes._dict({
+ "target": 0.0, "achieved": 0.0
+ }))
+
+ tav_dict = sim_map[sd.name][sd.item_group][month]
+
+ for ad in achieved_details:
+ if (filters["target_on"] == "Quantity"):
+ tav_dict.target = flt(sd.target_qty) * \
+ (tdd[month]["percentage_allocation"]/100)
+ if ad.month_name == month and get_item_group(ad.item_code) == sd.item_group \
+ and ad.sales_person == sd.name:
+ tav_dict.achieved += ad.qty
+
+ if (filters["target_on"] == "Amount"):
+ tav_dict.target = flt(sd.target_amount) * \
+ (tdd[month]["percentage_allocation"]/100)
+ if ad.month_name == month and get_item_group(ad.item_code) == sd.item_group \
+ and ad.sales_person == sd.name:
+ tav_dict.achieved += ad.amount
+
+ return sim_map
+
+def get_item_group(item_name):
+ return webnotes.conn.get_value("Item", item_name, "item_group")
\ No newline at end of file
diff --git a/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt
new file mode 100644
index 00000000000..e587c2c0840
--- /dev/null
+++ b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-21 12:14:15",
+ "docstatus": 0,
+ "modified": "2013-06-21 12:14:15",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Sales Order",
+ "report_name": "Sales Person Target Variance Item Group-Wise",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Sales Person Target Variance Item Group-Wise"
+ }
+]
\ No newline at end of file
diff --git a/selling/report/sales_person_wise_transaction_summary/__init__.py b/selling/report/sales_person_wise_transaction_summary/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js
new file mode 100644
index 00000000000..2e1996e9a26
--- /dev/null
+++ b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js
@@ -0,0 +1,60 @@
+wn.query_reports["Sales Person-wise Transaction Summary"] = {
+ "filters": [
+ {
+ fieldname: "sales_person",
+ label: "Sales Person",
+ fieldtype: "Link",
+ options: "Sales Person"
+ },
+ {
+ fieldname: "doc_type",
+ label: "Document Type",
+ fieldtype: "Select",
+ options: "Sales Order\nDelivery Note\nSales Invoice",
+ default: "Sales Order"
+ },
+ {
+ fieldname: "from_date",
+ label: "From Date",
+ fieldtype: "Date",
+ default: wn.defaults.get_user_default("year_start_date"),
+ },
+ {
+ fieldname:"to_date",
+ label: "To Date",
+ fieldtype: "Date",
+ default: get_today()
+ },
+ {
+ fieldname:"company",
+ label: "Company",
+ fieldtype: "Link",
+ options: "Company",
+ default: sys_defaults.company
+ },
+ {
+ fieldname:"item_group",
+ label: "Item Group",
+ fieldtype: "Link",
+ options: "Item Group",
+ },
+ {
+ fieldname:"brand",
+ label: "Brand",
+ fieldtype: "Link",
+ options: "Brand",
+ },
+ {
+ fieldname:"customer",
+ label: "Customer",
+ fieldtype: "Link",
+ options: "Customer",
+ },
+ {
+ fieldname:"territory",
+ label: "Territory",
+ fieldtype: "Link",
+ options: "Territory",
+ },
+ ]
+}
\ No newline at end of file
diff --git a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py
new file mode 100644
index 00000000000..8ec3a1826ee
--- /dev/null
+++ b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py
@@ -0,0 +1,82 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes import msgprint, _
+
+def execute(filters=None):
+ if not filters: filters = {}
+
+ columns = get_columns(filters)
+ data = get_entries(filters)
+
+ return columns, data
+
+def get_columns(filters):
+ if not filters.get("doc_type"):
+ msgprint(_("Please select the document type first"), raise_exception=1)
+
+ return [filters["doc_type"] + ":Link/" + filters["doc_type"] + ":140",
+ "Customer:Link/Customer:140", "Territory:Link/Territory:100", "Posting Date:Date:100",
+ "Item Code:Link/Item:120", "Qty:Float:100", "Amount:Currency:120",
+ "Sales Person:Link/Sales Person:140", "Contribution %:Float:110",
+ "Contribution Amount:Currency:140"]
+
+def get_entries(filters):
+ date_field = filters["doc_type"] == "Sales Order" and "transaction_date" or "posting_date"
+ conditions, items = get_conditions(filters, date_field)
+ entries = webnotes.conn.sql("""select dt.name, dt.customer, dt.territory, dt.%s,
+ dt_item.item_code, dt_item.qty, dt_item.amount, st.sales_person,
+ st.allocated_percentage, dt_item.amount*st.allocated_percentage/100
+ from `tab%s` dt, `tab%s Item` dt_item, `tabSales Team` st
+ where st.parent = dt.name and dt.name = dt_item.parent and st.parenttype = '%s'
+ and dt.docstatus = 1 %s order by st.sales_person, dt.name desc""" %
+ (date_field, filters["doc_type"], filters["doc_type"], filters["doc_type"], conditions),
+ tuple(items), as_list=1)
+
+ return entries
+
+def get_conditions(filters, date_field):
+ conditions = ""
+ if filters.get("company"): conditions += " and dt.company = '%s'" % filters["company"]
+ if filters.get("customer"): conditions += " and dt.customer = '%s'" % filters["customer"]
+ if filters.get("territory"): conditions += " and dt.territory = '%s'" % filters["territory"]
+
+ if filters.get("from_date"): conditions += " and dt.%s >= '%s'" % \
+ (date_field, filters["from_date"])
+ if filters.get("to_date"): conditions += " and dt.%s <= '%s'" % (date_field, filters["to_date"])
+
+ if filters.get("sales_person"): conditions += " and st.sales_person = '%s'" % \
+ filters["sales_person"]
+
+ items = get_items(filters)
+ if items:
+ conditions += " and dt_item.item_code in (%s)" % ', '.join(['%s']*len(items))
+
+ return conditions, items
+
+def get_items(filters):
+ if filters.get("item_group"): key = "item_group"
+ elif filters.get("brand"): key = "brand"
+ else: key = ""
+
+ items = []
+ if key:
+ items = webnotes.conn.sql_list("""select name from tabItem where %s = %s""" %
+ (key, '%s'), (filters[key]))
+
+ return items
\ No newline at end of file
diff --git a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt
new file mode 100644
index 00000000000..abd69f3f2fb
--- /dev/null
+++ b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-05-03 11:31:05",
+ "docstatus": 0,
+ "modified": "2013-05-03 11:31:05",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "add_total_row": 1,
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Sales Order",
+ "report_name": "Sales Person-wise Transaction Summary",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Sales Person-wise Transaction Summary"
+ }
+]
\ No newline at end of file
diff --git a/selling/report/territory_target_variance_item_group_wise/__init__.py b/selling/report/territory_target_variance_item_group_wise/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js
new file mode 100644
index 00000000000..146b17d02b8
--- /dev/null
+++ b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js
@@ -0,0 +1,25 @@
+wn.query_reports["Territory Target Variance Item Group-Wise"] = {
+ "filters": [
+ {
+ fieldname: "fiscal_year",
+ label: "Fiscal Year",
+ fieldtype: "Link",
+ options: "Fiscal Year",
+ default: sys_defaults.fiscal_year
+ },
+ {
+ fieldname: "period",
+ label: "Period",
+ fieldtype: "Select",
+ options: "Monthly\nQuarterly\nHalf-Yearly\nYearly",
+ default: "Monthly"
+ },
+ {
+ fieldname: "target_on",
+ label: "Target On",
+ fieldtype: "Select",
+ options: "Quantity\nAmount",
+ default: "Quantity"
+ },
+ ]
+}
\ No newline at end of file
diff --git a/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
new file mode 100644
index 00000000000..109acbdbe85
--- /dev/null
+++ b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
@@ -0,0 +1,141 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes import _, msgprint
+from webnotes.utils import flt
+import time
+from accounts.utils import get_fiscal_year
+from controllers.trends import get_period_date_ranges, get_period_month_ranges
+
+def execute(filters=None):
+ if not filters: filters = {}
+
+ columns = get_columns(filters)
+ period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
+ tim_map = get_territory_item_month_map(filters)
+
+ precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2
+
+ data = []
+
+ for territory, territory_items in tim_map.items():
+ for item_group, monthwise_data in territory_items.items():
+ row = [territory, item_group]
+ totals = [0, 0, 0]
+ for relevant_months in period_month_ranges:
+ period_data = [0, 0, 0]
+ for month in relevant_months:
+ month_data = monthwise_data.get(month, {})
+ for i, fieldname in enumerate(["target", "achieved", "variance"]):
+ value = flt(month_data.get(fieldname), precision)
+ period_data[i] += value
+ totals[i] += value
+ period_data[2] = period_data[0] - period_data[1]
+ row += period_data
+ totals[2] = totals[0] - totals[1]
+ row += totals
+ data.append(row)
+
+ return columns, sorted(data, key=lambda x: (x[0], x[1]))
+
+def get_columns(filters):
+ for fieldname in ["fiscal_year", "period", "target_on"]:
+ if not filters.get(fieldname):
+ label = (" ".join(fieldname.split("_"))).title()
+ msgprint(_("Please specify") + ": " + label, raise_exception=True)
+
+ columns = ["Territory:Link/Territory:80", "Item Group:Link/Item Group:80"]
+
+ group_months = False if filters["period"] == "Monthly" else True
+
+ for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]):
+ for label in ["Target (%s)", "Achieved (%s)", "Variance (%s)"]:
+ if group_months:
+ columns.append(label % (from_date.strftime("%b") + " - " + to_date.strftime("%b")))
+ else:
+ columns.append(label % from_date.strftime("%b"))
+
+ return columns + ["Total Target::80", "Total Achieved::80", "Total Variance::80"]
+
+#Get territory & item group details
+def get_territory_details(filters):
+ return webnotes.conn.sql("""select t.name, td.item_group, td.target_qty,
+ td.target_amount, t.distribution_id
+ from `tabTerritory` t, `tabTarget Detail` td
+ where td.parent=t.name and td.fiscal_year=%s and
+ ifnull(t.distribution_id, '')!='' order by t.name""",
+ (filters["fiscal_year"]), as_dict=1)
+
+#Get target distribution details of item group
+def get_target_distribution_details(filters):
+ target_details = {}
+
+ for d in webnotes.conn.sql("""select bdd.month, bdd.percentage_allocation \
+ from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd, \
+ `tabTerritory` t where bdd.parent=bd.name and t.distribution_id=bd.name and \
+ bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
+ target_details.setdefault(d.month, d)
+
+ return target_details
+
+#Get achieved details from sales order
+def get_achieved_details(filters):
+ start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
+
+ return webnotes.conn.sql("""select soi.item_code, soi.qty, soi.amount, so.transaction_date,
+ so.territory, MONTHNAME(so.transaction_date) as month_name
+ from `tabSales Order Item` soi, `tabSales Order` so
+ where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and
+ so.transaction_date<=%s""" % ('%s', '%s'),
+ (start_date, end_date), as_dict=1)
+
+def get_territory_item_month_map(filters):
+ territory_details = get_territory_details(filters)
+ tdd = get_target_distribution_details(filters)
+ achieved_details = get_achieved_details(filters)
+
+ tim_map = {}
+
+ for td in territory_details:
+ for month in tdd:
+ tim_map.setdefault(td.name, {}).setdefault(td.item_group, {})\
+ .setdefault(month, webnotes._dict({
+ "target": 0.0, "achieved": 0.0
+ }))
+
+ tav_dict = tim_map[td.name][td.item_group][month]
+
+ for ad in achieved_details:
+ if (filters["target_on"] == "Quantity"):
+ tav_dict.target = flt(td.target_qty) * \
+ (tdd[month]["percentage_allocation"]/100)
+ if ad.month_name == month and get_item_group(ad.item_code) == td.item_group \
+ and ad.territory == td.name:
+ tav_dict.achieved += ad.qty
+
+ if (filters["target_on"] == "Amount"):
+ tav_dict.target = flt(td.target_amount) * \
+ (tdd[month]["percentage_allocation"]/100)
+ if ad.month_name == month and get_item_group(ad.item_code) == td.item_group \
+ and ad.territory == td.name:
+ tav_dict.achieved += ad.amount
+
+ return tim_map
+
+def get_item_group(item_name):
+ return webnotes.conn.get_value("Item", item_name, "item_group")
\ No newline at end of file
diff --git a/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt
new file mode 100644
index 00000000000..6e16b64d4e2
--- /dev/null
+++ b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-21 12:15:00",
+ "docstatus": 0,
+ "modified": "2013-06-21 12:15:00",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Sales Order",
+ "report_name": "Territory Target Variance Item Group-Wise",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Territory Target Variance Item Group-Wise"
+ }
+]
\ No newline at end of file
diff --git a/selling/search_criteria/__init__.py b/selling/search_criteria/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/delivered_items_to_be_install/__init__.py b/selling/search_criteria/delivered_items_to_be_install/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/delivered_items_to_be_install/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.js b/selling/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.js
deleted file mode 100644
index df8fc21fb47..00000000000
--- a/selling/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
-}
\ No newline at end of file
diff --git a/selling/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.txt b/selling/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.txt
deleted file mode 100644
index ab23a299ff2..00000000000
--- a/selling/search_criteria/delivered_items_to_be_install/delivered_items_to_be_install.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:51"
- },
- {
- "add_col": "(`tabDelivery Note Item`.`qty`- ifnull(`tabDelivery Note Item`.`installed_qty`, 0)) AS 'Pending to Install'",
- "parent_doc_type": "Delivery Note",
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Delivery Note\u0001Saved':1,'Delivery Note\u0001Submitted':1,'Delivery Note\u0001Status':'','Delivery Note\u0001Fiscal Year':''}",
- "description": "Delivered Items to be Install",
- "doc_type": "Delivery Note Item",
- "name": "__common__",
- "add_cond": "`tabDelivery Note Item`.`qty` > ifnull(`tabDelivery Note Item`.`installed_qty`, 0)",
- "doctype": "Search Criteria",
- "sort_by": "`tabDelivery Note`.`name`",
- "page_len": 50,
- "criteria_name": "Delivered Items to be Install",
- "columns": "Delivery Note\u0001ID,Delivery Note\u0001Status,Delivery Note\u0001Customer,Delivery Note\u0001Customer Name,Delivery Note\u0001Contact Person,Delivery Note\u0001Voucher Date,Delivery Note Item\u0001Item Code,Delivery Note Item\u0001Item Name,Delivery Note Item\u0001Quantity,Delivery Note Item\u0001Installed Qty,Delivery Note\u0001% Installed"
- },
- {
- "name": "delivered_items_to_be_install",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/draft_sales_orders/__init__.py b/selling/search_criteria/draft_sales_orders/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/draft_sales_orders/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/draft_sales_orders/draft_sales_orders.js b/selling/search_criteria/draft_sales_orders/draft_sales_orders.js
deleted file mode 100644
index 7f8aed8f41b..00000000000
--- a/selling/search_criteria/draft_sales_orders/draft_sales_orders.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'From Sales Order Date'].df['report_default'] = sys_defaults.year_start_date;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'To Sales Order Date'].df['report_default'] = dateutil.obj_to_str(new Date());
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
-
-}
\ No newline at end of file
diff --git a/selling/search_criteria/draft_sales_orders/draft_sales_orders.txt b/selling/search_criteria/draft_sales_orders/draft_sales_orders.txt
deleted file mode 100644
index af60e71713c..00000000000
--- a/selling/search_criteria/draft_sales_orders/draft_sales_orders.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-[
- {
- "creation": "2012-05-14 18:20:52",
- "docstatus": 0,
- "modified": "2013-01-30 15:19:07",
- "modified_by": "Administrator",
- "owner": "Administrator"
- },
- {
- "columns": "Sales Order\u0001ID,Sales Order\u0001Status,Sales Order\u0001Sales Order Date,Sales Order\u0001Customer,Sales Order\u0001P.O. No,Sales Order\u0001Currency,Sales Order\u0001Grand Total (Export)",
- "criteria_name": "Draft Sales Orders",
- "custom_query": "",
- "description": "List of Open Sales orders filtered by period, customer and other details",
- "doc_type": "Sales Order",
- "doctype": "Search Criteria",
- "filters": "{\"Sales Order\\u0001Saved\":1,\"Sales Order\\u0001Submitted\":1,\"Sales Order\\u0001To Sales Order Date\\u0001upper\":\"2013-01-30\",\"Sales Order\\u0001Company\":\"Alpha\",\"Sales Order\\u0001Fiscal Year\":[\"\"],\"Sales Order\\u0001Status\":[\"Draft\"]}",
- "module": "Selling",
- "name": "__common__",
- "page_len": 50,
- "report_script": null,
- "sort_by": "`tabSales Order`.`name`",
- "sort_order": "DESC",
- "standard": "Yes"
- },
- {
- "doctype": "Search Criteria",
- "name": "draft_sales_orders"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/follow_up_report/__init__.py b/selling/search_criteria/follow_up_report/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/follow_up_report/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/follow_up_report/follow_up_report.js b/selling/search_criteria/follow_up_report/follow_up_report.js
deleted file mode 100644
index 2126d0b9bb2..00000000000
--- a/selling/search_criteria/follow_up_report/follow_up_report.js
+++ /dev/null
@@ -1,63 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.mytabs.items['Select Columns'].hide()
- this.mytabs.items['More Filters'].hide()
-
- this.hide_all_filters();
- this.add_filter({fieldname:'follow_up_on', label:'Communication on', fieldtype:'Select', options:''+NEWLINE+'Lead'+NEWLINE+'Opportunity'+NEWLINE+'Quotation',ignore : 1,parent:'Communication Log', in_first_page : 1, single_select :1});
- this.add_filter({fieldname:'lead_name', label:'Lead', fieldtype:'Link', options:'Lead', report_default:'', ignore : 1, parent:'Communication Log', in_first_page : 1});
- this.add_filter({fieldname:'enq_name', label:'Opportunity', fieldtype:'Link', options:'Opportunity', report_default:'', ignore : 1, parent:'Communication Log', in_first_page : 1});
- this.add_filter({fieldname:'qtn_name', label:'Quotation', fieldtype:'Link', options:'Quotation', report_default:'', ignore : 1, parent:'Communication Log', in_first_page : 1});
-
- this.get_filter('Communication Log', 'Communication type').set_as_single();
- this.set_filter_properties('Communication Log', 'Communication by', {filter_hide:0, in_first_page : 1});
- this.set_filter_properties('Communication Log', 'Communication type', {filter_hide:0, in_first_page : 1});
- this.set_filter_properties('Communication Log', 'From Date', {filter_hide:0, in_first_page : 1});
- this.set_filter_properties('Communication Log', 'To Date', {filter_hide:0, in_first_page : 1});
-
- this.orig_sort_list = [['Date','`tabCommunication Log`.`date`'],['Document Type','`tabCommunication Log`.`parenttype`'],['Document','`tabCommunication Log`.`parent`'],['Follow Up By','`tabCommunication Log`.`follow_up_by`'],['Follow Up Type','`tabCommunication Log`.`follow_up_type`']];
-}
-
-
-report.get_query = function() {
- var lead_id = this.filter_fields_dict['Communication Log'+FILTER_SEP+'Lead'].get_value();
- var enq_id = this.filter_fields_dict['Communication Log'+FILTER_SEP+'Opportunity'].get_value();
- var quo_id = this.filter_fields_dict['Communication Log'+FILTER_SEP+'Quotation'].get_value();
-
- var follow_up_on = this.filter_fields_dict['Communication Log'+FILTER_SEP+'Communication on'].get_value();
- var follow_up_by = this.filter_fields_dict['Communication Log'+FILTER_SEP+'Communication by'].get_value();
-
- var on_type = this.filter_fields_dict['Communication Log'+FILTER_SEP+'Communication type'].get_value();
- var from_date = this.filter_fields_dict['Communication Log'+FILTER_SEP+'From Date'].get_value();
- var to_date = this.filter_fields_dict['Communication Log'+FILTER_SEP+'To Date'].get_value();
-
- var cond = 'parenttype IN ("Lead","Opportunity","Quotation")';
- if(follow_up_on) cond = 'parenttype = "'+follow_up_on+'"';
-
- if((follow_up_on == 'Lead' && lead_id) || (lead_id && !follow_up_on)) cond +=' AND parent = "'+lead_id+'"';
- if((follow_up_on == 'Opportunity' && enq_id) || (enq_id && !follow_up_on)) cond +=' AND parent = "'+enq_id+'"';
- if((follow_up_on == 'Quotation' && quo_id) || (quo_id && !follow_up_on)) cond +=' AND parent = "'+quo_id+'"';
-
- if(on_type) cond += ' AND follow_up_type ="'+on_type+'"';
- if(from_date) cond += ' AND date >="'+from_date+'"';
- if(to_date) cond += ' AND date <="'+to_date+'"';
- if(follow_up_by) cond += ' AND follow_up_by = "'+follow_up_by+'"';
-
- var q ='SELECT distinct `tabCommunication Log`.`parenttype`, `tabCommunication Log`.`parent`, `tabCommunication Log`.`date`, `tabCommunication Log`.`notes`, `tabCommunication Log`.`follow_up_type`, `tabCommunication Log`.`follow_up_by` FROM `tabCommunication Log` WHERE '+cond+' ORDER BY '+sel_val(this.dt.sort_sel)+' '+this.dt.sort_order;
- return q;
-}
diff --git a/selling/search_criteria/follow_up_report/follow_up_report.py b/selling/search_criteria/follow_up_report/follow_up_report.py
deleted file mode 100644
index 40066274d22..00000000000
--- a/selling/search_criteria/follow_up_report/follow_up_report.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-from __future__ import unicode_literals
-follow_up_on = filter_values.get('follow_up_on')
-
-cols = [['Document Type', 'Data', '150px', '']
- ,['Document', 'Link', '150px', follow_up_on]
- ,['Follow Up Date', 'Date', '150px', '']
- ,['Description','Data','300px','']
- ,['Follow Up Type','Data','150px','']
- ,['Follow Up By','Link','150px','Sales Person']
- ]
-
-for c in cols:
- colnames.append(c[0])
- coltypes.append(c[1])
- colwidths.append(c[2])
- coloptions.append(c[3])
- col_idx[c[0]] = len(colnames)-1
diff --git a/selling/search_criteria/follow_up_report/follow_up_report.txt b/selling/search_criteria/follow_up_report/follow_up_report.txt
deleted file mode 100644
index b789bd92a2f..00000000000
--- a/selling/search_criteria/follow_up_report/follow_up_report.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "ashwini@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:51"
- },
- {
- "parent_doc_type": "Lead",
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Lead\u0001Status':'','Lead\u0001Source':'','Lead\u0001Lead Type':'','Lead\u0001Rating':'','Lead\u0001Market Segment':'','Lead\u0001Fiscal Year':''}",
- "doc_type": "Communication Log",
- "name": "__common__",
- "doctype": "Search Criteria",
- "sort_by": "`tabLead`.`name`",
- "page_len": 50,
- "criteria_name": "Follow-up Report",
- "columns": "Lead\u0001ID,Communication Log\u0001Date,Communication Log\u0001Notes,Communication Log\u0001Communication Log type"
- },
- {
- "name": "follow-up_report",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/itemwise_delivery_details/__init__.py b/selling/search_criteria/itemwise_delivery_details/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/itemwise_delivery_details/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/itemwise_delivery_details/itemwise_delivery_details.js b/selling/search_criteria/itemwise_delivery_details/itemwise_delivery_details.js
deleted file mode 100644
index b0566765c0b..00000000000
--- a/selling/search_criteria/itemwise_delivery_details/itemwise_delivery_details.js
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
- this.filter_fields_dict['Delivery Note'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
-
-}
diff --git a/selling/search_criteria/itemwise_delivery_details/itemwise_delivery_details.py b/selling/search_criteria/itemwise_delivery_details/itemwise_delivery_details.py
deleted file mode 100644
index 0529d1b92de..00000000000
--- a/selling/search_criteria/itemwise_delivery_details/itemwise_delivery_details.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-from __future__ import unicode_literals
-out=[]
-qty,amt,bill_amt=0,0,0
-
-for r in res:
- qty += flt(r[col_idx['Quantity']])
- amt += flt(r[col_idx['Amount*']])
- bill_amt += flt(r[col_idx['Billed Amt']])
- out.append(r)
-
-
-#Add the totals row
-l_row = ['' for i in range(len(colnames))]
-l_row[col_idx['Item Name']] = 'TOTALS'
-l_row[col_idx['Quantity']] = qty
-l_row[col_idx['Amount*']] = amt
-l_row[col_idx['Billed Amt']] = bill_amt
-out.append(l_row)
diff --git a/selling/search_criteria/itemwise_delivery_details/itemwise_delivery_details.txt b/selling/search_criteria/itemwise_delivery_details/itemwise_delivery_details.txt
deleted file mode 100644
index 9ba342e2aef..00000000000
--- a/selling/search_criteria/itemwise_delivery_details/itemwise_delivery_details.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-23 12:46:00",
- "modified_by": "Administrator",
- "modified": "2012-05-03 18:13:49"
- },
- {
- "parent_doc_type": "Delivery Note",
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{\"Delivery Note\\u0001Submitted\":1,\"Delivery Note\\u0001Status\":[\"\"],\"Delivery Note\\u0001Fiscal Year\":[\"\"]}",
- "doc_type": "Delivery Note Item",
- "name": "__common__",
- "doctype": "Search Criteria",
- "sort_by": "`tabDelivery Note`.`name`",
- "page_len": 50,
- "criteria_name": "Itemwise Delivery Details",
- "columns": "Delivery Note\u0001ID,Delivery Note Item\u0001Item Code,Delivery Note Item\u0001Item Name,Delivery Note Item\u0001Quantity,Delivery Note Item\u0001Rate*,Delivery Note Item\u0001Amount*,Delivery Note Item\u0001Billed Amt"
- },
- {
- "name": "itemwise_delivery_details",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/itemwise_sales_details/__init__.py b/selling/search_criteria/itemwise_sales_details/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/itemwise_sales_details/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/itemwise_sales_details/itemwise_sales_details.js b/selling/search_criteria/itemwise_sales_details/itemwise_sales_details.js
deleted file mode 100644
index 7ff214a4951..00000000000
--- a/selling/search_criteria/itemwise_sales_details/itemwise_sales_details.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'ID'].df.in_first_page = 1;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'From Sales Order Date'].df['report_default'] = sys_defaults.year_start_date;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'To Sales Order Date'].df['report_default'] = dateutil.obj_to_str(new Date());
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
- this.filter_fields_dict['Sales Order Item'+FILTER_SEP +'Item Code'].df.in_first_page = 1;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Status'].df.filter_hide = 1;
-}
-
-//this.mytabs.items['Select Columns'].hide();
-this.mytabs.items['More Filters'].hide();
\ No newline at end of file
diff --git a/selling/search_criteria/itemwise_sales_details/itemwise_sales_details.py b/selling/search_criteria/itemwise_sales_details/itemwise_sales_details.py
deleted file mode 100644
index 1b7a19524fd..00000000000
--- a/selling/search_criteria/itemwise_sales_details/itemwise_sales_details.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-from __future__ import unicode_literals
-out=[]
-qty,amt,del_qty,bill_amt=0,0,0,0
-
-for r in res:
- qty += flt(r[col_idx['Quantity']])
- amt += flt(r[col_idx['Amount*']])
- del_qty += flt(r[col_idx['Delivered Qty']])
- bill_amt += flt(r[col_idx['Billed Amt']])
- out.append(r)
-
-
-#Add the totals row
-l_row = ['' for i in range(len(colnames))]
-l_row[col_idx['Item Name']] = 'TOTALS'
-l_row[col_idx['Quantity']] = qty
-l_row[col_idx['Amount*']] = amt
-l_row[col_idx['Delivered Qty']] = del_qty
-l_row[col_idx['Billed Amt']] = bill_amt
-out.append(l_row)
diff --git a/selling/search_criteria/itemwise_sales_details/itemwise_sales_details.txt b/selling/search_criteria/itemwise_sales_details/itemwise_sales_details.txt
deleted file mode 100644
index 77370408097..00000000000
--- a/selling/search_criteria/itemwise_sales_details/itemwise_sales_details.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-23 12:46:00",
- "modified_by": "Administrator",
- "modified": "2012-05-03 18:18:31"
- },
- {
- "parent_doc_type": "Sales Order",
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{\"Sales Order\\u0001Submitted\":1,\"Sales Order\\u0001Fiscal Year\":[\"\"],\"Sales Order\\u0001Status\":[\"\"]}",
- "doc_type": "Sales Order Item",
- "name": "__common__",
- "doctype": "Search Criteria",
- "sort_by": "`tabSales Order`.`name`",
- "page_len": 50,
- "criteria_name": "Itemwise Sales Details",
- "columns": "Sales Order\u0001ID,Sales Order\u0001Customer,Sales Order Item\u0001Item Code,Sales Order Item\u0001Item Name,Sales Order Item\u0001Quantity,Sales Order Item\u0001Basic Rate*,Sales Order Item\u0001Amount*,Sales Order Item\u0001Delivered Qty,Sales Order Item\u0001Billed Amt"
- },
- {
- "name": "itemwise_sales_details",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/lead_to_follow_up/__init__.py b/selling/search_criteria/lead_to_follow_up/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/lead_to_follow_up/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/lead_to_follow_up/lead_to_follow_up.js b/selling/search_criteria/lead_to_follow_up/lead_to_follow_up.js
deleted file mode 100644
index 94f2ef5bafe..00000000000
--- a/selling/search_criteria/lead_to_follow_up/lead_to_follow_up.js
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.filter_fields_dict['Lead'+FILTER_SEP +'Status'].df.filter_hide = 1;
- this.filter_fields_dict['Lead'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
-}
-
\ No newline at end of file
diff --git a/selling/search_criteria/lead_to_follow_up/lead_to_follow_up.txt b/selling/search_criteria/lead_to_follow_up/lead_to_follow_up.txt
deleted file mode 100644
index 2ddd5e9753f..00000000000
--- a/selling/search_criteria/lead_to_follow_up/lead_to_follow_up.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:51"
- },
- {
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Lead\u0001Status':'','Lead\u0001Source':'','Lead\u0001Expected Month':'','Lead\u0001Industry':'','Lead\u0001Market Segment':'','Lead\u0001Rating':''}",
- "doc_type": "Lead",
- "name": "__common__",
- "add_cond": "`tabLead`.status!='Converted' \n`tabLead`.status!='Lead Lost' \n`tabLead`.status!='Not Interested'",
- "doctype": "Search Criteria",
- "sort_by": "`tabLead`.`name`",
- "page_len": 50,
- "criteria_name": "Lead-To follow up",
- "columns": "Lead\u0001ID,Lead\u0001Status,Lead\u0001Lead Name,Lead\u0001Lead Date,Lead\u0001Lead Owner,Lead\u0001Next Contact Date"
- },
- {
- "name": "lead-to_follow_up",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/lead_to_follow_up/sales_order_overdue.js b/selling/search_criteria/lead_to_follow_up/sales_order_overdue.js
deleted file mode 100644
index 799cd229484..00000000000
--- a/selling/search_criteria/lead_to_follow_up/sales_order_overdue.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.hide_all_filters();
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Customer'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'ID'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Quotation No'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Sales Partner'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'From Sales Order Date'].df.filter_hide = 0;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'To Sales Order Date'].df.filter_hide = 0;
-}
\ No newline at end of file
diff --git a/selling/search_criteria/opportunity_to_follow_up/__init__.py b/selling/search_criteria/opportunity_to_follow_up/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/opportunity_to_follow_up/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/opportunity_to_follow_up/opportunity_to_follow_up.txt b/selling/search_criteria/opportunity_to_follow_up/opportunity_to_follow_up.txt
deleted file mode 100644
index b524e6af737..00000000000
--- a/selling/search_criteria/opportunity_to_follow_up/opportunity_to_follow_up.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-03-30 14:50:44",
- "modified_by": "Administrator",
- "modified": "2012-03-30 14:50:44"
- },
- {
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Opportunity\u0001Fiscal Year':''}",
- "doc_type": "Opportunity",
- "name": "__common__",
- "add_cond": "`tabOpportunity`.name=`tabQuotation`.enq_no\n`tabOpportunity`.docstatus=1\n`tabQuotation`.status='Submitted'",
- "doctype": "Search Criteria",
- "sort_by": "`tabOpportunity`.`name`",
- "page_len": 50,
- "criteria_name": "Opportunity-To follow up",
- "columns": "Opportunity\u0001ID,Opportunity\u0001Owner,Opportunity\u0001Company,Opportunity\u0001Fiscal Year"
- },
- {
- "name": "opportunity-to_follow_up",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/sales_orderwise_booking_&_delivery_summary/__init__.py b/selling/search_criteria/sales_orderwise_booking_&_delivery_summary/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/sales_orderwise_booking_&_delivery_summary/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/sales_orderwise_booking_&_delivery_summary/sales_orderwise_booking_&_delivery_summary.txt b/selling/search_criteria/sales_orderwise_booking_&_delivery_summary/sales_orderwise_booking_&_delivery_summary.txt
deleted file mode 100644
index 9050204f68e..00000000000
--- a/selling/search_criteria/sales_orderwise_booking_&_delivery_summary/sales_orderwise_booking_&_delivery_summary.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "add_col": "SUM(CASE WHEN `tabSales Order`.`status` = 'Stopped' THEN (`tabSales Order Item`.`delivered_qty` * `tabSales Order Item`.`basic_rate`) ELSE (`tabSales Order Item`.`qty` * `tabSales Order Item`.`basic_rate`) END) AS 'Booking Total'\nSUM(`tabSales Order Item`.`delivered_qty` * `tabSales Order Item`.`basic_rate`) AS 'Delivered Amount'",
- "parent_doc_type": "Sales Order",
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Sales Order\u0001Submitted':1,'Sales Order\u0001Status':'','Sales Order\u0001Fiscal Year':''}",
- "description": "Sales Orderwise Booking & Delivery Summary",
- "doc_type": "Sales Order Item",
- "name": "__common__",
- "doctype": "Search Criteria",
- "sort_by": "`tabSales Order`.`name`",
- "group_by": "`tabSales Order`.`name`",
- "page_len": 50,
- "criteria_name": "Sales Orderwise Booking & Delivery Summary",
- "columns": "Sales Order\u0001ID,Sales Order\u0001Status,Sales Order\u0001% Billed,Sales Order\u0001Sales Order Date,Sales Order\u0001Customer,Sales Order\u0001Customer Name,Sales Order\u0001Territory"
- },
- {
- "name": "sales_orderwise_booking_&_delivery_summary",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/sales_orderwise_pending_amount_to_bill/__init__.py b/selling/search_criteria/sales_orderwise_pending_amount_to_bill/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/sales_orderwise_pending_amount_to_bill/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.js b/selling/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.js
deleted file mode 100644
index 1b3837a4ed7..00000000000
--- a/selling/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
-}
\ No newline at end of file
diff --git a/selling/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.txt b/selling/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.txt
deleted file mode 100644
index 1a8d19bd3d7..00000000000
--- a/selling/search_criteria/sales_orderwise_pending_amount_to_bill/sales_orderwise_pending_amount_to_bill.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-[
- {
- "owner": "dhanalekshmi@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "add_col": "SUM((`tabSales Order Item`.`qty` - ifnull(`tabSales Order Item`.`billed_qty`, 0)) * `tabSales Order Item`.`basic_rate`) AS \"Pending Amount\"",
- "parent_doc_type": "Sales Order",
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Sales Order\u0001Saved':1,'Sales Order\u0001Submitted':1,'Sales Order\u0001Company Name':'','Sales Order\u0001Fiscal Year':''}",
- "description": "Sales Orderwise Pending Amount To Bill",
- "doc_type": "Sales Order Item",
- "name": "__common__",
- "add_cond": "`tabSales Order`.status != \"Stopped\"\n`tabSales Order`.order_type!=\"Maintenance\"",
- "doctype": "Search Criteria",
- "sort_by": "`tabSales Order`.`name`",
- "group_by": "`tabSales Order`.`name`",
- "page_len": 50,
- "criteria_name": "Sales Orderwise Pending Amount To Bill",
- "columns": "Sales Order\u0001ID,Sales Order\u0001Customer,Sales Order\u0001Customer Address,Sales Order\u0001Status,Sales Order\u0001% Delivered,Sales Order\u0001% Billed,Sales Order\u0001Company Name,Sales Order\u0001Sales Order Date,Sales Order\u0001Net Total,Sales Order\u0001Zone,Sales Order\u0001Territory,Sales Order\u0001Email Id"
- },
- {
- "name": "sales_orderwise_pending_amount_to_bill",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/sales_orderwise_pending_qty_to_deliver/__init__.py b/selling/search_criteria/sales_orderwise_pending_qty_to_deliver/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/sales_orderwise_pending_qty_to_deliver/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/sales_orderwise_pending_qty_to_deliver/sales_orderwise_pending_qty_to_deliver.txt b/selling/search_criteria/sales_orderwise_pending_qty_to_deliver/sales_orderwise_pending_qty_to_deliver.txt
deleted file mode 100644
index d9b15819e0a..00000000000
--- a/selling/search_criteria/sales_orderwise_pending_qty_to_deliver/sales_orderwise_pending_qty_to_deliver.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-[
- {
- "owner": "dhanalekshmi@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "add_col": "SUM(`tabSales Order Item`.`qty` - ifnull(`tabSales Order Item`.`delivered_qty`, 0)) AS \"Pending Qty\"",
- "parent_doc_type": "Sales Order",
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Sales Order\u0001Saved':1,'Sales Order\u0001Submitted':1,'Sales Order\u0001Status':'','Sales Order\u0001Fiscal Year':''}",
- "description": "Sales Orderwise Pending Qty To Deliver",
- "doc_type": "Sales Order Item",
- "name": "__common__",
- "add_cond": "`tabSales Order`.status != \"Stopped\"\n`tabSales Order Item`.`qty` > ifnull(`tabSales Order Item`.`delivered_qty`, 0)",
- "doctype": "Search Criteria",
- "sort_by": "`tabSales Order`.`name`",
- "group_by": "`tabSales Order`.`name`",
- "page_len": 50,
- "criteria_name": "Sales Orderwise Pending Qty To Deliver",
- "columns": "Sales Order\u0001ID,Sales Order\u0001Customer,Sales Order\u0001Customer Name,Sales Order\u0001Customer Address,Sales Order\u0001Status,Sales Order\u0001% Delivered,Sales Order\u0001% Billed,Sales Order\u0001Sales Order Date,Sales Order\u0001Territory,Sales Order\u0001Email Id"
- },
- {
- "name": "sales_orderwise_pending_qty_to_deliver",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/sales_persons_target_variance_item_group_wise/__init__.py b/selling/search_criteria/sales_persons_target_variance_item_group_wise/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/sales_persons_target_variance_item_group_wise/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.js b/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.js
deleted file mode 100644
index 8e46f423220..00000000000
--- a/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.js
+++ /dev/null
@@ -1,57 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
-
- this.hide_all_filters();
-
- this.add_filter({fieldname:'sales_person', label:'Sales Person', fieldtype:'Link', options:'Sales Person',ignore : 1,parent:'Target Detail'});
-
- this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Target Detail'});
-
- this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Target Detail'});
-
- this.add_filter({fieldname:'under', label:'Under',fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice',report_default:'Sales Order',ignore : 1, parent:'Target Detail'});
-
- this.add_filter({fieldname : 'target_on', label:'Target On', fieldtype:'Select', options:'Quantity'+NEWLINE+'Amount',report_default:'Quantity',ignore : 1,parent:'Target Detail'});
- this.filter_fields_dict['Target Detail'+FILTER_SEP +'Sales Person'].df.in_first_page = 1;
-}
-this.mytabs.items['Select Columns'].hide();
-report.get_query = function() {
-
- sales_person = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Sales Person'].get_value();
- target_on = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Target On'].get_value();
- under = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Under'].get_value();
- if(under == 'Sales Invoice') under = 'Sales Invoice';
-
- if(target_on == 'Quantity'){
- q1 = 't1.target_qty AS "Target Quantity"';
- q2 = '0 AS "Target Quantity"';
- cond1 = 'ifnull(t1.target_qty,"")!=""';
- cond2 = 'ifnull(t6.target_qty,"")!=""';
- }
- else{
- q1 = 't1.target_amount AS "Target Amount"';
- q2 = '0 AS "Target Amount"';
- cond1 = 'ifnull(t1.target_amount,"")!=""';
- cond2 = 'ifnull(t6.target_amount,"")!=""';
- }
-
- var q ='SELECT t1.item_group AS "Item Group", '+q1+', t2.distribution_id AS "Distribution Id" FROM `tabTarget Detail` t1, `tabSales Person` t2 WHERE t1.parenttype = "Sales Person" AND t1.parent = "'+sales_person+'" AND t1.parent=t2.name AND ifnull(t1.item_group,"") != "" AND '+cond1+' UNION SELECT t3.item_group AS "Item Group", '+q2+',"" AS "Distribution Id" FROM `tab'+under+' Item` t3,`tabSales Team` t4,`tab'+under+'` t5 where t3.item_group NOT IN (SELECT t6.item_group AS "Item Group" FROM `tabTarget Detail` t6, `tabSales Person` t7 WHERE t6.parenttype = "Sales Person" AND t6.parent = "'+sales_person+'" AND t6.parent=t7.name AND '+cond2+') AND t4.sales_person = "'+sales_person+'" AND t3.parent = t5.name AND t4.parent = t5.name AND t5.docstatus = 1';
-
- return q;
-
-}
diff --git a/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.py b/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.py
deleted file mode 100644
index 3c822a6aac5..00000000000
--- a/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.py
+++ /dev/null
@@ -1,145 +0,0 @@
-# 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 .
-# validate Filters
-from __future__ import unicode_literals
-flt_dict = {'fiscal_year': 'Fiscal Year', 'period': 'Period', 'under' : 'Under', 'sales_person':'Sales Person', 'target_on':'Target On'}
-for f in flt_dict:
- if not filter_values.get(f):
- msgprint("Please Select " + cstr(flt_dict[f]))
- raise Exception
-
-# Get Values from fliters
-fiscal_year = filter_values.get('fiscal_year')[0]
-period = filter_values.get('period')
-under = filter_values.get('under')
-sales_person = filter_values.get('sales_person')
-target_on = filter_values.get('target_on')
-
-
-# set colnames
-for d in ['Item Group', 'Total Target Allocated', 'Distribution Id']:
- colnames.append(d)
- coltypes.append('Data')
- colwidths.append('150px')
- coloptions.append('')
- col_idx[d] = len(colnames) - 1
-
-
-
-# Set required field names
-based_on_fn = 'sales_person'
-
-date_fn = (under == 'Sales Order' ) and 'transaction_date' or 'posting_date'
-
-mon_list = []
-
-data = {'start_date':0, 'end_date':1}
-
-def make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx):
- count = 1
- if period == 'Quarterly' or period == 'Half Yearly' or period == 'Annual': mon_list.append([str(start_date)])
- for m in range(12):
- # get last date
- last_date = str(sql("select LAST_DAY('%s')" % start_date)[0][0])
-
- # make mon_list for Monthly Period
- if period == 'Monthly' :
- mon_list.append([start_date, last_date])
- # add months as Column names
- month_name = sql("select MONTHNAME('%s')" % start_date)[0][0]
- append_colnames(str(month_name)[:3], colnames, coltypes, colwidths, coloptions, col_idx)
-
- # get start date
- start_date = str(sql("select DATE_ADD('%s',INTERVAL 1 DAY)" % last_date)[0][0])
-
- # make mon_list for Quaterly Period
- if period == 'Quarterly' and count % 3 == 0:
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column names
- append_colnames('Q '+ str(count / 3), colnames, coltypes, colwidths, coloptions, col_idx)
- if count != 12: mon_list.append([start_date])
-
- # make mon_list for Half Yearly Period
- if period == 'Half Yearly' and count % 6 == 0 :
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column Names
- append_colnames('H'+str(count / 6), colnames, coltypes, colwidths, coloptions, col_idx)
- if count != 12: mon_list.append([start_date])
-
- # make mon_list for Annual Period
- if period == 'Annual' and count % 12 == 0:
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column Names
- append_colnames('', colnames, coltypes, colwidths, coloptions, col_idx)
- count = count +1
-
-def append_colnames(name, colnames, coltypes, colwidths, coloptions, col_idx):
- col = ['Target', 'Actual', 'Variance']
- for c in col:
- n = str(name) and ' (' + str(name) +')' or ''
- colnames.append(str(c) + n )
- coltypes.append('Currency')
- colwidths.append('150px')
- coloptions.append('')
- col_idx[str(c) + n ] = len(colnames) - 1
-
-
-
-
-# get start date
-start_date = webnotes.conn.get_value('Fiscal Year', fiscal_year, 'year_start_date')
-if not start_date:
- msgprint("Please Define Year Start Date for Fiscal Year " + str(fiscal_year))
- raise Exception
-start_date = start_date.strftime('%Y-%m-%d')
-
-# make month list and columns
-make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx)
-
-
-bc_obj = get_obj('Budget Control')
-for r in res:
-
- count = 0
-
- for idx in range(3, len(colnames), 3):
-
- cidx = 2
- # ================= Calculate Target ==========================================
- r.append(bc_obj.get_monthly_budget(r[cidx], fiscal_year, mon_list[count][data['start_date']], mon_list[count][data['end_date']], r[cidx-1]))
-
- #================== Actual Amount =============================================
- actual = 0
-
-
- #----------------------------------------------------------
- if target_on == "Quantity":
-
- actual = sql("select sum(ifnull(t2.qty,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Item` t2, `tabSales Team` t3 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t2.item_group = '%s' and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, under, based_on_fn, sales_person, r[0].strip(), date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
-
- #----------------------------------------------------------
- if target_on == "Amount":
-
- actual = sql("select sum(ifnull(t2.amount,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Item` t2, `tabSales Team` t3 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t2.item_group = '%s' and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, under, based_on_fn, sales_person, r[0].strip(), date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
- #----------------------------------------------------------
-
- actual = actual and flt(actual[0][0]) or 0
- r.append(actual)
- # ================ Variance ===================================================
-
- r.append(r[idx] - r[idx + 1])
-
- count = count +1
diff --git a/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.txt b/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.txt
deleted file mode 100644
index 55351829ff4..00000000000
--- a/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "parent_doc_type": "Sales Person",
- "module": "Selling",
- "doctype": "Search Criteria",
- "sort_order": "DESC",
- "filters": "{'Sales Person\u0001Country':'','Sales Person\u0001State':'','Target Detail\u0001Fiscal Year':''}",
- "standard": "Yes",
- "doc_type": "Target Detail",
- "name": "__common__",
- "sort_by": "`tabTarget Detail`.`target_amount`",
- "page_len": 50,
- "criteria_name": "Sales Persons Target Variance (Item Group wise)"
- },
- {
- "name": "sales_persons_target_variance_item_group_wise",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/sales_personwise_transaction_summary/__init__.py b/selling/search_criteria/sales_personwise_transaction_summary/__init__.py
deleted file mode 100755
index baffc488252..00000000000
--- a/selling/search_criteria/sales_personwise_transaction_summary/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.js b/selling/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.js
deleted file mode 100755
index 79dd9d5faf0..00000000000
--- a/selling/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.js
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.hide_all_filters();
-
- //Add filter
- this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice', report_default:'Sales Order', ignore : 1,parent:'Sales Person', single_select :1, in_first_page:1});
- this.add_filter({fieldname:'transaction_date', label:'Date', fieldtype:'Date', options:'', ignore : 1,parent:'Sales Person', in_first_page:1});
- this.add_filter({fieldname:'voucher_id', label:'Voucher Id', fieldtype:'Data', options:'', ignore : 1,parent:'Sales Person', in_first_page:1});
- this.add_filter({fieldname:'territory', label:'Territory', fieldtype:'Link', options:'Territory', ignore : 1,parent:'Sales Person', in_first_page:1});
- this.add_filter({fieldname:'sales_person', label:'Sales Person', fieldtype:'Link', options:'Sales Person', ignore : 1,parent:'Sales Person', in_first_page:1});
-}
-
-// hide sections
-this.mytabs.items['More Filters'].hide();
-this.mytabs.items['Select Columns'].hide();
-
-// Get query
-report.get_query = function() {
- based_on = this.get_filter('Sales Person', 'Based On').get_value();
- from_date = this.get_filter('Sales Person', 'From Date').get_value();
- to_date = this.get_filter('Sales Person', 'To Date').get_value();
- vid = this.get_filter('Sales Person', 'Voucher Id').get_value();
- terr = this.get_filter('Sales Person', 'Territory').get_value();
- sp = this.get_filter('Sales Person', 'Sales Person').get_value();
-
- date_fld = 'transaction_date';
- if(based_on == 'Sales Invoice' || based_on == "Delivery Note") date_fld = 'posting_date';
-
- sp_cond = '';
- if (from_date) sp_cond += ' AND t1.' + date_fld + '>= "' + from_date + '"';
- if (to_date) sp_cond += ' AND t1.' + date_fld + '<= "' + to_date + '"';
- if (vid) sp_cond += ' AND t1.name LIKE "%' + vid + '%"';
- if (terr) sp_cond += ' AND t1.territory = "' + terr + '"';
- if (sp) sp_cond += ' AND t2.sales_person = "' + sp + '"';
-
- return 'SELECT t1.`name`, t1.`customer_name`, t1.`territory`, t1.`' + date_fld + '`, t1.`net_total`, t1.`grand_total`, t2.`sales_person`, t2.`allocated_percentage`, t2.`allocated_amount` FROM `tab' + based_on + '` t1, `tabSales Team` t2 WHERE t1.docstatus=1 AND t2.`parenttype` = "' + based_on + '" AND t2.`parent` = t1.`name`' + sp_cond + ' ORDER BY t1.`name` DESC';
-}
-
diff --git a/selling/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.py b/selling/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.py
deleted file mode 100755
index 632e5459052..00000000000
--- a/selling/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-from __future__ import unicode_literals
-if filter_values.get('based_on') == 'Sales Invoice':
- based_on_dt = 'Sales Invoice'
-else:
- based_on_dt = filter_values.get('based_on')
-
-cols = [[filter_values.get('based_on'), 'Link','150px', based_on_dt], ['Customer', 'Link','150px','Customer'], ['Territory', 'Link','120px','Territory'], ['Transaction Date', 'Date', '120px', ''], ['Net Total', 'Currency', '80px', ''], ['Grand Total', 'Currency', '80px', ''], ['Sales Person', 'Link', '150px', 'Sales Person'], ['% Contribution', 'Currency', '120px', ''], ['Contribution Amt', 'Currency', '120px', '']]
-
-for c in cols:
- colnames.append(c[0])
- coltypes.append(c[1])
- colwidths.append(c[2])
- coloptions.append(c[3])
- col_idx[c[0]] = len(colnames)-1
diff --git a/selling/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.txt b/selling/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.txt
deleted file mode 100755
index 5f299815d7d..00000000000
--- a/selling/search_criteria/sales_personwise_transaction_summary/sales_personwise_transaction_summary.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Sales Person\u0001Saved':1,'Sales Person\u0001Submitted':1,'Sales Person\u0001Country':'','Sales Person\u0001State':''}",
- "doctype": "Search Criteria",
- "doc_type": "Sales Person",
- "name": "__common__",
- "sort_by": "`tabSales Person`.`name`",
- "page_len": 50,
- "criteria_name": "Sales Personwise Transaction Summary",
- "columns": "Sales Person\u0001ID"
- },
- {
- "name": "sales_personwise_transaction_summary",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/serial_no_amc_expiring_this_month/__init__.py b/selling/search_criteria/serial_no_amc_expiring_this_month/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/serial_no_amc_expiring_this_month/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/serial_no_amc_expiring_this_month/serial_no_amc_expiring_this_month.txt b/selling/search_criteria/serial_no_amc_expiring_this_month/serial_no_amc_expiring_this_month.txt
deleted file mode 100644
index 463d077cce9..00000000000
--- a/selling/search_criteria/serial_no_amc_expiring_this_month/serial_no_amc_expiring_this_month.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Serial No\u0001Saved':1,'Serial No\u0001Submitted':1,'Serial No\u0001Status':'','Serial No\u0001Warranty Status':''}",
- "doc_type": "Serial No",
- "name": "__common__",
- "add_cond": "`tab Serial No`.month(amc_expiry_date)=month(now()) \n`tab Serial No`.year(amc_expiry_date)=year(now())",
- "doctype": "Search Criteria",
- "sort_by": "`tabSerial No`.`name`",
- "page_len": 50,
- "criteria_name": "Serial No-AMC expiring this month",
- "columns": "Serial No\u0001ID,Serial No\u0001Status,Serial No\u0001AMC Expiry Date,Serial No\u0001Customer Name"
- },
- {
- "name": "serial_no-amc_expiring_this_month",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/serial_no_warranty_expiring_this_month/__init__.py b/selling/search_criteria/serial_no_warranty_expiring_this_month/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/serial_no_warranty_expiring_this_month/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/serial_no_warranty_expiring_this_month/serial_no_warranty_expiring_this_month.txt b/selling/search_criteria/serial_no_warranty_expiring_this_month/serial_no_warranty_expiring_this_month.txt
deleted file mode 100644
index 05a9f0fce99..00000000000
--- a/selling/search_criteria/serial_no_warranty_expiring_this_month/serial_no_warranty_expiring_this_month.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:52",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:52"
- },
- {
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Serial No\u0001Saved':1,'Serial No\u0001Submitted':1,'Serial No\u0001Status':'Issued','Serial No\u0001Maintenance Status':''}",
- "doc_type": "Serial No",
- "name": "__common__",
- "add_cond": "`tab Serial No`.docstatus!=2\n`tab Serial No`.maintenance_status='Under Warranty'\n`tab Serial No`.status!='Scrapped'\n`tab Serial No`.status!='Not in Use'\n`tab Serial No`.month(ifnull(warranty_expiry_date,0)) = month(now()) \n`tab Serial No`.yearmonth(ifnull(warranty_expiry_date,0)) = year(now())",
- "doctype": "Search Criteria",
- "sort_by": "`tabSerial No`.`name`",
- "page_len": 50,
- "criteria_name": "Serial No-Warranty expiring this month",
- "columns": "Serial No\u0001ID,Serial No\u0001Status,Serial No\u0001Warranty Expiry Date,Serial No\u0001Customer Name"
- },
- {
- "name": "serial_no-warranty_expiring_this_month",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/target_variance_report/__init__.py b/selling/search_criteria/target_variance_report/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/target_variance_report/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/target_variance_report/target_variance_report.js b/selling/search_criteria/target_variance_report/target_variance_report.js
deleted file mode 100644
index cc8e03ed4ae..00000000000
--- a/selling/search_criteria/target_variance_report/target_variance_report.js
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.hide_all_filters();
- this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Cost Center'+NEWLINE+'Sales Person'+NEWLINE+'Sales Partner',report_default:'Cost Center',ignore : 1,parent:'Target Detail'});
- this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Target Detail'});
- this.add_filter({fieldname:'company', label:'Company', fieldtype:'Link', options:'Company',report_default:sys_defaults.company, ignore : 1, parent:'Target Detail'});
- this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Target Detail'});
- this.add_filter({fieldname:'group_by', label:'Group By', fieldtype:'Select', options:NEWLINE+'Item Group',ignore : 1, parent:'Target Detail'});
- this.add_filter({fieldname:'under', label:'Under',fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice',report_default:'Sales Order',ignore : 1, parent:'Target Detail'});
-
-}
-
-report.get_query = function() {
- group_by = '';
- group_by = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Group By'].get_value();
- based_on = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Based On'].get_value();
- sel_fields = '`tabTarget Detail`.parent AS "' + cstr(based_on)+'"';
- cond = ' and ifnull(`tabTarget Detail`.item_group, "") = ""'
- if (group_by == 'Item Group'){
- sel_fields = cstr(sel_fields) + ', `tabTarget Detail`.item_group';
- cond = ' and ifnull(`tabTarget Detail`.item_group,"") != ""'
- }
- sel_fields = cstr(sel_fields) + ', `tabTarget Detail`.target_amount, `tabTarget Detail`.distribution_id';
- var q = 'SELECT '+ cstr(sel_fields) +' FROM `tabTarget Detail` WHERE `tabTarget Detail`.parenttype = "' + cstr(based_on) + '"'+ cstr(cond);
- return q
-}
-
-this.mytabs.items['Select Columns'].hide();
\ No newline at end of file
diff --git a/selling/search_criteria/target_variance_report/target_variance_report.py b/selling/search_criteria/target_variance_report/target_variance_report.py
deleted file mode 100644
index 0c1411257ad..00000000000
--- a/selling/search_criteria/target_variance_report/target_variance_report.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# 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 .
-
-# validate Filters
-from __future__ import unicode_literals
-flt_dict = {'fiscal_year': 'Fiscal Year', 'period': 'Period', 'company':'Company', 'under' : 'Under', 'based_on' : 'Based On'}
-for f in flt_dict:
- if not filter_values.get(f):
- msgprint("Please Select " + cstr(flt_dict[f]))
- raise Exception
-
-# Get Values from fliters
-fiscal_year = filter_values.get('fiscal_year')
-period = filter_values.get('period')
-under = filter_values.get('under')
-based_on = filter_values.get('based_on')
-group_by = filter_values.get('group_by')
-
-# Set required field names
-based_on_fn = (based_on == 'Cost Center') and 'cost_center' or (based_on == 'Sales Partner') and 'sales_partner' or (based_on == 'Sales Person') and 'sales_person'
-date_fn = (under == 'Sales Order' ) and 'transaction_date' or 'posting_date'
-
-mon_list = []
-data = {'start_date':0, 'end_date':1}
-
-def make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx):
- count = 1
- if period == 'Quarterly' or period == 'Half Yearly' or period == 'Annual': mon_list.append([str(start_date)])
- for m in range(12):
- # get last date
- last_date = str(sql("select LAST_DAY('%s')" % start_date)[0][0])
-
- # make mon_list for Monthly Period
- if period == 'Monthly' :
- mon_list.append([start_date, last_date])
- # add months as Column names
- month_name = sql("select MONTHNAME('%s')" % start_date)[0][0]
- append_colnames(str(month_name)[:3], colnames, coltypes, colwidths, coloptions, col_idx)
-
- # get start date
- start_date = str(sql("select DATE_ADD('%s',INTERVAL 1 DAY)" % last_date)[0][0])
-
- # make mon_list for Quaterly Period
- if period == 'Quarterly' and count % 3 == 0:
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column names
- append_colnames('Q '+ str(count / 3), colnames, coltypes, colwidths, coloptions, col_idx)
- if count != 12: mon_list.append([start_date])
-
- # make mon_list for Half Yearly Period
- if period == 'Half Yearly' and count % 6 == 0 :
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column Names
- append_colnames('H'+str(count / 6), colnames, coltypes, colwidths, coloptions, col_idx)
- if count != 12: mon_list.append([start_date])
-
- # make mon_list for Annual Period
- if period == 'Annual' and count % 12 == 0:
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column Names
- append_colnames('', colnames, coltypes, colwidths, coloptions, col_idx)
- count = count +1
-
-def append_colnames(name, colnames, coltypes, colwidths, coloptions, col_idx):
- col = ['Budget', 'Actual', 'Variance']
- for c in col:
- colnames.append(str(c) + ' (' + str(name) +')' )
- coltypes.append('Currency')
- colwidths.append('150px')
- coloptions.append('')
- col_idx[str(c) + ' (' + str(name) +')' ] = len(colnames) - 1
-
-# make default columns
-coltypes[col_idx[based_on]] = 'Link'
-coloptions[col_idx[based_on]]= based_on
-
-# get start date
-start_date = webnotes.conn.get_value('Fiscal Year', fiscal_year, 'year_start_date')
-if not start_date:
- msgprint("Please Define Year Start Date for Fiscal Year " + str(fiscal_year))
- raise Exception
-start_date = start_date.strftime('%Y-%m-%d')
-
-# make month list and columns
-make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx)
-
-bc_obj = get_obj('Budget Control')
-for r in res:
- count = 0
- for idx in range((group_by == 'Item Group') and 4 or 3, len(colnames), 3):
- cidx = (group_by == 'Item Group') and 3 or 2
- # ================= Calculate Target ==========================================
- r.append(bc_obj.get_monthly_budget( r[cidx], fiscal_year, mon_list[count][data['start_date']], mon_list[count][data['end_date']], r[cidx-1]))
-
- #================== Actual Amount =============================================
- actual = 0
- if based_on == 'Cost Center' or based_on == 'Sales Partner':
- if group_by =='Item Group':
- actual = sql("select sum(ifnull(t2.amount,0)) from `tab%s` t1, `tab%s Detail` t2, `tabItem` t3 where t2.parenttype = '%s' and t2.parent = t1.name and t1.%s = '%s' and t3.name = t2.item_code and t3.item_group = '%s' and t1.docstatus = 1 and t1.%s between '%s' and '%s'" % (under, (under == 'Sales Invoice') and 'RV' or under, under, based_on_fn, r[0], r[1], date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
- actual = flt(actual[0][0])
- else:
- actual = sql("select sum(ifnull(net_total,0)) from `tab%s` where %s = '%s' and docstatus = 1 and %s between '%s' and '%s' " % (under, based_on_fn, r[0], date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
- actual = flt(actual[0][0])
- elif based_on == 'Sales Person':
- if group_by =='Item Group':
- actual = sql("select sum(ifnull(t2.amount,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3, `tabItem` t4 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t4.name = t2.item_code and t4.item_group = '%s' and t1.docstatus != 2 and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, (under == 'Sales Invoice') and 'RV' or under, based_on_fn, r[0], r[1], date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
- actual = flt(actual[0][0])
- else:
- actual = sql("select sum(ifnull(t2.allocated_amount,0)) from `tab%s` t1, `tabSales Team` t2 where t2.%s = '%s' and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and t1.%s between '%s' and '%s'"%(under, based_on_fn, r[0], under, date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
- actual = flt(actual[0][0])
- r.append(actual)
- # ================ Variance ===================================================
- r.append(r[idx] - r[idx + 1])
- count = count +1
\ No newline at end of file
diff --git a/selling/search_criteria/target_variance_report/target_variance_report.txt b/selling/search_criteria/target_variance_report/target_variance_report.txt
deleted file mode 100644
index c89236632ba..00000000000
--- a/selling/search_criteria/target_variance_report/target_variance_report.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "harshada@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:53",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:53"
- },
- {
- "parent_doc_type": "Sales Person",
- "module": "Selling",
- "standard": "Yes",
- "disabled": 0,
- "sort_order": "DESC",
- "filters": "{'Sales Person\u0001Saved':1,'Sales Person\u0001Submitted':1,'Sales Person\u0001Country':'','Sales Person\u0001State':'','Target Detail\u0001Fiscal Year':''}",
- "doc_type": "Target Detail",
- "name": "__common__",
- "doctype": "Search Criteria",
- "page_len": 50,
- "criteria_name": "Target Variance Report",
- "columns": "Sales Person\u0001ID,Sales Person\u0001Owner,Sales Person\u0001Sales Person,Sales Person\u0001Country,Sales Person\u0001State,Target Detail\u0001Item Group,Target Detail\u0001Fiscal Year,Target Detail\u0001Target Amount"
- },
- {
- "name": "target_variance_report",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/territories_target_variance_item_group_wise/__init__.py b/selling/search_criteria/territories_target_variance_item_group_wise/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/territories_target_variance_item_group_wise/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.js b/selling/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.js
deleted file mode 100644
index d7dcf703912..00000000000
--- a/selling/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.js
+++ /dev/null
@@ -1,61 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
-
- this.hide_all_filters();
-
- this.add_filter({fieldname:'territory', label:'Territory', fieldtype:'Link', options:'Territory',ignore : 1,parent:'Target Detail'});
-
- this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Target Detail'});
-
- this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Target Detail'});
-
- this.add_filter({fieldname:'under', label:'Under',fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice',report_default:'Sales Order',ignore : 1, parent:'Target Detail'});
-
- this.add_filter({fieldname : 'target_on', label:'Target On', fieldtype:'Select', options:'Quantity'+NEWLINE+'Amount',report_default:'Quantity',ignore : 1,parent:'Target Detail'});
- this.filter_fields_dict['Target Detail'+FILTER_SEP +'Territory'].df.in_first_page = 1;
-}
-this.mytabs.items['Select Columns'].hide();
-report.get_query = function() {
-
- territory = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Territory'].get_value();
- target_on = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Target On'].get_value();
- under = this.filter_fields_dict['Target Detail'+FILTER_SEP+'Under'].get_value();
- if(under == 'Sales Invoice') under = 'Sales Invoice';
-
- if(target_on == 'Quantity'){
- q1 = 't1.target_qty AS "Target Quantity"';
- q2 = '0 AS "Target Quantity"';
- cond1 = 'ifnull(t1.target_qty,"")!=""';
- cond2 = 'ifnull(t5.target_qty,"")!=""';
- }
- else{
- q1 = 't1.target_amount AS "Target Amount"';
- q2 = '0 AS "Target Amount"';
- cond1 = 'ifnull(t1.target_amount,"")!=""';
- cond2 = 'ifnull(t5.target_amount,"")!=""';
- }
- if(under =='Sales Invoice')
- tab = 'RV';
- else
- tab = under;
-
- var q ='SELECT distinct t1.item_group AS "Item Group", '+q1+', t2.distribution_id AS "Distribution Id" FROM `tabTarget Detail` t1, `tabTerritory` t2 WHERE t1.parenttype = "Territory" AND t1.parent = "'+territory+'" AND t1.parent=t2.name AND ifnull(t1.item_group,"")!="" AND '+cond1+' UNION SELECT distinct t3.item_group AS "Item Group", '+q2+',"" AS "Distribution Id" FROM `tab'+tab+' Detail` t3,`tab'+under+'` t4 where t3.item_group NOT IN (SELECT t5.item_group FROM `tabTarget Detail` t5, `tabTerritory` t6 WHERE t5.parenttype = "Territory" AND t5.parent = "'+territory+'" AND t5.parent=t6.name AND '+cond2+') AND t4.territory = "'+territory+'" AND t3.parent = t4.name AND t4.docstatus = 1';
-
- return q;
-
-}
\ No newline at end of file
diff --git a/selling/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.py b/selling/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.py
deleted file mode 100644
index 17acb478a59..00000000000
--- a/selling/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.py
+++ /dev/null
@@ -1,144 +0,0 @@
-# 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 .
-
-# validate Filters
-from __future__ import unicode_literals
-flt_dict = {'fiscal_year': 'Fiscal Year', 'period': 'Period', 'under' : 'Under', 'territory':'Territory', 'target_on':'Target On'}
-for f in flt_dict:
- if not filter_values.get(f):
- msgprint("Please Select " + cstr(flt_dict[f]))
- raise Exception
-
-# Get Values from fliters
-fiscal_year = filter_values.get('fiscal_year')
-period = filter_values.get('period')
-under = filter_values.get('under')
-if under == 'Sales Invoice': under = 'Sales Invoice'
-territory = filter_values.get('territory')
-target_on = filter_values.get('target_on')
-
-
-# Set required field names
-based_on_fn = 'territory'
-
-date_fn = (under == 'Sales Order' ) and 'transaction_date' or 'posting_date'
-
-mon_list = []
-
-data = {'start_date':0, 'end_date':1}
-
-def make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx):
- count = 1
- if period == 'Quarterly' or period == 'Half Yearly' or period == 'Annual': mon_list.append([str(start_date)])
- for m in range(12):
- # get last date
- last_date = str(sql("select LAST_DAY('%s')" % start_date)[0][0])
-
- # make mon_list for Monthly Period
- if period == 'Monthly' :
- mon_list.append([start_date, last_date])
- # add months as Column names
- month_name = sql("select MONTHNAME('%s')" % start_date)[0][0]
- append_colnames(str(month_name)[:3], colnames, coltypes, colwidths, coloptions, col_idx)
-
- # get start date
- start_date = str(sql("select DATE_ADD('%s',INTERVAL 1 DAY)" % last_date)[0][0])
-
- # make mon_list for Quaterly Period
- if period == 'Quarterly' and count % 3 == 0:
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column names
- append_colnames('Q '+ str(count / 3), colnames, coltypes, colwidths, coloptions, col_idx)
- if count != 12: mon_list.append([start_date])
-
- # make mon_list for Half Yearly Period
- if period == 'Half Yearly' and count % 6 == 0 :
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column Names
- append_colnames('H'+str(count / 6), colnames, coltypes, colwidths, coloptions, col_idx)
- if count != 12: mon_list.append([start_date])
-
- # make mon_list for Annual Period
- if period == 'Annual' and count % 12 == 0:
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column Names
- append_colnames('', colnames, coltypes, colwidths, coloptions, col_idx)
- count = count +1
-
-def append_colnames(name, colnames, coltypes, colwidths, coloptions, col_idx):
- col = ['Target', 'Actual', 'Variance']
- for c in col:
- n = str(name) and ' (' + str(name) +')' or ''
- colnames.append(str(c) + n )
- coltypes.append('Currency')
- colwidths.append('150px')
- coloptions.append('')
- col_idx[str(c) + n ] = len(colnames) - 1
-
-
-
-# make default columns
-#coltypes[col_idx['Item Group']] = 'Link'
-#coloptions[col_idx['Item Group']]= 'Sales '
-
-# get start date
-start_date = webnotes.conn.get_value('Fiscal Year', fiscal_year, 'year_start_date')
-if not start_date:
- msgprint("Please Define Year Start Date for Fiscal Year " + str(fiscal_year))
- raise Exception
-start_date = start_date.strftime('%Y-%m-%d')
-
-# make month list and columns
-make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx)
-
-
-
-bc_obj = get_obj('Budget Control')
-for r in res:
-
- count = 0
-
- for idx in range(3, len(colnames), 3):
-
- cidx = 2
- # ================= Calculate Target ==========================================
- r.append(bc_obj.get_monthly_budget(r[cidx], fiscal_year, mon_list[count][data['start_date']], mon_list[count][data['end_date']], r[cidx-1]))
-
- #================== Actual Amount =============================================
- actual = 0
-
-
-
- #----------------------------------------------------------
- if target_on == "Quantity":
-
- actual = sql("select sum(ifnull(t2.qty,0)) from `tab%s` t1, `tab%s Detail` t2 where t2.parenttype = '%s' and t2.parent = t1.name and t1.%s = '%s' and t1.docstatus = 1 and t2.item_group = '%s' and t1.%s between '%s' and '%s'" % (under, (under == 'Sales Invoice') and 'RV' or under, under, based_on_fn, territory, r[0],date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
-
-
- #----------------------------------------------------------
- if target_on == "Amount":
-
- actual = sql("select sum(ifnull(t2.amount,0)) from `tab%s` t1, `tab%s Detail` t2 where t2.parenttype = '%s' and t2.parent = t1.name and t1.%s = '%s' and t1.docstatus = 1 and t2.item_group = '%s' and t1.%s between '%s' and '%s'" % (under, (under == 'Sales Invoice') and 'RV' or under, under, based_on_fn, territory, r[0],date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
-
- #----------------------------------------------------------
-
- actual = actual and flt(actual[0][0]) or 0
- r.append(actual)
- # ================ Variance ===================================================
-
- r.append(r[idx] - r[idx + 1])
-
- count = count +1
\ No newline at end of file
diff --git a/selling/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.txt b/selling/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.txt
deleted file mode 100644
index a64b47e915f..00000000000
--- a/selling/search_criteria/territories_target_variance_item_group_wise/territories_target_variance_item_group_wise.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:53",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:53"
- },
- {
- "parent_doc_type": "Sales Person",
- "module": "Selling",
- "doctype": "Search Criteria",
- "sort_order": "DESC",
- "filters": "{'Sales Person\u0001Country':'','Sales Person\u0001State':'','Target Detail\u0001Fiscal Year':''}",
- "standard": "Yes",
- "doc_type": "Target Detail",
- "name": "__common__",
- "sort_by": "`tabTarget Detail`.`target_amount`",
- "page_len": 50,
- "criteria_name": "Territories Target Variance (Item Group wise)"
- },
- {
- "name": "territories_target_variance_item_group_wise",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/territory_sales___variance_report/__init__.py b/selling/search_criteria/territory_sales___variance_report/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/territory_sales___variance_report/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/territory_sales___variance_report/territory_sales___variance_report.js b/selling/search_criteria/territory_sales___variance_report/territory_sales___variance_report.js
deleted file mode 100644
index aabd4e179e4..00000000000
--- a/selling/search_criteria/territory_sales___variance_report/territory_sales___variance_report.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice',report_default:'Sales Order',ignore : 1, parent:'Territory'});
- this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Territory'});
- this.add_filter({fieldname:'company', label:'Company', fieldtype:'Link', options:'Company',report_default:sys_defaults.company, ignore : 1, parent:'Territory'});
- this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Territory'});
-}
\ No newline at end of file
diff --git a/selling/search_criteria/territory_sales___variance_report/territory_sales___variance_report.py b/selling/search_criteria/territory_sales___variance_report/territory_sales___variance_report.py
deleted file mode 100644
index e9e40aa6140..00000000000
--- a/selling/search_criteria/territory_sales___variance_report/territory_sales___variance_report.py
+++ /dev/null
@@ -1,205 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-from __future__ import unicode_literals
-if filter_values.get('period'):
- period_values = filter_values['period']
- if len(period_values.split(NEWLINE))>1:
- msgprint("You can view report only for one period. Please select only one value in period.")
- raise Exception
- else:
- period = period_values.split(NEWLINE)[0]
-
-if filter_values.get('based_on'):
- based_on = filter_values['based_on']
- if len(based_on.split(NEWLINE)) > 1:
- msgprint("You can view report based on only one criteria. Please select only one value in Based On.")
- raise Exception
- else:
- based_on = based_on.split(NEWLINE)[0]
-
-if not filter_values.get('fiscal_year'):
- msgprint("Please Select Fiscal Year")
- raise Exception
-elif not filter_values.get('period'):
- msgprint("Please Select Period")
- raise Exception
-elif not filter_values.get('based_on'):
- msgprint("Please Select the Criteria on which you want your report to be based")
- raise Exception
-
-fiscal_year = filter_values.get('fiscal_year')
-
-# get fiscal year start date and start month
-# ---------------------------------------------------------
-year_start_date = sql("select year_start_date,MONTH(year_start_date) from `tabFiscal Year` where name = %s",fiscal_year)
-start_date = year_start_date and year_start_date[0][0] or ''
-start_month = year_start_date and year_start_date[0][1] or ''
-month_name = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
-
-# Add columns based on period
-# --------------------------------
-columns = []
-# ================ Annual ======================
-if period == 'Annual':
- columns.append(['Target','Currency','120px',''])
- columns.append(['Actual','Currency','120px',''])
-
-# =========== Half Yearly ======================
-elif period == 'Half Yearly':
- columns.append(['Target (H1)','Currency','120px','']) # first half
- columns.append(['Actual (H1)','Currency','120px','']) # first half
- if start_month == 1: # this is case when fiscal year starts with JAN
- columns.append(['Target (H2)','Currency','120px',''])
- columns.append(['Actual (H2)','Currency','120px',''])
- else: #this is case when fiscal year starts with other than JAN
- columns.append(['Target (H2)','Currency','120px',''])
- columns.append(['Actual (H2)','Currency','120px',''])
-
-# ================ Quarterly ===================
-elif period == 'Quarterly':
- length_1 = (len(month_name) - start_month + 1) / 3 #this gives the total no. of times we need to iterate for quarter
- val = length_1 % 4
- q_no = 1
- for i in range(length_1):
- value = 3*i + val
- columns.append(['Target (Q'+cstr(q_no)+')','Currency','120px',''])
- columns.append(['Actual (Q'+cstr(q_no)+')','Currency','120px',''])
- q_no += 1
- length_2 = (start_month - 1) / 3 #this gives the total no. of times we need to iterate for quarter (this is required only if fiscal year starts from april)
- for i in range(length_2):
- columns.append(['Target (Q'+cstr(q_no)+')','Currency','120px',''])
- columns.append(['Actual (Q'+cstr(q_no)+')','Currency','120px',''])
- q_no += 1;
-
-
-# =============== Monthly ======================
-elif period == 'Monthly':
- for i in range(start_month-1,len(month_name)):
- columns.append(['Target ('+month_name[i]+')','Currency','120px',''])
- columns.append(['Actual ('+month_name[i]+')','Currency','120px',''])
-
- for i in range(start_month-1):
- columns.append(['Target('+month_name[i]+')','Currency','120px',''])
- columns.append(['Actual ('+month_name[i]+')','Currency','120px',''])
-
-
-
-for c in columns:
- colnames.append(c[0])
- coltypes.append(c[1])
- colwidths.append(c[2])
- coloptions.append(c[3])
- col_idx[c[0]] = len(colnames)-1
-
-
-condition = ' docstatus = 1 and fiscal_year = "'+fiscal_year+'"'
-
-
-for r in res:
- query = ''
-
- # ================= Annual Report ===============
- if period == 'Annual':
-
- target = sql("select sum(target_amount) from `tabTarget Detail` where parent = %s and parenttype= 'Territory' and fiscal_year = %s ",(r[col_idx['ID']],fiscal_year))
- target = target and flt(target[0][0]) or 0
- r.append(target)
-
-
- so = sql("select sum(net_total) from `tab%s` where territory = '%s' and %s" % (based_on, r[col_idx['ID']],condition))
- so = so and flt(so[0][0]) or 0
- r.append(so)
-
- # ================= Half Yearly Report ===============
- elif period == 'Half Yearly':
- target = sql("select sum(target_amount) from `tabTarget Detail` where parent = %s and parenttype= 'Territory' and fiscal_year = %s",(r[col_idx['ID']],fiscal_year))
- target = target and flt(flt(target[0][0])/2) or 0
- r.append(target)
-
- query += ' MONTH(transaction_date) BETWEEN '+cstr(start_month)+' and '+cstr(start_month+5)
- so = sql("select sum(net_total) from `tab%s` where territory = '%s' and %s and %s" % (based_on, r[col_idx['ID']],condition,query))
- so = so and flt(so[0][0]) or 0
- r.append(so)
-
- r.append(target)
-
- query =''
- query += 'MONTH(transaction_date) NOT BETWEEN '+cstr(start_month)+' and '+cstr(start_month+5)
- so = sql("select sum(net_total) from `tab%s` where territory = '%s' and %s and %s" % (based_on, r[col_idx['ID']],condition,query))
- so = so and flt(so[0][0]) or 0
- r.append(so)
- query = ''
-
- # =============== Quarterly Report ==============
- elif period == 'Quarterly':
- query = ''
- length_1 = (len(month_name) - start_month + 1) / 3; #this gives the total no. of times we need to iterate for quarter
- val = length_1 % 4;
- for i in range(length_1):
- value = 3*i + val;
- query +='SUM(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN net_total ELSE NULL END),'
- length_2 = (start_month - 1) / 3; #this gives the total no. of times we need to iterate for quarter (this is required only if fiscal year starts from april)
- for i in range(length_2):
- query += 'SUM(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN net_total ELSE NULL END)';
-
- target = sql("select sum(target_amount) from `tabTarget Detail` where parent = %s and parenttype= 'Territory' and fiscal_year = %s",(r[col_idx['ID']],fiscal_year))
- target = target and flt(flt(target[0][0])/4) or 0
-
-
- so = sql("SELECT %s from `tab%s` where territory ='%s' and %s " %(query,based_on,r[col_idx['ID']],condition))
- i = 0
- length_l = 0
- for c in columns:
- if length_l == 0:
- r.append(target)
- length_l += 1
- else:
- so_total = so and flt(so[0][i]) or 0
- r.append(so_total)
- i +=1
- length_l = 0
-
- # ================ Monthly Report ===============
- elif period == 'Monthly':
- query =''
- target = sql("select sum(target_amount) from `tabTarget Detail` where parent = %s and parenttype= 'Territory' and fiscal_year = %s",(r[col_idx['ID']],fiscal_year))
- #msgprint(target)
- target = target and flt(flt(target[0][0])/12) or 0
-
-
- # for loop is required twice coz fiscal year starts from April (this will also work if fiscal year starts in January)
- for i in range(start_month-1,len(month_name)):
- query += 'SUM(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END),'
-
- for i in range(start_month-1):
- if i != (start_month-2):
- query += 'SUM(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END),'
- else:
- query += 'SUM(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END)';
- so = sql("SELECT %s from `tab%s` where territory ='%s' and %s " %(query,based_on,r[col_idx['ID']],condition))
-
- i = 0
- length_l = 0
- for c in columns:
- if length_l == 0:
- r.append(target)
- length_l += 1
- else:
- so_total = so and flt(so[0][i]) or 0
- r.append(so_total)
- i +=1
- length_l = 0
\ No newline at end of file
diff --git a/selling/search_criteria/territory_sales___variance_report/territory_sales___variance_report.txt b/selling/search_criteria/territory_sales___variance_report/territory_sales___variance_report.txt
deleted file mode 100644
index 011b957818a..00000000000
--- a/selling/search_criteria/territory_sales___variance_report/territory_sales___variance_report.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:53",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:53"
- },
- {
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Territory\u0001State':'','Territory\u0001Based On':'Sales Order','Territory\u0001Fiscal Year':'2009-2010','Territory\u0001Company':'Alpha Company','Territory\u0001Period':'Quarterly'}",
- "doctype": "Search Criteria",
- "doc_type": "Territory",
- "name": "__common__",
- "sort_by": "ID",
- "page_len": 50,
- "criteria_name": "Territory Sales - Variance Report",
- "columns": "Territory\u0001ID"
- },
- {
- "name": "territory_sales_-_variance_report",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/total_target_variance_report/__init__.py b/selling/search_criteria/total_target_variance_report/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/total_target_variance_report/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/total_target_variance_report/total_target_variance_report.js b/selling/search_criteria/total_target_variance_report/total_target_variance_report.js
deleted file mode 100644
index 59a9b89871a..00000000000
--- a/selling/search_criteria/total_target_variance_report/total_target_variance_report.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.hide_all_filters();
- this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Territory'+NEWLINE+'Sales Person',report_default:'Territory',ignore : 1,parent:'Target Detail', single_select :1});
- this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Target Detail'});
- this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Target Detail', single_select :1});
- this.add_filter({fieldname:'under', label:'Under',fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice',report_default:'Sales Order',ignore : 1, parent:'Target Detail', single_select :1});
- this.add_filter({fieldname : 'target_on', label:'Target On', fieldtype:'Select', options:'Quantity'+NEWLINE+'Amount',report_default:'Quantity',ignore : 1,parent:'Target Detail', single_select :1});
-}
-report.aftertableprint = function(t) {
- $yt(t,'*',1,{whiteSpace:'pre'});
-}
-this.mytabs.items['Select Columns'].hide();
\ No newline at end of file
diff --git a/selling/search_criteria/total_target_variance_report/total_target_variance_report.py b/selling/search_criteria/total_target_variance_report/total_target_variance_report.py
deleted file mode 100644
index 954f9f2fc3b..00000000000
--- a/selling/search_criteria/total_target_variance_report/total_target_variance_report.py
+++ /dev/null
@@ -1,223 +0,0 @@
-# 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 .
-
-# validate Filters
-from __future__ import unicode_literals
-flt_dict = {'fiscal_year': 'Fiscal Year', 'period': 'Period', 'under' : 'Under', 'based_on' : 'Based On','target_on':'Target On'}
-for f in flt_dict:
- if not filter_values.get(f):
- msgprint("Please Select " + cstr(flt_dict[f]))
- raise Exception
-
-# Get Values from fliters
-fiscal_year = filter_values.get('fiscal_year')
-period = filter_values.get('period')
-under = filter_values.get('under')
-if under == 'Sales Invoice': under = 'Sales Invoice'
-based_on = filter_values.get('based_on')
-target_on = filter_values.get('target_on')
-
-#add distributed id field
-col = []
-col.append([based_on,'Date','150px',''])
-if target_on == 'Quantity':
- col.append(['Target Quantity','Currency','150px',''])
-else:
- col.append(['Target Amount','Currency','150px',''])
-col.append(['Distribution Id','Date','150px',''])
-
-for c in col:
- colnames.append(c[0])
- coltypes.append(c[1])
- colwidths.append(c[2])
- coloptions.append(c[3])
-
- col_idx[c[0]] = len(colnames)-1
-
-def make_child_lst(based_on,name):
- rg = sql("select lft, rgt from `tab%s` where name = '%s'"%(based_on,name))
- ch_name = sql("select name from `tab%s` where lft between %d and %d"%(based_on,int(rg[0][0]),int(rg[0][1])))
- chl ='('
- flag = 1
- for c in ch_name:
- if flag == 1:
- chl += "'%s'"%c[0]
- flag = 2
- else:
- chl +=",'%s'"%c[0]
-
- chl +=")"
- return chl
-
-
-def get_target(target_on,based_on,fiscal_year,r):
-
- if target_on == 'Quantity':
- q1 = "select t1.target_qty "
- q2 = "select sum(t1.target_qty)"
- if target_on == 'Amount':
- q1 = "select t1.target_amount "
- q2 = "select sum(t1.target_amount)"
-
- cond1 =" t1.fiscal_year ='%s' and t1.parent=t2.name and t1.parenttype = '%s' and t1.docstatus !=2"
- #----------------------------------------------------------------
- q = "select t1.name from `tabTarget Detail` t1, `tab%s` t2 where "+cond1+" and t2.name = '%s'"
- ch = sql(q%(based_on,fiscal_year,based_on,r))
-
- return {'q1':q1,'q2':q2,'cond1':cond1,'ch':ch}
-
-for r in res:
-
- tt = get_target(target_on,based_on,fiscal_year,r[0].strip())
-
- if tt['ch']:
-
- cond2 = " ifnull(t1.item_group,'')='' and"
- qur = tt['q1']+"from `tabTarget Detail` t1, `tab%s` t2 where "+cond2+tt['cond1']+" and t2.name = '%s'"
- ret_amt = sql(qur%(based_on,fiscal_year,based_on,r[0].strip()))
-
- #----------------------------------------------------------------
- if not ret_amt:
- qur = tt['q2']+"from `tabTarget Detail` t1, `tab%s` t2 where "+tt['cond1']+" and t2.name = '%s'"
- ret_amt = sql(qur%(based_on,fiscal_year,based_on,r[0].strip()))
-
- #----------------------------------------------------------------
- else:
- node_lst = make_child_lst(based_on,r[0].strip())
- qur = tt['q2']+"from `tabTarget Detail` t1, `tab%s` t2 where "+tt['cond1']+" and t2.name in %s"
- ret_amt = sql(qur%(based_on,fiscal_year,based_on,node_lst))
-
- #----------------------------------------------------------------
- ret_dis_id = sql("select distribution_id from `tab%s` where name = '%s'"%(based_on,r[0].strip()))
-
- target_amt = ret_amt and flt(ret_amt[0][0]) or 0
- dis_id = ret_dis_id and ret_dis_id[0][0] or ''
-
- r.append(target_amt)
- r.append(dis_id)
-
-
-# Set required field names
-based_on_fn = (based_on == 'Territory') and 'territory' or 'sales_person'
-
-date_fn = (under == 'Sales Order' ) and 'transaction_date' or 'posting_date'
-
-mon_list = []
-
-data = {'start_date':0, 'end_date':1}
-
-def make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx):
- count = 1
- if period == 'Quarterly' or period == 'Half Yearly' or period == 'Annual': mon_list.append([str(start_date)])
- for m in range(12):
- # get last date
- last_date = str(sql("select LAST_DAY('%s')" % start_date)[0][0])
-
- # make mon_list for Monthly Period
- if period == 'Monthly' :
- mon_list.append([start_date, last_date])
- # add months as Column names
- month_name = sql("select MONTHNAME('%s')" % start_date)[0][0]
- append_colnames(str(month_name)[:3], colnames, coltypes, colwidths, coloptions, col_idx)
-
- # get start date
- start_date = str(sql("select DATE_ADD('%s',INTERVAL 1 DAY)" % last_date)[0][0])
-
- # make mon_list for Quaterly Period
- if period == 'Quarterly' and count % 3 == 0:
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column names
- append_colnames('Q '+ str(count / 3), colnames, coltypes, colwidths, coloptions, col_idx)
- if count != 12: mon_list.append([start_date])
-
- # make mon_list for Half Yearly Period
- if period == 'Half Yearly' and count % 6 == 0 :
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column Names
- append_colnames('H'+str(count / 6), colnames, coltypes, colwidths, coloptions, col_idx)
- if count != 12: mon_list.append([start_date])
-
- # make mon_list for Annual Period
- if period == 'Annual' and count % 12 == 0:
- mon_list[len(mon_list) - 1 ].append(last_date)
- # add Column Names
- append_colnames('', colnames, coltypes, colwidths, coloptions, col_idx)
- count = count +1
-
-def append_colnames(name, colnames, coltypes, colwidths, coloptions, col_idx):
- col = ['Target', 'Actual', 'Variance']
- for c in col:
- n = str(name) and ' (' + str(name) +')' or ''
- colnames.append(str(c) + n)
- coltypes.append('Currency')
- colwidths.append('150px')
- coloptions.append('')
- col_idx[str(c) + n ] = len(colnames) - 1
-
-
-
-# make default columns
-#coltypes[col_idx[based_on]] = 'Link'
-#coloptions[col_idx[based_on]]= based_on
-
-# get start date
-start_date = webnotes.conn.get_value('Fiscal Year', fiscal_year, 'year_start_date')
-if not start_date:
- msgprint("Please Define Year Start Date for Fiscal Year " + str(fiscal_year))
- raise Exception
-start_date = start_date.strftime('%Y-%m-%d')
-
-# make month list and columns
-make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx)
-
-
-bc_obj = get_obj('Budget Control')
-for r in res:
- count = 0
-
- for idx in range(3, len(colnames), 3):
- cidx = 2
-
- # ================= Calculate Target ==========================================
- r.append(bc_obj.get_monthly_budget( r[cidx], fiscal_year, mon_list[count][data['start_date']], mon_list[count][data['end_date']], r[cidx-1]))
-
- #================== Actual Amount =============================================
- actual = 0
-
- ch = make_child_lst(based_on,r[0].strip())
-
- #----------------------------------------------------------
- if target_on == "Quantity":
- if based_on == "Territory":
- actual = sql("select sum(ifnull(t2.qty,0)) from `tab%s` t1, `tab%s Detail` t2 where t2.parenttype = '%s' and t2.parent = t1.name and t1.%s in %s and t1.docstatus = 1 and t1.%s between '%s' and '%s'" % (under, (under == 'Sales Invoice') and 'RV' or under, under, based_on_fn, ch, date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
-
- elif based_on == 'Sales Person':
- actual = sql("select sum(ifnull(t2.qty,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3 where t2.parent = t1.name and t3.parent = t1.name and t3.%s in %s and t1.docstatus != 2 and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, (under == 'Sales Invoice') and 'RV' or under, based_on_fn, ch, date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
-
- #----------------------------------------------------------
- if target_on == "Amount":
- if based_on == 'Territory':
-
- actual = sql("select sum(ifnull(net_total,0)) from `tab%s` where %s in %s and docstatus = 1 and %s between '%s' and '%s' " % (under, based_on_fn, ch, date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
-
- elif based_on == 'Sales Person':
- actual = sql("select sum(ifnull(t2.allocated_amount,0)) from `tab%s` t1, `tabSales Team` t2 where t2.%s in %s and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and t1.%s between '%s' and '%s'"%(under, based_on_fn, ch, under, date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
- #----------------------------------------------------------
- actual = flt(actual[0][0])
- r.append(actual)
- # ================ Variance ===================================================
- r.append(r[idx] - r[idx + 1])
- count = count +1
\ No newline at end of file
diff --git a/selling/search_criteria/total_target_variance_report/total_target_variance_report.sql b/selling/search_criteria/total_target_variance_report/total_target_variance_report.sql
deleted file mode 100644
index ebd7ae845fe..00000000000
--- a/selling/search_criteria/total_target_variance_report/total_target_variance_report.sql
+++ /dev/null
@@ -1 +0,0 @@
-SELECT CONCAT(REPEAT(' ', COUNT(parent.name) - 1), node.name) AS name FROM `tab%(based_on)s` AS node,`tab%(based_on)s` AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt AND node.docstatus !=2 GROUP BY node.name ORDER BY node.lft
\ No newline at end of file
diff --git a/selling/search_criteria/total_target_variance_report/total_target_variance_report.txt b/selling/search_criteria/total_target_variance_report/total_target_variance_report.txt
deleted file mode 100644
index cf1484b479b..00000000000
--- a/selling/search_criteria/total_target_variance_report/total_target_variance_report.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:53",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:53"
- },
- {
- "parent_doc_type": "Sales Person",
- "module": "Selling",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Sales Person\u0001Saved':1,'Sales Person\u0001Submitted':1,'Sales Person\u0001Country':'','Sales Person\u0001State':'','Target Detail\u0001Fiscal Year':''}",
- "doc_type": "Target Detail",
- "name": "__common__",
- "doctype": "Search Criteria",
- "sort_by": "`tabSales Person`.`name`",
- "page_len": 50,
- "criteria_name": "Total Target Variance Report",
- "columns": "Sales Person\u0001ID,Sales Person\u0001Owner,Sales Person\u0001Sales Person,Sales Person\u0001Country,Sales Person\u0001State,Sales Person\u0001lft,Sales Person\u0001rgt,Target Detail\u0001Item Group,Target Detail\u0001Fiscal Year,Target Detail\u0001Target Amount"
- },
- {
- "name": "total_target_variance_report",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/selling/search_criteria/variance_report/__init__.py b/selling/search_criteria/variance_report/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/selling/search_criteria/variance_report/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/search_criteria/variance_report/variance_report.js b/selling/search_criteria/variance_report/variance_report.js
deleted file mode 100644
index b5fe3fb8fd4..00000000000
--- a/selling/search_criteria/variance_report/variance_report.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.hide_all_filters();
- this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Territory'+NEWLINE+'Sales Person'+NEWLINE+'Sales Partner',report_default:'Territory',ignore : 1,parent:'Target Detail'});
- this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Target Detail'});
- this.add_filter({fieldname:'company', label:'Company', fieldtype:'Link', options:'Company',report_default:sys_defaults.company, ignore : 1, parent:'Target Detail'});
- this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Target Detail'});
-// this.add_filter({fieldname:'item_group', label:'Item Group', fieldtype:'Link', options:'Item Group', ignore : 1, parent:'Target Detail'});
- this.add_filter({fieldname:'group_by', label:'Group By', fieldtype:'Select', options:NEWLINE+'Item Group',ignore : 1, parent:'Target Detail'});
- this.add_filter({fieldname:'under', label:'Under',fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice',report_default:'Sales Order',ignore : 1, parent:'Target Detail'});
-}
-
-//this.mytabs.items['Select Columns'].hide()
diff --git a/selling/search_criteria/variance_report/variance_report.py b/selling/search_criteria/variance_report/variance_report.py
deleted file mode 100644
index 7b6856c157f..00000000000
--- a/selling/search_criteria/variance_report/variance_report.py
+++ /dev/null
@@ -1,520 +0,0 @@
-# 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 .
-
-# Add columns
-# -----------
-from __future__ import unicode_literals
-row_list = [['ID','Data','150px','']]
-
-for r in row_list:
- colnames.append(r[0])
- coltypes.append(r[1])
- colwidths.append(r[2])
- coloptions.append(r[3])
- col_idx[r[0]] = len(colnames)-1
-
-if not filter_values.get('fiscal_year'):
- msgprint("Please Select Fiscal Year")
- raise Exception
-elif not filter_values.get('period'):
- msgprint("Please Select Period")
- raise Exception
-elif not filter_values.get('based_on'):
- msgprint("Please Select the Criteria on which you want your report to be based")
- raise Exception
-elif not filter_values.get('group_by') and filter_values.get('item_group'):
- msgprint("Item Group cannot be selected if Group By is not Item Group")
- raise Exception
-
-fiscal_year = filter_values.get('fiscal_year')
-period = filter_values.get('period')
-based_on = filter_values.get('based_on')
-group_by = filter_values.get('group_by')
-item_group = filter_values.get('item_group')
-msgprint(item_group)
-company = filter_values.get('company')
-under = filter_values.get('under')
-
-#if filter_values.get('item_group'):
-# itm_grp = filter_values.get('item_group')
-
-if based_on == 'Territory':
- based = 'territory'
-elif based_on == 'Sales Person':
- based = 'sales_person'
-elif based_on == 'Sales Partner':
- based = 'sales_partner'
-
-
-if under == 'Sales Invoice':
- under_detail = 'RV'
- dt = 'posting_date'
-else:
- under_detail = under
- dt = "transaction_date"
-
-# get fiscal year start date and start month
-year_start_date = sql("select year_start_date,MONTH(year_start_date) from `tabFiscal Year` where name = %s",fiscal_year)
-start_date = year_start_date and year_start_date[0][0] or ''
-start_month = year_start_date and year_start_date[0][1] or ''
-month_name = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
-
-# Add columns based on period
-# --------------------------------
-columns = []
-if group_by == 'Item Group':
- columns.append(['Item Group','Data','120px',''])
-# ================ Annual ======================
-if period == 'Annual':
- columns.append(['Target','Currency','120px',''])
- columns.append(['Actual','Currency','120px',''])
-
-# =========== Half Yearly ======================
-elif period == 'Half Yearly':
- columns.append(['Target (H1)','Currency','120px','']) # first half
- columns.append(['Actual (H1)','Currency','120px','']) # first half
- columns.append(['Target (H2)','Currency','120px',''])
- columns.append(['Actual (H2)','Currency','120px',''])
-
-# ================ Quarterly ===================
-elif period == 'Quarterly':
- length_1 = (len(month_name) - start_month + 1) / 3 #this gives the total no. of times we need to iterate for quarter
- val = length_1 % 4
- q_no = 1
- for i in range(length_1):
- value = 3*i + val
- columns.append(['Target (Q'+cstr(q_no)+')','Currency','120px',''])
- columns.append(['Actual (Q'+cstr(q_no)+')','Currency','120px',''])
- q_no += 1
- length_2 = (start_month - 1) / 3 #this gives the total no. of times we need to iterate for quarter (this is required only if fiscal year starts from april)
- for i in range(length_2):
- columns.append(['Target (Q'+cstr(q_no)+')','Currency','120px',''])
- columns.append(['Actual (Q'+cstr(q_no)+')','Currency','120px',''])
- q_no += 1;
-
-# =============== Monthly ======================
-elif period == 'Monthly':
- for i in range(start_month-1,len(month_name)):
- columns.append(['Target ('+month_name[i]+')','Currency','120px',''])
- columns.append(['Actual ('+month_name[i]+')','Currency','120px',''])
-
- for i in range(start_month-1):
- columns.append(['Target('+month_name[i]+')','Currency','120px',''])
- columns.append(['Actual ('+month_name[i]+')','Currency','120px',''])
-
-for c in columns:
- colnames.append(c[0])
- coltypes.append(c[1])
- colwidths.append(c[2])
- coloptions.append(c[3])
- col_idx[c[0]] = len(colnames)-1
-
-out = []
-if company:
- condition = ' fiscal_year = "'+fiscal_year+'" and company = "'+company+'"'
-else:
- condition = ' fiscal_year = "'+fiscal_year+'"'
-
-#=================== function for fetching allocated percentage in Distribution id according to period=============
-def get_budget_distribution(period,dist_id,fiscal_year):
- query = ''
- id1 = 1
- if period == 'Half Yearly':
- id2 = 6
- for i in range(2):
- query += 'SUM(CASE WHEN t2.idx BETWEEN '+str(id1)+' AND '+str(id2)+' THEN t2.percentage_allocation ELSE NULL END)'
- id1 += 6
- id2 += 6
- if i < 1 :
- query += ','
-
- elif period == 'Quarterly':
- id2 = 3
- for i in range(4):
- query += 'SUM(CASE WHEN t2.idx BETWEEN '+str(id1)+' AND '+str(id2)+' THEN t2.percentage_allocation ELSE NULL END)'
- id1 += 3
- id2 += 3
- if i < 3 :
- query += ','
-
- elif period == 'Monthly':
- for i in range(12):
- query += 'SUM(CASE WHEN t2.idx ='+str(id1)+' THEN t2.percentage_allocation ELSE NULL END)'
- id1 += 1
- if i < 11 :
- query += ','
-
-# msgprint(query)
-
- # Main Query
- dist = sql("select %s from `tabBudget Distribution` t1, `tabBudget Distribution Detail` t2 where t1.name = '%s' and t2.parent = t1.name and t1.fiscal_year = '%s'"%(query,dist_id,fiscal_year))
- dist = dist and dist[0] or 0
-# msgprint(dist)
- bug = []
- for i in dist:
- i = i and float(i) or 0
- bug.append(i)
-# msgprint(bug)
- return bug
-
-
-#============ function for appending target amt and actual amt in a proper order =======================
-def appending_func(ran,tl,lst,actual,flt):
-
- c = 2
- for i in range(ran):
- #==== for each itemgroup their actual amt is appended/inserted between target amt
- if tl == 0:
- lst.insert(c,actual and flt(actual[0][i]) or 0)
- #======== here actual amt is appended/inserted b/w target amt for a particular territory/sales person/sales partner only if target is not zero
- elif tl == 1:
-# msgprint(lst)
- lst.insert(c,actual and flt(actual[0][i]) or 0)
- c += 2
- return lst
-
-def get_target(tar_det,group_by,period,fiscal_year,rng,r,get_budget_distribution,flt):
-
- grp,lst = [],[]
- list_range,tl = 0,0
- if group_by == 'Item Group':
- for i in tar_det:
- if i[0] != '':
- igrp = [i[0]]
- if i[2]:
- dist_id = i[2]
- dist = get_budget_distribution(period,dist_id,fiscal_year)
- for d in dist:
- t = flt(flt(flt(i[1]) * flt(d))/ 100)
- igrp.append(t)
- else:
- t = i and flt(i[1]/rng) or 0
- for i in range(rng):
- igrp.append(t)
-
- grp.append(igrp)
- list_range +=1
- lst = [1,grp,list_range]
-
- #============== Total target(on basis of whole target ) ============
- else:
- for i in tar_det:
- if i[0] == '':
- if i[2]:
- dist_id = i[2]
- dist = get_budget_distribution(period,dist_id,fiscal_year)
- for d in dist:
- t = flt((flt(i[1]) * flt(d))/ 100)
- r.append(t)
- else:
- tot_target = i and flt(i[1]/rng) or 0
- for i in range(rng):
- r.append(tot_target)
- tl = 1
- lst = [0,r,tl]
- return lst
-#============ report display function =====================
-for r in res:
- query = ''
- grp=[]
- list_range, count, ap, tot_target, tl = 0,0,0,0,0
-
- #============= ANNUAL REPORT ===================
- if period == 'Annual':
- tar_det = sql("select item_group, target_amount, distribution_id from `tabTarget Detail` where parent = %s and parenttype = %s and fiscal_year = %s",(r[col_idx['ID']],based_on,fiscal_year))
-# msgprint(tar_det)
-
- #================ Target based on individual item group ==============
- if group_by == 'Item Group':
- for i in tar_det:
- if i[0] != '':
- grp_target = i and flt(i[1]) or 0
- igrp = [i[0],grp_target]
- grp.append(igrp)
-# msgprint(grp)
- list_range +=1
- count = 3
-
- #============== Total target(will be displayed only if target is specified by the user) ============
- else:
- for i in tar_det:
- # ======= here target is considered and not sum of target of item groups
- if i[0] == '':
- tot_target = tar_det and flt(i[1]) or 0
-# msgprint(tot_target)
-
- #================== Actual Amount =============================================
- if based_on == 'Territory' or based_on == 'Sales Partner':
-
- if group_by =='Item Group':
-
- for i in grp:
- item_group = i[0]
- actual = sql("select sum(t2.amount) from `tab%s` t1, `tab%s Detail` t2, `tabItem` t3 where t2.parent = t1.name and t1.%s = '%s' and t3.name = t2.item_code and t3.item_group = '%s' and t1.docstatus = 1 and t1.docstatus != 2 and %s"%(under,under_detail,based,r[col_idx['ID']],item_group,condition))
- msgprint(actual)
- actual = actual and flt(actual[0][0]) or 0
- i.append(actual)
-
- else:
- actual = sql("select sum(net_total) from `tab%s` where %s = '%s' and docstatus = 1 and %s" % (under, based, r[col_idx['ID']],condition))
- actual = actual and flt(actual[0][0]) or 0
-
- elif based_on == 'Sales Person':
- if group_by =='Item Group':
- for i in grp:
- item_group = i[0]
- actual = sql("select sum(t2.amount) from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3, `tabItem` t4 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t4.name = t2.item_code and t4.item_group = '%s' and t1.docstatus != 2 and t1.docstatus = 1 and %s"%(under,under_detail,based,r[col_idx['ID']],item_group,condition))
- actual = actual and flt(actual[0][0]) or 0
-# msgprint(actual)
- i.append(actual)
-
- else:
- actual = sql("select sum(t1.net_total) from `tab%s` t1, `tabSales Team` t2 where t2.%s = '%s' and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and %s"%(under,based,r[col_idx['ID']],under,condition))
- actual = actual and flt(actual[0][0]) or 0
-# msgprint(actual)
-
- # ================= Half Yearly Report ===============
- elif period == 'Half Yearly':
- tl = 0
- grp_target = []
-
- tar_det = sql("select item_group, target_amount, distribution_id from `tabTarget Detail` where parent = %s and parenttype = %s and fiscal_year = %s",(r[col_idx['ID']],based_on,fiscal_year))
-# msgprint(tar_det)
-
- tar = get_target(tar_det,group_by,period,fiscal_year,2,r,get_budget_distribution,flt)
- if tar[0] == 1:
- grp = tar[1]
- list_range = tar[2]
- count = 5
- else:
- r = tar[1]
- tl = tar[2]
-
- #============= Actual Amount======================
- if group_by == 'Item Group':
- # first half
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN t2.amount ELSE NULL END),'
- # second half
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') NOT BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN t2.amount ELSE NULL END)';
-
- elif based_on != 'Sales Person':
- # first half
- query += 'SUM(CASE WHEN MONTH('+dt+') BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END),'
- # second half
- query += 'SUM(CASE WHEN MONTH('+dt+') NOT BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END)';
-
- else:
- # first half
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN t1.net_total ELSE NULL END),'
- # second half
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') NOT BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN t1.net_total ELSE NULL END)';
-
- #=========== Main Query ===============
- if based_on == 'Territory' or based_on == 'Sales Partner':
-
- if group_by =='Item Group':
- for i in grp:
- item_group = i[0]
- actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabItem` t3 where t2.parent = t1.name and t1.%s = '%s' and t3.name = t2.item_code and t3.item_group = '%s' and t1.docstatus = 1 and t1.docstatus != 2 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
-# msgprint(actual)
- i = appending_func(2,tl,i,actual,flt)
-
- else:
- actual = sql("select %s from `tab%s` where %s = '%s' and docstatus = 1 and %s" % (query,under, based, r[col_idx['ID']],condition))
-# msgprint(actual)
-
- elif based_on == 'Sales Person':
- if group_by =='Item Group':
- for i in grp:
- item_group = i[0]
- actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3, `tabItem` t4 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t4.name = t2.item_code and t4.item_group = '%s' and t1.docstatus != 2 and t1.docstatus = 1 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
-# msgprint(actual)
- i = appending_func(2,tl,i,actual,flt)
- else:
- actual = sql("select %s from `tab%s` t1, `tabSales Team` t2 where t2.%s = '%s' and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and %s"%(query,under,based,r[col_idx['ID']],under,condition))
-# msgprint(actual)
-
- if tl == 1:
- r = appending_func(2,tl,r,actual,flt)
-# msgprint(r)
-
- #============== Quarterly Report =========================
- elif period == 'Quarterly':
- tl = 0
- grp_target = []
- tar_det = sql("select item_group, target_amount, distribution_id from `tabTarget Detail` where parent = %s and parenttype = %s and fiscal_year = %s",(r[col_idx['ID']],based_on,fiscal_year))
-
- tar = get_target(tar_det,group_by,period,fiscal_year,4,r,get_budget_distribution,flt)
- if tar[0] == 1:
- grp = tar[1]
- list_range = tar[2]
- count = 9
- else:
- r = tar[1]
- tl = tar[2]
-
- #======= Actual Amt ==================
- length_1 = (len(month_name) - start_month + 1) / 3; #this gives the total no. of times we need to iterate for quarter
- val = length_1 % 4;
- for i in range(length_1):
- value = 3*i + val;
-
- if group_by == 'Item Group':
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN t2.amount ELSE NULL END),'
-
- elif based_on != 'Sales Person':
- query += 'SUM(CASE WHEN MONTH('+dt+') BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN net_total ELSE NULL END),'
-
- else:
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN t1.net_total ELSE NULL END),'
-
- length_2 = (start_month - 1) / 3; #this gives the total no. of times we need to iterate for quarter (this is required only if fiscal year starts from april)
- for i in range(length_2):
- if group_by == 'Item Group':
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN t2.amount ELSE NULL END)';
-
- elif based_on != 'Sales Person':
- query += 'SUM(CASE WHEN MONTH('+dt+') BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN net_total ELSE NULL END)';
-
- else:
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN t1.net_total ELSE NULL END)';
-
- #=========== Main Query ===============
- if based_on == 'Territory' or based_on == 'Sales Partner':
-
- if group_by =='Item Group':
- for i in grp:
- item_group = i[0]
- actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabItem` t3 where t2.parent = t1.name and t1.%s = '%s' and t3.name = t2.item_code and t3.item_group = '%s' and t1.docstatus = 1 and t1.docstatus != 2 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
-# msgprint(actual)
- #================common function
- i = appending_func(4,tl,i,actual,flt)
-
- else:
- actual = sql("select %s from `tab%s` where %s = '%s' and docstatus = 1 and %s" % (query,under, based, r[col_idx['ID']],condition))
-# msgprint(actual)
-
- elif based_on == 'Sales Person':
- if group_by =='Item Group':
- for i in grp:
- item_group = i[0]
- actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3, `tabItem` t4 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t4.name = t2.item_code and t4.item_group = '%s' and t1.docstatus != 2 and t1.docstatus = 1 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
-# msgprint(actual)
- i = appending_func(4,tl,i,actual,flt)
- else:
- actual = sql("select %s from `tab%s` t1, `tabSales Team` t2 where t2.%s = '%s' and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and %s"%(query,under,based,r[col_idx['ID']],under,condition))
-# msgprint(actual)
-
- if tl == 1:
- r = appending_func(4,tl,r,actual,flt)
-# msgprint(r)
-
- #================ Monthly Report ===========================
- elif period == 'Monthly':
- tl = 0
- grp_target = []
- tar_det = sql("select item_group, target_amount, distribution_id from `tabTarget Detail` where parent = %s and parenttype = %s and fiscal_year = %s",(r[col_idx['ID']],based_on,fiscal_year))
-
- tar = get_target(tar_det,group_by,period,fiscal_year,12,r,get_budget_distribution,flt)
- if tar[0] == 1:
- grp = tar[1]
- list_range = tar[2]
- count = 25
- else:
- r = tar[1]
- tl = tar[2]
-
- #======= Actual Amt ==================
- # for loop is required twice coz fiscal year starts from April (this will also work if fiscal year starts in January)
- for i in range(start_month-1,len(month_name)):
- if group_by == 'Item Group':
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') = '+cstr(i+1)+' THEN t2.amount ELSE NULL END),'
-
- elif based_on != 'Sales Person':
- query += 'SUM(CASE WHEN MONTH('+dt+') = '+cstr(i+1)+' THEN net_total ELSE NULL END),'
-
- else:
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') = '+cstr(i+1)+' THEN t1.net_total ELSE NULL END),'
-
- for i in range(start_month-1):
- if i != (start_month-1):
- if group_by == 'Item Group':
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') = '+cstr(i+1)+' THEN t2.amount ELSE NULL END)'
-
- elif based_on != 'Sales Person':
- query += 'SUM(CASE WHEN MONTH('+dt+') = '+cstr(i+1)+' THEN net_total ELSE NULL END)'
-
- else:
- query += 'SUM(CASE WHEN MONTH(t1.'+dt+') = '+cstr(i+1)+' THEN t1.net_total ELSE NULL END)'
-
- if i < (start_month -2):
- query += ','
-
- #=========== Main Query ===============
- if based_on == 'Territory' or based_on == 'Sales Partner':
-
- if group_by =='Item Group':
- for i in grp:
- item_group = i[0]
- actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabItem` t3 where t2.parent = t1.name and t1.%s = '%s' and t3.name = t2.item_code and t3.item_group = '%s' and t1.docstatus = 1 and t1.docstatus != 2 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
-# msgprint(actual)
- #===============common function=====================
- i = appending_func(12,tl,i,actual,flt)
-
- else:
- actual = sql("select %s from `tab%s` where %s = '%s' and docstatus = 1 and %s" % (query,under, based, r[col_idx['ID']],condition))
-# msgprint(actual)
-
- elif based_on == 'Sales Person':
- if group_by =='Item Group':
- for i in grp:
- item_group = i[0]
- actual = sql("select %s from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3, `tabItem` t4 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t4.name = t2.item_code and t4.item_group = '%s' and t1.docstatus != 2 and t1.docstatus = 1 and %s"%(query,under,under_detail,based,r[col_idx['ID']],item_group,condition))
-# msgprint(actual)
- i = appending_func(12,tl,i,actual,flt)
- else:
- actual = sql("select %s from `tab%s` t1, `tabSales Team` t2 where t2.%s = '%s' and t2.parenttype='%s' and t1.docstatus != 2 and t2.parent = t1.name and %s"%(query,under,based,r[col_idx['ID']],under,condition))
-# msgprint(actual)
-
- if tl == 1:
- r = appending_func(12,tl,r,actual,flt)
-# msgprint(r)
-
-#-------------DISPLAY OF TARGET vs ACTUAL ON BASIS OF TOTAL TARGET / ITEM GROUP
-
- if group_by == 'Item Group':
- for col in range(len(colnames)-1): # this would make all first row blank. just for look
- r.append('')
-
- for des in range(list_range):
- if ap == 0:
- out.append(r)
- ap = 1
- t_row = ['' for i in range(len(colnames))]
-
- for v in range(count):
- t_row[col_idx[colnames[v+1]]] = grp[des][v]
-# msgprint(t_row)
- out.append(t_row)
-
- elif tot_target != 0 and period =='Annual':
- r.append(tot_target)
- r.append(actual)
- out.append(r)
- tot_target = 0
-
- elif tl == 1:
- out.append(r)
diff --git a/selling/search_criteria/variance_report/variance_report.sql b/selling/search_criteria/variance_report/variance_report.sql
deleted file mode 100644
index 89becb7f066..00000000000
--- a/selling/search_criteria/variance_report/variance_report.sql
+++ /dev/null
@@ -1 +0,0 @@
-SELECT DISTINCT t1.`name` FROM `tab%(based_on)s` t1, `tabTarget Detail` t2 WHERE t2.parent = t1.name and (t2.target_amount != 0 or t2.target_amount is not null)
\ No newline at end of file
diff --git a/selling/search_criteria/variance_report/variance_report.txt b/selling/search_criteria/variance_report/variance_report.txt
deleted file mode 100644
index e1411917a58..00000000000
--- a/selling/search_criteria/variance_report/variance_report.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:53",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:53"
- },
- {
- "parent_doc_type": "Territory",
- "module": "Selling",
- "doctype": "Search Criteria",
- "sort_order": "DESC",
- "filters": "{'Territory\u0001State':'','Target Detail\u0001Fiscal Year':'2009-2010','Target Detail\u0001Based On':'Territory','Target Detail\u0001Company':'Alpha Company','Target Detail\u0001Period':'Quarterly','Target Detail\u0001Under':'Sales Order'}",
- "standard": "Yes",
- "doc_type": "Target Detail",
- "name": "__common__",
- "sort_by": "ID",
- "page_len": 50,
- "criteria_name": "Variance Report"
- },
- {
- "name": "variance_report",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/setup/doctype/backup_manager/backup_dropbox.py b/setup/doctype/backup_manager/backup_dropbox.py
index 2901638c048..054d2b26b6d 100644
--- a/setup/doctype/backup_manager/backup_dropbox.py
+++ b/setup/doctype/backup_manager/backup_dropbox.py
@@ -7,12 +7,14 @@
# dropbox_access_key
# dropbox_access_secret
-
+from __future__ import unicode_literals
import os
import webnotes
-from webnotes.utils import get_request_site_address, get_base_path
+from webnotes.utils import get_request_site_address, get_base_path, cstr
from webnotes import _
+from backup_manager import ignore_list
+
@webnotes.whitelist()
def get_dropbox_authorize_url():
sess = get_dropbox_session()
@@ -58,7 +60,7 @@ def dropbox_callback(oauth_token=None, not_approved=False):
webnotes.message_title = "Dropbox Approval"
webnotes.message = "%s
Please close this window.
" % message
-
+
webnotes.conn.commit()
webnotes.response['type'] = 'page'
webnotes.response['page_name'] = 'message.html'
@@ -81,12 +83,19 @@ def backup_to_dropbox():
backup = new_backup()
filename = os.path.join(get_base_path(), "public", "backups",
os.path.basename(backup.backup_path_db))
- upload_file_to_dropbox(filename, "database", dropbox_client)
+ upload_file_to_dropbox(filename, "/database", dropbox_client)
+ webnotes.conn.close()
response = dropbox_client.metadata("/files")
+
# upload files to files folder
+ did_not_upload = []
+ error_log = []
path = os.path.join(get_base_path(), "public", "files")
for filename in os.listdir(path):
+ if filename in ignore_list:
+ continue
+
found = False
filepath = os.path.join(path, filename)
for file_metadata in response["contents"]:
@@ -94,7 +103,14 @@ def backup_to_dropbox():
found = True
break
if not found:
- upload_file_to_dropbox(filepath, "files", dropbox_client)
+ try:
+ upload_file_to_dropbox(filepath, "/files", dropbox_client)
+ except Exception, e:
+ did_not_upload.append(filename)
+ error_log.append(cstr(e))
+
+ webnotes.connect()
+ return did_not_upload, list(set(error_log))
def get_dropbox_session():
try:
@@ -113,21 +129,21 @@ def get_dropbox_session():
def upload_file_to_dropbox(filename, folder, dropbox_client):
from dropbox import rest
size = os.stat(filename).st_size
- f = open(filename,'r')
- # if max packet size reached, use chunked uploader
- max_packet_size = 4194304
+ with open(filename, 'r') as f:
+ # if max packet size reached, use chunked uploader
+ max_packet_size = 4194304
- if size > max_packet_size:
- uploader = dropbox_client.get_chunked_uploader(f, size)
- while uploader.offset < size:
- try:
- uploader.upload_chunked()
- uploader.finish(folder + "/" + os.path.basename(filename), overwrite=True)
- except rest.ErrorResponse:
- pass
- else:
- dropbox_client.put_file(folder + "/" + os.path.basename(filename), f, overwrite=True)
+ if size > max_packet_size:
+ uploader = dropbox_client.get_chunked_uploader(f, size)
+ while uploader.offset < size:
+ try:
+ uploader.upload_chunked()
+ uploader.finish(folder + "/" + os.path.basename(filename), overwrite=True)
+ except rest.ErrorResponse:
+ pass
+ else:
+ dropbox_client.put_file(folder + "/" + os.path.basename(filename), f, overwrite=True)
if __name__=="__main__":
backup_to_dropbox()
\ No newline at end of file
diff --git a/setup/doctype/backup_manager/backup_googledrive.py b/setup/doctype/backup_manager/backup_googledrive.py
index 4b2a82cb891..533b37ddb0d 100644
--- a/setup/doctype/backup_manager/backup_googledrive.py
+++ b/setup/doctype/backup_manager/backup_googledrive.py
@@ -10,16 +10,22 @@
# gdrive_client_id
# gdrive_client_secret
+from __future__ import unicode_literals
import httplib2
import os
import mimetypes
import webnotes
import oauth2client.client
-from webnotes.utils import get_base_path
+from webnotes.utils import get_base_path, cstr
from webnotes import _, msgprint
from apiclient.discovery import build
from apiclient.http import MediaFileUpload
+# define log config for google drive api's log messages
+# basicConfig redirects log to stderr
+import logging
+logging.basicConfig()
+
@webnotes.whitelist()
def get_gdrive_authorize_url():
flow = get_gdrive_flow()
@@ -28,7 +34,6 @@ def get_gdrive_authorize_url():
"authorize_url": authorize_url,
}
-@webnotes.whitelist()
def upload_files(name, mimetype, service, folder_id):
if not webnotes.conn:
webnotes.connect()
@@ -67,8 +72,14 @@ def backup_to_gdrive():
# upload files to database folder
upload_files(filename, 'application/x-gzip', drive_service,
webnotes.conn.get_value("Backup Manager", None, "database_folder_id"))
-
+
# upload files to files folder
+ did_not_upload = []
+ error_log = []
+
+ files_folder_id = webnotes.conn.get_value("Backup Manager", None, "files_folder_id")
+
+ webnotes.conn.close()
path = os.path.join(get_base_path(), "public", "files")
for filename in os.listdir(path):
found = False
@@ -78,19 +89,24 @@ def backup_to_gdrive():
if ext == 'gz' or ext == 'gzip':
mimetype = 'application/x-gzip'
else:
- mimetype = mimetypes.types_map["." + ext]
+ mimetype = mimetypes.types_map.get("." + ext) or "application/octet-stream"
+
#Compare Local File with Server File
- param = {}
- children = drive_service.children().list(
- folderId=webnotes.conn.get_value("Backup Manager", None, "files_folder_id"),
- **param).execute()
+ children = drive_service.children().list(folderId=files_folder_id).execute()
for child in children.get('items', []):
file = drive_service.files().get(fileId=child['id']).execute()
if filename == file['title'] and size == int(file['fileSize']):
found = True
break
if not found:
- upload_files(filepath, mimetype, drive_service, webnotes.conn.get_value("Backup Manager", None, "files_folder_id"))
+ try:
+ upload_files(filepath, mimetype, drive_service, files_folder_id)
+ except Exception, e:
+ did_not_upload.append(filename)
+ error_log.append(cstr(e))
+
+ webnotes.connect()
+ return did_not_upload, list(set(error_log))
def get_gdrive_flow():
from oauth2client.client import OAuth2WebServerFlow
diff --git a/setup/doctype/backup_manager/backup_manager.js b/setup/doctype/backup_manager/backup_manager.js
index 28315c5bc51..c78be3a1eb6 100644
--- a/setup/doctype/backup_manager/backup_manager.js
+++ b/setup/doctype/backup_manager/backup_manager.js
@@ -1,65 +1,90 @@
-cur_frm.cscript.refresh = function(doc) {
- cur_frm.disable_save();
-}
-
-//dropbox
-cur_frm.cscript.allow_dropbox_access = function(doc) {
- if (doc.send_notifications_to == '') {
- msgprint("Please enter email address.")
- }
- else {
- wn.call({
- method: "setup.doctype.backup_manager.backup_dropbox.get_dropbox_authorize_url",
- callback: function(r) {
- if(!r.exc) {
- cur_frm.set_value("dropbox_access_secret", r.message.secret);
- cur_frm.set_value("dropbox_access_key", r.message.key);
- cur_frm.save(null, function() {
- window.open(r.message.url);
- });
+$.extend(cur_frm.cscript, {
+ refresh: function() {
+ cur_frm.disable_save();
+
+ if(!(cint(cur_frm.doc.dropbox_access_allowed) ||
+ cint(cur_frm.doc.gdrive_access_allowed))) {
+ cur_frm.set_intro(wn._("You can start by selecting backup frequency and \
+ granting access for sync"));
+ } else {
+ var services = {
+ "dropbox": wn._("Dropbox"),
+ "gdrive": wn._("Google Drive")
+ }
+ var active_services = [];
+
+ $.each(services, function(service, label) {
+ var access_allowed = cint(cur_frm.doc[service + "_access_allowed"]);
+ var frequency = cur_frm.doc["upload_backups_to_" + service];
+ if(access_allowed && frequency && frequency !== "Never") {
+ active_services.push(label + " [" + frequency + "]");
}
+ });
+
+ if(active_services.length > 0) {
+ cur_frm.set_intro(wn._("Backups will be uploaded to") + ": " +
+ wn.utils.comma_and(active_services));
+ } else {
+ cur_frm.set_intro("");
}
- })
- }
-}
-
-cur_frm.cscript.backup_right_now = function(doc) {
- msgprint("Backing up and uploading. This may take a few minutes.")
- wn.call({
- method: "setup.doctype.backup_manager.backup_manager.take_backups_dropbox",
- callback: function(r) {
- msgprint("Backups taken. Please check your email for the response.")
}
- })
-}
-//gdrive
-cur_frm.cscript.allow_gdrive_access = function(doc) {
- if (doc.send_notifications_to == '') {
- msgprint("Please enter email address.")
- }
- else {
+
+ },
+
+ validate_send_notifications_to: function() {
+ if(!cur_frm.doc.send_notifications_to) {
+ msgprint(wn._("Please specify") + ": " +
+ wn._(wn.meta.get_label(cur_frm.doctype, "send_notifications_to")));
+ return false;
+ }
+
+ return true;
+ },
+
+ allow_dropbox_access: function() {
+ if(cur_frm.cscript.validate_send_notifications_to()) {
+ wn.call({
+ method: "setup.doctype.backup_manager.backup_dropbox.get_dropbox_authorize_url",
+ callback: function(r) {
+ if(!r.exc) {
+ cur_frm.set_value("dropbox_access_secret", r.message.secret);
+ cur_frm.set_value("dropbox_access_key", r.message.key);
+ cur_frm.save(null, function() {
+ window.open(r.message.url);
+ });
+ }
+ }
+ });
+ }
+ },
+
+ allow_gdrive_access: function() {
+ if(cur_frm.cscript.validate_send_notifications_to()) {
+ wn.call({
+ method: "setup.doctype.backup_manager.backup_googledrive.get_gdrive_authorize_url",
+ callback: function(r) {
+ if(!r.exc) {
+ window.open(r.message.authorize_url);
+ }
+ }
+ });
+ }
+ },
+
+ validate_gdrive: function() {
wn.call({
- method: "setup.doctype.backup_manager.backup_googledrive.get_gdrive_authorize_url",
- callback: function(r) {
- window.open(r.message.authorize_url);
- }
- })
- }
-}
-
-cur_frm.cscript.validate_gdrive = function(doc) {
- wn.call({
- method: "setup.doctype.backup_manager.backup_manager.gdrive_callback",
- args: {
- verification_code: doc.verification_code
- },
- });
-}
-
-cur_frm.cscript.upload_backups_to_dropbox = function(doc) {
- cur_frm.save()
-}
-
-cur_frm.cscript.upload_backups_to_gdrive = function(doc) {
- cur_frm.save()
-}
+ method: "setup.doctype.backup_manager.backup_googledrive.gdrive_callback",
+ args: {
+ verification_code: cur_frm.doc.verification_code
+ },
+ });
+ },
+
+ upload_backups_to_dropbox: function() {
+ cur_frm.save();
+ },
+
+ upload_backups_to_gdrive: function() {
+ cur_frm.save();
+ },
+});
\ No newline at end of file
diff --git a/setup/doctype/backup_manager/backup_manager.py b/setup/doctype/backup_manager/backup_manager.py
index 4fb6ab30697..c91cf1110fa 100644
--- a/setup/doctype/backup_manager/backup_manager.py
+++ b/setup/doctype/backup_manager/backup_manager.py
@@ -4,6 +4,8 @@ from __future__ import unicode_literals
import webnotes
from webnotes import _
+ignore_list = []
+
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
@@ -18,27 +20,39 @@ def take_backups_if(freq):
if webnotes.conn.get_value("Backup Manager", None, "upload_backups_to_dropbox")==freq:
take_backups_dropbox()
- if webnotes.conn.get_value("Backup Manager", None, "upload_backups_to_gdrive")==freq:
- take_backups_gdrive()
+ # if webnotes.conn.get_value("Backup Manager", None, "upload_backups_to_gdrive")==freq:
+ # take_backups_gdrive()
@webnotes.whitelist()
def take_backups_dropbox():
+ did_not_upload, error_log = [], []
try:
from setup.doctype.backup_manager.backup_dropbox import backup_to_dropbox
- backup_to_dropbox()
+ did_not_upload, error_log = backup_to_dropbox()
+ if did_not_upload: raise Exception
+
send_email(True, "Dropbox")
- except Exception, e:
- send_email(False, "Dropbox", e)
+ except Exception:
+ file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)]
+ error_message = ("\n".join(file_and_error) + "\n" + webnotes.getTraceback())
+ webnotes.errprint(error_message)
+ send_email(False, "Dropbox", error_message)
#backup to gdrive
@webnotes.whitelist()
def take_backups_gdrive():
+ did_not_upload, error_log = [], []
try:
from setup.doctype.backup_manager.backup_googledrive import backup_to_gdrive
- backup_to_gdrive()
+ did_not_upload, error_log = backup_to_gdrive()
+ if did_not_upload: raise Exception
+
send_email(True, "Google Drive")
- except Exception, e:
- send_email(False, "Google Drive", e)
+ except Exception:
+ file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)]
+ error_message = ("\n".join(file_and_error) + "\n" + webnotes.getTraceback())
+ webnotes.errprint(error_message)
+ send_email(False, "Google Drive", error_message)
def send_email(success, service_name, error_status=None):
if success:
@@ -58,4 +72,4 @@ def send_email(success, service_name, error_status=None):
# email system managers
from webnotes.utils.email_lib import sendmail
sendmail(webnotes.conn.get_value("Backup Manager", None, "send_notifications_to").split(","),
- subject=subject, msg=message)
\ No newline at end of file
+ subject=subject, msg=message)
diff --git a/setup/doctype/backup_manager/backup_manager.txt b/setup/doctype/backup_manager/backup_manager.txt
index 9a43f34746a..2d6f191e5e8 100644
--- a/setup/doctype/backup_manager/backup_manager.txt
+++ b/setup/doctype/backup_manager/backup_manager.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-15 11:06:59",
+ "creation": "2013-04-30 12:58:38",
"docstatus": 0,
- "modified": "2013-03-15 17:27:33",
+ "modified": "2013-05-02 11:42:08",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -109,6 +109,7 @@
"doctype": "DocField",
"fieldname": "sync_with_gdrive",
"fieldtype": "Section Break",
+ "hidden": 1,
"label": "Sync with Google Drive"
},
{
diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py
index 78be5380b24..25645038331 100644
--- a/setup/doctype/company/company.py
+++ b/setup/doctype/company/company.py
@@ -16,6 +16,7 @@
from __future__ import unicode_literals
import webnotes
+from webnotes import _, msgprint
from webnotes.utils import cstr
from webnotes.model.doc import Document
@@ -221,7 +222,6 @@ class DocType:
# Create default cost center
# ---------------------------------------------------
def create_default_cost_center(self):
- from accounts.utils import add_cc
cc_list = [
{
'cost_center_name':'Root',
@@ -243,7 +243,10 @@ class DocType:
}
]
for cc in cc_list:
- add_cc(cc)
+ cc.update({"doctype": "Cost Center"})
+ cc_bean = webnotes.bean(cc)
+ cc_bean.ignore_permissions = True
+ cc_bean.insert()
webnotes.conn.set_value("Company", self.doc.name, "cost_center",
"Default CC Ledger - " + self.doc.abbr)
@@ -287,7 +290,10 @@ class DocType:
where doctype='Global Defaults' and field='default_company'
and value=%s""", self.doc.name)
- def on_rename(self,newdn,olddn):
+ def on_rename(self,newdn,olddn, merge=False):
+ if merge:
+ msgprint(_("Sorry. Companies cannot be merged"), raise_exception=True)
+
webnotes.conn.sql("""update `tabCompany` set company_name=%s
where name=%s""", (newdn, olddn))
diff --git a/setup/doctype/global_defaults/global_defaults.py b/setup/doctype/global_defaults/global_defaults.py
index 8275513dc9a..dc7f6b4b735 100644
--- a/setup/doctype/global_defaults/global_defaults.py
+++ b/setup/doctype/global_defaults/global_defaults.py
@@ -21,6 +21,7 @@ import webnotes.defaults
from webnotes.utils import cint
keydict = {
+ # "key in defaults": "key in Global Defaults"
"print_style": "print_style",
"fiscal_year": "current_fiscal_year",
'company': 'default_company',
@@ -31,6 +32,7 @@ keydict = {
'item_group': 'default_item_group',
'customer_group': 'default_customer_group',
'cust_master_name': 'cust_master_name',
+ "item_naming_by": "item_naming_by",
'supplier_type': 'default_supplier_type',
'supp_master_name': 'supp_master_name',
'territory': 'default_territory',
diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt
index 7f816184691..175ca9414b6 100644
--- a/setup/doctype/global_defaults/global_defaults.txt
+++ b/setup/doctype/global_defaults/global_defaults.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-25 11:08:14",
+ "creation": "2013-05-02 17:53:24",
"docstatus": 0,
- "modified": "2013-03-28 15:41:03",
+ "modified": "2013-05-22 15:57:26",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -167,6 +167,14 @@
"read_only": 0,
"width": "50%"
},
+ {
+ "doctype": "DocField",
+ "fieldname": "item_naming_by",
+ "fieldtype": "Select",
+ "label": "Item Naming By",
+ "options": "Item Code\nNaming Series",
+ "read_only": 0
+ },
{
"doctype": "DocField",
"fieldname": "default_item_group",
@@ -207,14 +215,6 @@
"label": "Allow Negative Stock",
"read_only": 0
},
- {
- "doctype": "DocField",
- "fieldname": "default_warehouse_type",
- "fieldtype": "Link",
- "label": "Default Warehouse Type",
- "options": "Warehouse Type",
- "read_only": 0
- },
{
"doctype": "DocField",
"fieldname": "auto_indent",
@@ -222,6 +222,21 @@
"label": "Raise Material Request when stock reaches re-order level",
"read_only": 0
},
+ {
+ "doctype": "DocField",
+ "fieldname": "reorder_email_notify",
+ "fieldtype": "Check",
+ "label": "Notify by Email on creation of automatic Material Request"
+ },
+ {
+ "default": "Hourly",
+ "doctype": "DocField",
+ "fieldname": "reorder_level_checking_frequency",
+ "fieldtype": "Select",
+ "hidden": 1,
+ "label": "Reorder Level Checking Frequency",
+ "options": "Hourly\nDaily"
+ },
{
"default": "1",
"doctype": "DocField",
@@ -230,6 +245,14 @@
"read_only": 0,
"width": "50%"
},
+ {
+ "doctype": "DocField",
+ "fieldname": "default_warehouse_type",
+ "fieldtype": "Link",
+ "label": "Default Warehouse Type",
+ "options": "Warehouse Type",
+ "read_only": 0
+ },
{
"description": "Percentage you are allowed to receive or deliver more against the quantity ordered. For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units
",
"doctype": "DocField",
@@ -269,7 +292,8 @@
"fieldtype": "Check",
"label": "Auto Inventory Accounting",
"no_copy": 0,
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"description": "Accounting entry frozen up to this date, nobody can do / modify entry except authorized person",
diff --git a/setup/doctype/item_group/item_group.py b/setup/doctype/item_group/item_group.py
index 1445f3999fc..1ff3d4a9397 100644
--- a/setup/doctype/item_group/item_group.py
+++ b/setup/doctype/item_group/item_group.py
@@ -81,3 +81,4 @@ class DocType(DocTypeNestedSet):
if self.doc.slideshow:
from website.helpers.slideshow import get_slideshow
get_slideshow(self)
+
\ No newline at end of file
diff --git a/setup/doctype/item_group/item_group.txt b/setup/doctype/item_group/item_group.txt
index a8da12c8f3f..568cf9d03d6 100644
--- a/setup/doctype/item_group/item_group.txt
+++ b/setup/doctype/item_group/item_group.txt
@@ -173,15 +173,6 @@
"report_hide": 1,
"search_index": 0
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"amend": 0,
"cancel": 0,
diff --git a/setup/doctype/naming_series/naming_series.py b/setup/doctype/naming_series/naming_series.py
index 599118152d5..eb293f256b1 100644
--- a/setup/doctype/naming_series/naming_series.py
+++ b/setup/doctype/naming_series/naming_series.py
@@ -29,12 +29,12 @@ class DocType:
def get_transactions(self, arg=None):
return {
- "transactions": "\n".join([''] + [i[0] for i in
- sql("""select `tabDocField`.`parent`
- FROM `tabDocField`, `tabDocType`
- WHERE `tabDocField`.`fieldname` = 'naming_series'
- and `tabDocType`.name=`tabDocField`.parent
- order by `tabDocField`.parent""")]),
+ "transactions": "\n".join([''] + sorted(list(set(
+ webnotes.conn.sql_list("""select parent
+ from `tabDocField` where fieldname='naming_series'""")
+ + webnotes.conn.sql_list("""select dt from `tabCustom Field`
+ where fieldname='naming_series'""")
+ )))),
"prefixes": "\n".join([''] + [i[0] for i in
sql("""select name from tabSeries""")])
}
@@ -89,7 +89,6 @@ class DocType:
'property': prop,
'value': prop_dict[prop],
'property_type': 'Select',
- 'select_doctype': doctype
})
ps.save(1)
@@ -101,11 +100,18 @@ class DocType:
from core.doctype.doctype.doctype import DocType
dt = DocType()
- parent = sql("""select dt.name from `tabDocField` df, `tabDocType` dt
- where dt.name = df.parent and df.fieldname='naming_series' and dt.name != %s""",
- self.doc.select_doc_for_series)
- sr = ([webnotes.model.doctype.get_property(p[0], 'options', 'naming_series'), p[0]]
- for p in parent)
+ parent = list(set(
+ webnotes.conn.sql_list("""select dt.name
+ from `tabDocField` df, `tabDocType` dt
+ where dt.name = df.parent and df.fieldname='naming_series' and dt.name != %s""",
+ self.doc.select_doc_for_series)
+ + webnotes.conn.sql_list("""select dt.name
+ from `tabCustom Field` df, `tabDocType` dt
+ where dt.name = df.dt and df.fieldname='naming_series' and dt.name != %s""",
+ self.doc.select_doc_for_series)
+ ))
+ sr = [[webnotes.model.doctype.get_property(p, 'options', 'naming_series'), p]
+ for p in parent]
options = self.scrub_options_list(self.doc.set_options.split("\n"))
for series in options:
dt.validate_series(series, self.doc.select_doc_for_series)
@@ -117,9 +123,9 @@ class DocType:
def validate_series_name(self, n):
import re
- if not re.match('[a-zA-Z0-9]+(([-/][a-zA-Z0-9])?[-/][a-zA-Z0-9]*)*',n):
- msgprint('Special Characters except "-" and "/" not allowed in naming series')
- raise Exception
+ if not re.match("^[a-zA-Z0-9-/.#]*$", n):
+ msgprint('Special Characters except "-" and "/" not allowed in naming series',
+ raise_exception=True)
def get_options(self, arg=''):
sr = webnotes.model.doctype.get_property(self.doc.select_doc_for_series,
diff --git a/setup/doctype/naming_series/naming_series.txt b/setup/doctype/naming_series/naming_series.txt
index 3de9e5cfabc..0dab9e970dc 100644
--- a/setup/doctype/naming_series/naming_series.txt
+++ b/setup/doctype/naming_series/naming_series.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-01-10 16:34:23",
+ "creation": "2013-01-25 11:35:08",
"docstatus": 0,
- "modified": "2013-01-22 14:56:34",
+ "modified": "2013-05-02 15:34:41",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -25,8 +25,6 @@
"permlevel": 0
},
{
- "amend": 0,
- "cancel": 0,
"create": 1,
"doctype": "DocPerm",
"name": "__common__",
@@ -62,7 +60,7 @@
"fieldname": "help_html",
"fieldtype": "HTML",
"label": "Help HTML",
- "options": "\nEdit list of Series in the box below. Each Series Prefix on a new line.
\nAllowed special characters are \"/\" and \"-\"
\nExamples:
\nINV-
\nINV-10-
\nINVK-
\n
"
+ "options": "\nEdit list of Series in the box below. Rules:\n
\n- Each Series Prefix on a new line.
\n- Allowed special characters are \"/\" and \"-\"
\n- Optionally, set the number of digits in the series using dot (.) followed by hashes (#). For example, \".####\" means that the series will have four digits. Default is five digits.
\n
\nExamples:
\nINV-
\nINV-10-
\nINVK-
\nINV-.####
\n
"
},
{
"doctype": "DocField",
diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js
index 75d3d0f1c13..b68627f73f7 100644
--- a/setup/doctype/price_list/price_list.js
+++ b/setup/doctype/price_list/price_list.js
@@ -14,10 +14,46 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+cur_frm.cscript.onload = function() {
+ cur_frm.cscript.show_item_prices();
+}
+
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.set_intro("");
if(doc.__islocal) {
cur_frm.set_intro("Save this list to begin.");
return;
+ } else {
+ cur_frm.cscript.show_item_prices();
}
}
+
+cur_frm.cscript.show_item_prices = function() {
+ var item_price = wn.model.get("Item Price", {price_list_name: cur_frm.doc.name});
+
+ var show = item_price && item_price.length;
+
+ cur_frm.toggle_display("item_prices_section", show);
+ $(cur_frm.fields_dict.item_prices.wrapper).empty();
+ if (!show) return;
+
+ var out = '\
+ \
+ | ' + wn._("Item Code") + ' | \
+ ' + wn._("Price") + ' | \
+ ' + wn._("Valid For Selling") + ' | \
+ ' + wn._("Valid For Buying") + ' | \
+
\
+ '
+ + $.map(item_price.sort(function(a, b) { return a.parent.localeCompare(b.parent); }), function(d) {
+ return ''
+ + '| ' + d.parent + ' | '
+ + '' + format_currency(d.ref_rate, d.ref_currency) + ' | '
+ + '' + (cint(d.selling) ? '' : "") + ' | '
+ + '' + (cint(d.buying) ? '' : "") + ' | '
+ + '
'
+ }).join("\n")
+ + '\
+
';
+ $(out).appendTo($(cur_frm.fields_dict.item_prices.wrapper));
+}
diff --git a/setup/doctype/price_list/price_list.py b/setup/doctype/price_list/price_list.py
index a88309b6db7..5c03a3a8538 100644
--- a/setup/doctype/price_list/price_list.py
+++ b/setup/doctype/price_list/price_list.py
@@ -16,73 +16,23 @@
from __future__ import unicode_literals
import webnotes
-
-from webnotes.model.doc import Document
-from webnotes import msgprint
+from webnotes import msgprint, _
+from webnotes.utils import cint
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
- self.cl = []
-
- # validate currency
- def is_currency_valid(self, currency):
- if currency in self.cl:
- return 1
-
- if webnotes.conn.sql("select name from tabCurrency where name=%s", currency):
- self.cl.append(currency)
- return 1
- else:
- return 0
-
- def download_template(self, arg=None):
- """download 3 column template with all Items"""
- default_currency = webnotes.conn.get_default('currency')
- item_list = webnotes.conn.sql("""select name from tabItem where
- (ifnull(is_sales_item,'')='Yes' or ifnull(is_service_item,'')='Yes')""")
- data = [self.get_price(i[0], default_currency) for i in item_list]
- return [['Item', 'Rate', 'Currency']] + data
-
- def get_price(self, item, default_currency):
- rate = webnotes.conn.sql("""select ref_rate, ref_currency from `tabItem Price`
- where parent=%s and price_list_name=%s""", (item, self.doc.name))
- return [item, rate and rate[0][0] or 0, rate and rate[0][1] or default_currency]
-
- # update prices in Price List
- def update_prices(self):
- from webnotes.utils.datautils import read_csv_content_from_attached_file
- data = read_csv_content_from_attached_file(self.doc)
- webnotes.conn.auto_commit_on_many_writes = 1
-
- updated = 0
-
- for line in data:
- if line and len(line)==3 and line[0]!='Item':
- # if item exists
- if webnotes.conn.sql("select name from tabItem where name=%s", line[0]):
- if self.is_currency_valid(line[2]):
- # if price exists
- ref_ret_detail = webnotes.conn.sql("select name from `tabItem Price` where parent=%s and price_list_name=%s and ref_currency=%s", \
- (line[0], self.doc.name, line[2]))
- if ref_ret_detail:
- webnotes.conn.sql("update `tabItem Price` set ref_rate=%s where name=%s", (line[1], ref_ret_detail[0][0]))
- else:
- d = Document('Item Price')
- d.parent = line[0]
- d.parentfield = 'ref_rate_details'
- d.parenttype = 'Item'
- d.price_list_name = self.doc.name
- d.ref_rate = line[1]
- d.ref_currency = line[2]
- d.save(1)
- updated += 1
- else:
- msgprint("[Ignored] Unknown currency '%s' for Item '%s'" % (line[2], line[0]))
- else:
- msgprint("[Ignored] Did not find Item '%s'" % line[1])
-
- msgprint("%s items updated" % updated)
- webnotes.conn.auto_commit_on_many_writes = 0
\ No newline at end of file
+ def onload(self):
+ self.doclist.extend(webnotes.conn.sql("""select * from `tabItem Price`
+ where price_list_name=%s""", self.doc.name, as_dict=True, update={"doctype": "Item Price"}))
+
+ def validate(self):
+ if not (cint(self.doc.valid_for_all_countries) or len(self.doclist.get({"parentfield": "valid_for_countries"}))):
+ msgprint(_("""Please check "Valid For All Countries" or \
+ enter atlease one row in the "Countries" table."""), raise_exception=True)
+
+ def on_trash(self):
+ webnotes.conn.sql("""delete from `tabItem Price` where price_list_name = %s""",
+ self.doc.name)
\ No newline at end of file
diff --git a/setup/doctype/price_list/price_list.txt b/setup/doctype/price_list/price_list.txt
index 7e48b783bae..781eae5f68f 100644
--- a/setup/doctype/price_list/price_list.txt
+++ b/setup/doctype/price_list/price_list.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-01-10 16:34:23",
+ "creation": "2013-01-25 11:35:09",
"docstatus": 0,
- "modified": "2013-01-22 14:56:41",
+ "modified": "2013-05-02 14:45:00",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -53,19 +53,54 @@
"reqd": 1
},
{
- "depends_on": "price_list_name",
+ "doctype": "DocField",
+ "fieldname": "currency",
+ "fieldtype": "Link",
+ "label": "Currency",
+ "options": "Currency",
+ "reqd": 1
+ },
+ {
+ "default": "1",
+ "doctype": "DocField",
+ "fieldname": "valid_for_all_countries",
+ "fieldtype": "Check",
+ "label": "Valid for all countries"
+ },
+ {
+ "description": "A list of Countries, for which, this Price List is valid",
+ "doctype": "DocField",
+ "fieldname": "valid_for_countries",
+ "fieldtype": "Table",
+ "label": "Valid for the following countries",
+ "options": "Price List Country"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "item_prices_section",
+ "fieldtype": "Section Break",
+ "label": "Item Prices"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "item_prices",
+ "fieldtype": "HTML",
+ "label": "Item Prices"
+ },
+ {
+ "depends_on": "eval:!doc.__islocal",
+ "doctype": "DocField",
+ "fieldname": "section_break_1",
+ "fieldtype": "Section Break",
+ "label": "How to upload"
+ },
+ {
+ "depends_on": "eval:!doc.__islocal",
"doctype": "DocField",
"fieldname": "how_to_upload",
"fieldtype": "HTML",
"label": "How to upload",
- "options": "Use the
Data Import Tool to upload, update Item Prices in bulk:\n
\n- Go to Data Import Tool.\n
- Select \"Item\"\n
- Check on \"With Data\"\n
- Download \"Item Price\" from Child Tables.\n
- Update the prices required and add new rows if required.\n
- Check on \"Overwrite\"\n
- Upload the modified sheet.\n
\n"
- },
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List"
+ "options": "Use the
Data Import Tool to upload, update Item Prices in bulk:\n
\n- Go to Data Import Tool.\n
- Select \"Item\"\n
- Check on \"With Data\"\n
- Download \"Item Price\" from Child Tables.\n
- Update the prices required and add new rows if required.\n
- Check on \"Overwrite\"\n
- Upload the modified sheet.\n
\n"
},
{
"cancel": 0,
diff --git a/setup/doctype/price_list/test_price_list.py b/setup/doctype/price_list/test_price_list.py
index 53b86a39fca..fe87821904d 100644
--- a/setup/doctype/price_list/test_price_list.py
+++ b/setup/doctype/price_list/test_price_list.py
@@ -1,6 +1,8 @@
test_records = [
[{
"doctype": "Price List",
- "price_list_name": "_Test Price List"
+ "price_list_name": "_Test Price List",
+ "currency": "INR",
+ "valid_for_all_countries": 1
}]
]
\ No newline at end of file
diff --git a/setup/doctype/price_list_country/__init__.py b/setup/doctype/price_list_country/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/setup/doctype/price_list_country/price_list_country.py b/setup/doctype/price_list_country/price_list_country.py
new file mode 100644
index 00000000000..928aa9ff9f2
--- /dev/null
+++ b/setup/doctype/price_list_country/price_list_country.py
@@ -0,0 +1,8 @@
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+class DocType:
+ def __init__(self, d, dl):
+ self.doc, self.doclist = d, dl
\ No newline at end of file
diff --git a/setup/doctype/price_list_country/price_list_country.txt b/setup/doctype/price_list_country/price_list_country.txt
new file mode 100644
index 00000000000..640b0a80527
--- /dev/null
+++ b/setup/doctype/price_list_country/price_list_country.txt
@@ -0,0 +1,36 @@
+[
+ {
+ "creation": "2013-04-29 18:24:32",
+ "docstatus": 0,
+ "modified": "2013-04-29 18:24:32",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "autoname": "PLCNTRY-.#####",
+ "doctype": "DocType",
+ "istable": 1,
+ "module": "Setup",
+ "name": "__common__"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "country",
+ "fieldtype": "Link",
+ "label": "Country",
+ "name": "__common__",
+ "options": "Country",
+ "parent": "Price List Country",
+ "parentfield": "fields",
+ "parenttype": "DocType",
+ "permlevel": 0,
+ "reqd": 1
+ },
+ {
+ "doctype": "DocType",
+ "name": "Price List Country"
+ },
+ {
+ "doctype": "DocField"
+ }
+]
\ No newline at end of file
diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py
index 5bfe4a7d94b..bf8b87f3ad7 100644
--- a/setup/doctype/setup_control/setup_control.py
+++ b/setup/doctype/setup_control/setup_control.py
@@ -97,7 +97,7 @@ class DocType:
self.create_email_digest()
webnotes.clear_cache()
- msgprint("Company setup is complete. Please refresh the page before continuing.")
+ msgprint("Company setup is complete. This page will be refreshed in a moment.")
import webnotes.utils
user_fullname = (args.get('first_name') or '') + (args.get('last_name')
diff --git a/setup/page/setup/setup.js b/setup/page/setup/setup.js
index 4ab7578850a..788021a42aa 100644
--- a/setup/page/setup/setup.js
+++ b/setup/page/setup/setup.js
@@ -73,7 +73,7 @@ wn.module_page["Setup"] = [
{
"route":"Form/Naming Series/Naming Series",
doctype: "Naming Series",
- label: wn._("Manage numbering series"),
+ label: wn._("Manage Numbering Series"),
"description":wn._("Set multiple numbering series for transactions")
},
{
@@ -82,6 +82,12 @@ wn.module_page["Setup"] = [
label: wn._("Rename Tool"),
"description":wn._("Rename multiple items in one go")
},
+ {
+ "route":"List/File Data",
+ doctype: "File Data",
+ label: wn._("File Manager"),
+ "description":wn._("List, delete uploaded files.")
+ },
]
},
{
@@ -187,21 +193,8 @@ wn.module_page["Setup"] = [
]
},
{
- title: wn._("Backups"),
- icon: "icon-cloud-upload",
- right: true,
- items: [
- {
- "route":"Form/Backup Manager",
- doctype:"Backup Manager",
- label: wn._("Backup Manager"),
- "description":wn._("Sync backups with remote tools like Dropbox etc.")
- },
- ]
- },
- {
- title: wn._("Update Manager"),
- icon: "icon-magnet",
+ title: wn._("Administration"),
+ icon: "icon-rocket",
right: true,
items: [
{
@@ -209,6 +202,18 @@ wn.module_page["Setup"] = [
label: wn._("Update This Application"),
"description":wn._("Apply latest updates and patches to this app")
},
+ {
+ "route":"Form/Backup Manager",
+ doctype:"Backup Manager",
+ label: wn._("Backup Manager"),
+ "description":wn._("Sync backups with remote tools like Dropbox etc.")
+ },
+ {
+ "route":"List/Scheduler Log",
+ doctype:"Scheduler Log",
+ label: wn._("Scheduler Error Log"),
+ "description":wn._("Get a list of errors encountered by the Scheduler")
+ },
]
},
]
diff --git a/startup/install.py b/startup/install.py
index 5ddbf094c82..204df87913f 100644
--- a/startup/install.py
+++ b/startup/install.py
@@ -139,8 +139,10 @@ def import_defaults():
{'doctype': 'Supplier Type', 'name': 'Default Supplier Type', 'supplier_type': 'Default Supplier Type'},
# Price List
- {'doctype': 'Price List', 'name': 'Default Price List', 'price_list_name': 'Default Price List'},
- {'doctype': 'Price List', 'name': 'Standard', 'price_list_name': 'Standard'},
+ {'doctype': 'Price List', 'name': 'Default Price List',
+ 'price_list_name': 'Default Price List', "valid_for_all_countries": 1},
+ {'doctype': 'Price List', 'name': 'Standard', 'price_list_name': 'Standard',
+ "valid_for_all_countries": 1},
# warehouse type
{'doctype': 'Warehouse Type', 'name': 'Default Warehouse Type', 'warehouse_type': 'Default Warehouse Type'},
@@ -176,6 +178,6 @@ def import_defaults():
]
for r in records:
- doc = webnotes.doc(r)
- doc.insert()
-
\ No newline at end of file
+ if not webnotes.conn.exists(r['doctype'], r['name']):
+ bean = webnotes.bean(r)
+ bean.insert()
\ No newline at end of file
diff --git a/startup/report_data_map.py b/startup/report_data_map.py
index 501db4f6cec..c3a5dd2cce9 100644
--- a/startup/report_data_map.py
+++ b/startup/report_data_map.py
@@ -47,8 +47,8 @@ data_map = {
"order_by": "lft"
},
"GL Entry": {
- "columns": ["name", "account", "posting_date", "cost_center", "debit", "credit", "is_opening",
- "company", "voucher_type", "voucher_no", "remarks"],
+ "columns": ["name", "account", "posting_date", "cost_center", "debit", "credit",
+ "is_opening", "company", "voucher_type", "voucher_no", "remarks"],
"conditions": ["ifnull(is_cancelled, 'No')='No'"],
"order_by": "posting_date, account",
"links": {
@@ -72,7 +72,7 @@ data_map = {
},
"Item Group": {
"columns": ["name", "parent_item_group"],
- "conditions": ["docstatus < 2"],
+ # "conditions": ["docstatus < 2"],
"order_by": "lft"
},
"Brand": {
diff --git a/startup/schedule_handlers.py b/startup/schedule_handlers.py
index 0799817206b..99cc05b041f 100644
--- a/startup/schedule_handlers.py
+++ b/startup/schedule_handlers.py
@@ -53,11 +53,15 @@ def execute_daily():
# daily backup
from setup.doctype.backup_manager.backup_manager import take_backups_daily
- take_backups_daily()
+ run_fn(take_backups_daily)
+
+ # check reorder level
+ from stock.utils import reorder_item
+ run_fn(reorder_item)
def execute_weekly():
from setup.doctype.backup_manager.backup_manager import take_backups_weekly
- take_backups_weekly()
+ run_fn(take_backups_weekly)
def execute_monthly():
pass
diff --git a/startup/website.py b/startup/website.py
index 295e5bb0cab..5e6c3118c2e 100644
--- a/startup/website.py
+++ b/startup/website.py
@@ -1,4 +1,5 @@
import webnotes, conf, os
+from webnotes.utils import cint, cstr, encode
def get_templates_path():
return os.path.join(os.path.dirname(conf.__file__), "app", "website", "templates")
@@ -61,15 +62,17 @@ def update_template_args(page_name, args):
settings = webnotes.doc("Website Settings", "Website Settings")
for k in ["banner_html", "brand_html", "copyright", "address", "twitter_share_via",
- "favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share"]:
+ "favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
+ "disable_signup"]:
if k in settings.fields:
args[k] = settings.fields.get(k)
- for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share"]:
- args[k] = int(args.get(k) or 0)
+ for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
+ "disable_signup"]:
+ args[k] = cint(args.get(k) or 0)
args.url = quote(str(get_request_site_address(full_address=True)), str(""))
- args.encoded_title = quote(str(args.title or ""), str(""))
+ args.encoded_title = quote(encode(args.title or ""), str(""))
return args
\ No newline at end of file
diff --git a/stock/doctype/batch/batch.txt b/stock/doctype/batch/batch.txt
index 6a6de8b2476..c6ed3c370a0 100644
--- a/stock/doctype/batch/batch.txt
+++ b/stock/doctype/batch/batch.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-01 08:21:54",
+ "creation": "2013-03-05 14:50:38",
"docstatus": 0,
- "modified": "2013-03-01 08:22:16",
+ "modified": "2013-05-01 15:49:47",
"modified_by": "Administrator",
"owner": "harshada@webnotestech.com"
},
@@ -98,24 +98,6 @@
"oldfieldname": "finished_date",
"oldfieldtype": "Date"
},
- {
- "doctype": "DocField",
- "fieldname": "trash_reason",
- "fieldtype": "Small Text",
- "label": "Trash Reason",
- "oldfieldname": "trash_reason",
- "oldfieldtype": "Small Text",
- "read_only": 1
- },
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"doctype": "DocPerm"
}
diff --git a/stock/doctype/bin/bin.py b/stock/doctype/bin/bin.py
index be343129bff..61baafafa2e 100644
--- a/stock/doctype/bin/bin.py
+++ b/stock/doctype/bin/bin.py
@@ -77,10 +77,6 @@ class DocType:
self.doc.save()
- if (flt(args.get("actual_qty")) < 0 or flt(args.get("reserved_qty")) > 0) \
- and args.get("is_cancelled") == 'No' and args.get("is_amended")=='No':
- self.reorder_item(args.get("voucher_type"), args.get("voucher_no"))
-
def get_first_sle(self):
sle = sql("""
select * from `tabStock Ledger Entry`
@@ -90,82 +86,4 @@ class DocType:
order by timestamp(posting_date, posting_time) asc, name asc
limit 1
""", (self.doc.item_code, self.doc.warehouse), as_dict=1)
- return sle and sle[0] or None
-
- def reorder_item(self,doc_type,doc_name):
- """ 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,
- material_request_type)
-
- def create_material_request(self, doc_type, doc_name, reorder_level, reorder_qty,
- 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": defaults.company,
- "fiscal_year": defaults.fiscal_year,
- "transaction_date": nowdate(),
- "material_request_type": material_request_type,
- "remark": _("This is an auto generated Material Request.") + \
- _("It was raised because the (actual + ordered + indented - reserved) quantity reaches re-order level when the following record was created") + \
- ": " + _(doc_type) + " " + doc_name
- }, {
- "doctype": "Material Request Item",
- "parenttype": "Material Request",
- "parentfield": "indent_details",
- "item_code": self.doc.item_code,
- "schedule_date": add_days(nowdate(),cint(item.lead_time_days)),
- "uom": self.doc.stock_uom,
- "warehouse": self.doc.warehouse,
- "item_name": item.item_name,
- "description": item.description,
- "item_group": item.item_group,
- "qty": reorder_qty,
- "brand": item.brand,
- }])
- mr.insert()
- mr.submit()
-
- msgprint("""Item: %s is to be re-ordered. Material Request %s raised.
- It was generated from %s: %s""" %
- (self.doc.item_code, mr.doc.name, doc_type, doc_name))
-
- if(item.email_notify):
- self.send_email_notification(doc_type, doc_name, mr)
-
- def send_email_notification(self, doc_type, doc_name, bean):
- """ Notify user about auto creation of indent"""
-
- from webnotes.utils.email_lib import sendmail
- email_list=[d[0] for d in sql("""select distinct r.parent from tabUserRole r, tabProfile p
- where p.name = r.parent and p.enabled = 1 and p.docstatus < 2
- and r.role in ('Purchase Manager','Material Manager')
- and p.name not in ('Administrator', 'All', 'Guest')""")]
-
- msg="""A new Material Request has been raised for Item: %s and Warehouse: %s \
- on %s due to %s: %s. See %s: %s """ % (self.doc.item_code, self.doc.warehouse,
- formatdate(), doc_type, doc_name, bean.doc.doctype,
- get_url_to_form(bean.doc.doctype, bean.doc.name))
-
- sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg)
-
+ return sle and sle[0] or None
\ No newline at end of file
diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js
index ad39b7a8222..5992d016b84 100644
--- a/stock/doctype/delivery_note/delivery_note.js
+++ b/stock/doctype/delivery_note/delivery_note.js
@@ -323,6 +323,17 @@ if (sys_defaults.auto_inventory_accounting) {
}
// cost center
+ cur_frm.cscript.cost_center = function(doc, cdt, cdn){
+ var d = locals[cdt][cdn];
+ if(d.cost_center) {
+ var cl = getchildren('Delivery Note Item', doc.name, cur_frm.cscript.fname, doc.doctype);
+ for(var i = 0; i < cl.length; i++){
+ if(!cl[i].cost_center) cl[i].cost_center = d.cost_center;
+ }
+ }
+ refresh_field(cur_frm.cscript.fname);
+ }
+
cur_frm.fields_dict.delivery_note_details.grid.get_field("cost_center").get_query = function(doc) {
return {
query: "accounts.utils.get_cost_center_list",
diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py
index 15e24ef2930..6ffd9600003 100644
--- a/stock/doctype/delivery_note/delivery_note.py
+++ b/stock/doctype/delivery_note/delivery_note.py
@@ -419,4 +419,4 @@ class DocType(SellingController):
if gl_entries:
from accounts.general_ledger import make_gl_entries
- make_gl_entries(gl_entries)
\ No newline at end of file
+ make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2))
\ No newline at end of file
diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt
index 618d172d074..36c2789bfa7 100644
--- a/stock/doctype/delivery_note/delivery_note.txt
+++ b/stock/doctype/delivery_note/delivery_note.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-01-29 17:54:12",
+ "creation": "2013-04-02 10:50:50",
"docstatus": 0,
"modified": "2013-02-02 19:18:38",
"modified_by": "Administrator",
@@ -32,9 +32,7 @@
"parent": "Delivery Note",
"parentfield": "permissions",
"parenttype": "DocType",
- "permlevel": 0,
- "read": 1,
- "report": 1
+ "read": 1
},
{
"doctype": "DocType",
@@ -1123,20 +1121,25 @@
"read_only": 0
},
{
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1,
- "read_only": 0
+ "amend": 1,
+ "cancel": 1,
+ "create": 1,
+ "doctype": "DocPerm",
+ "permlevel": 0,
+ "report": 1,
+ "role": "Material User",
+ "submit": 1,
+ "write": 1
},
{
+ "amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "role": "Accounts User",
+ "match": "",
+ "permlevel": 1,
+ "report": 0,
+ "role": "Material User",
"submit": 0,
"write": 0
},
@@ -1145,31 +1148,73 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
- "role": "Sales User",
- "submit": 1,
- "write": 1
- },
- {
- "doctype": "DocPerm",
- "match": "customer_name",
- "role": "Customer"
- },
- {
- "amend": 1,
- "cancel": 1,
- "create": 1,
- "doctype": "DocPerm",
+ "permlevel": 0,
+ "report": 1,
"role": "Material Manager",
"submit": 1,
"write": 1
},
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "match": "",
+ "permlevel": 1,
+ "report": 0,
+ "role": "Material Manager",
+ "submit": 0,
+ "write": 0
+ },
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
- "role": "Material User",
+ "match": "",
+ "permlevel": 0,
+ "report": 1,
+ "role": "Sales User",
"submit": 1,
"write": 1
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "match": "",
+ "permlevel": 1,
+ "report": 0,
+ "role": "Sales User",
+ "submit": 0,
+ "write": 0
+ },
+ {
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "permlevel": 0,
+ "report": 1,
+ "role": "Accounts User",
+ "submit": 0,
+ "write": 0
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "match": "",
+ "permlevel": 1,
+ "role": "Accounts User",
+ "submit": 0
+ },
+ {
+ "doctype": "DocPerm",
+ "match": "customer_name",
+ "permlevel": 0,
+ "report": 1,
+ "role": "Customer"
}
]
\ No newline at end of file
diff --git a/stock/doctype/delivery_note_item/delivery_note_item.txt b/stock/doctype/delivery_note_item/delivery_note_item.txt
index 1073f0cdc25..f90ba69f532 100644
--- a/stock/doctype/delivery_note_item/delivery_note_item.txt
+++ b/stock/doctype/delivery_note_item/delivery_note_item.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-04-01 10:49:21",
+ "creation": "2013-04-22 13:15:44",
"docstatus": 0,
- "modified": "2013-04-17 17:20:58",
+ "modified": "2013-05-22 12:05:32",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -340,6 +340,7 @@
"hidden": 1,
"in_filter": 1,
"label": "Document Type",
+ "no_copy": 1,
"oldfieldname": "prevdoc_doctype",
"oldfieldtype": "Data",
"print_hide": 1,
@@ -371,6 +372,7 @@
"hidden": 1,
"in_filter": 1,
"label": "Against Document Date",
+ "no_copy": 1,
"oldfieldname": "prevdoc_date",
"oldfieldtype": "Date",
"print_hide": 1,
@@ -383,6 +385,7 @@
"hidden": 1,
"in_filter": 1,
"label": "Against Document Detail No",
+ "no_copy": 1,
"oldfieldname": "prevdoc_detail_docname",
"oldfieldtype": "Data",
"print_hide": 1,
diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js
index 8b3e04484a2..acc78e77dc5 100644
--- a/stock/doctype/item/item.js
+++ b/stock/doctype/item/item.js
@@ -14,11 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+cur_frm.add_fetch("price_list_name", "currency", "ref_currency")
+
cur_frm.cscript.refresh = function(doc) {
// make sensitive fields(has_serial_no, is_stock_item, valuation_method)
// read only if any stock ledger entry exists
- cur_frm.toggle_enable("item_code", doc.__islocal);
+ cur_frm.toggle_display("naming_series", sys_defaults.item_naming_by=="Naming Series"
+ && doc.__islocal)
+ cur_frm.toggle_display("item_code", sys_defaults.item_naming_by!="Naming Series"
+ && doc.__islocal)
+
if ((!doc.__islocal) && (doc.is_stock_item == 'Yes')) {
var callback = function(r, rt) {
@@ -128,11 +134,7 @@ cur_frm.fields_dict.item_supplier_details.grid.get_field("supplier").get_query =
erpnext.utils.supplier_query;
cur_frm.cscript.on_remove_attachment = function(doc) {
- // refresh image list before unsetting image
- refresh_field("image");
if(!inList(cur_frm.fields_dict.image.df.options.split("\n"), doc.image)) {
- // if the selected image is removed from attachment, unset it
- cur_frm.set_value("image", "");
msgprint(wn._("Attachment removed. You may need to update: ")
+ wn.meta.get_docfield(doc.doctype, "description_html").label);
}
@@ -151,3 +153,7 @@ cur_frm.cscript.copy_from_item_group = function(doc) {
cur_frm.refresh();
});
}
+
+cur_frm.cscript.image = function() {
+ refresh_field("image_view");
+}
\ No newline at end of file
diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py
index a16296d18b9..d743a980057 100644
--- a/stock/doctype/item/item.py
+++ b/stock/doctype/item/item.py
@@ -23,51 +23,197 @@ from webnotes.model.bean import getlist
from webnotes import msgprint, _
from webnotes.model.controller import DocListController
-class DocType(DocListController):
- def get_tax_rate(self, tax_type):
- rate = webnotes.conn.sql("select tax_rate from tabAccount where name = %s", tax_type)
- ret = {
- 'tax_rate' : rate and flt(rate[0][0]) or 0
- }
- return ret
+class PriceListCurrencyMismatch(Exception): pass
+
+class DocType(DocListController):
+ def autoname(self):
+ if webnotes.conn.get_default("item_naming_by")=="Naming Series":
+ from webnotes.model.doc import make_autoname
+ self.doc.item_code = make_autoname(self.doc.naming_series+'.#####')
+ elif not self.doc.item_code:
+ msgprint(_("Item Code is mandatory"), raise_exception=1)
+
+ self.doc.name = self.doc.item_code
+
+ def validate(self):
+ if not self.doc.stock_uom:
+ msgprint(_("Please enter Default Unit of Measure"), raise_exception=1)
+
+ self.check_stock_uom_with_bin()
+ self.validate_conversion_factor()
+ self.add_default_uom_in_conversion_factor_table()
+ self.valiadte_item_type()
+ self.check_for_active_boms()
+ self.validate_price_lists()
+ self.fill_customer_code()
+ self.check_item_tax()
+ self.validate_barcode()
+ self.check_non_asset_warehouse()
+ self.cant_change()
+ self.validate_item_type_for_reorder()
+
+ if self.doc.name:
+ self.old_page_name = webnotes.conn.get_value('Item', self.doc.name, 'page_name')
+
def on_update(self):
self.validate_name_with_item_group()
-
- # webpage updates
self.update_website()
-
- bin = webnotes.conn.sql("select stock_uom from `tabBin` where item_code = %s",
- self.doc.item_code)
- if bin and cstr(bin[0][0]) and cstr(bin[0][0]) != cstr(self.doc.stock_uom):
- msgprint("Please Update Stock UOM with the help of Stock UOM Replace Utility.")
- raise Exception
+
+ def add_default_uom_in_conversion_factor_table(self):
+ uom_conv_list = [d.uom for d in self.doclist.get({"parentfield": "uom_conversion_details"})]
+ if self.doc.stock_uom not in uom_conv_list:
+ ch = addchild(self.doc, 'uom_conversion_details', 'UOM Conversion Detail', self.doclist)
+ ch.uom = self.doc.stock_uom
+ ch.conversion_factor = 1
+
+ def check_stock_uom_with_bin(self):
+ if not self.doc.fields.get("__islocal"):
+ bin = webnotes.conn.sql("select stock_uom from `tabBin` where item_code = %s",
+ self.doc.name)
+ if self.doc.stock_uom and bin and cstr(bin[0][0]) \
+ and cstr(bin[0][0]) != cstr(self.doc.stock_uom):
+ msgprint(_("Please Update Stock UOM with the help of Stock UOM Replace Utility."),
+ raise_exception=1)
+
+ def validate_conversion_factor(self):
check_list = []
for d in getlist(self.doclist,'uom_conversion_details'):
- if not self.doc.stock_uom:
- msgprint("Please enter Stock UOM first.")
- raise Exception
-
if cstr(d.uom) in check_list:
- msgprint("UOM %s has been entered more than once in Conversion Factor Details." % cstr(d.uom))
- raise Exception
+ msgprint(_("UOM %s has been entered more than once in Conversion Factor Table." %
+ cstr(d.uom)), raise_exception=1)
else:
check_list.append(cstr(d.uom))
- if cstr(d.uom) == cstr(self.doc.stock_uom):
- if flt(d.conversion_factor) != 1:
- msgprint("Conversion Factor of UOM : %s should be equal to 1. As UOM : %s is Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
- raise Exception
- elif cstr(d.uom) != cstr(self.doc.stock_uom) and flt(d.conversion_factor) == 1:
- msgprint("Conversion Factor of UOM : %s should not be equal to 1. As UOM : %s is not Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
- raise Exception
+ if d.uom and cstr(d.uom) == cstr(self.doc.stock_uom) and flt(d.conversion_factor) != 1:
+ msgprint(_("""Conversion Factor of UOM: %s should be equal to 1.
+ As UOM: %s is Stock UOM of Item: %s.""" %
+ (d.uom, d.uom, self.doc.name)), raise_exception=1)
+ elif d.uom and cstr(d.uom)!= self.doc.stock_uom and flt(d.conversion_factor) == 1:
+ msgprint(_("""Conversion Factor of UOM: %s should not be equal to 1.
+ As UOM: %s is not Stock UOM of Item: %s""" %
+ (d.uom, d.uom, self.doc.name)), raise_exception=1)
+
+ def valiadte_item_type(self):
+ if cstr(self.doc.is_manufactured_item) == "No":
+ self.doc.is_pro_applicable = "No"
- if not cstr(self.doc.stock_uom) in check_list :
- child = addchild( self.doc, 'uom_conversion_details',
- 'UOM Conversion Detail', self.doclist)
- child.uom = self.doc.stock_uom
- child.conversion_factor = 1
- child.save()
+ if self.doc.is_pro_applicable == 'Yes' and self.doc.is_stock_item == 'No':
+ msgprint("As Production Order can be made for this Item, then Is Stock Item Should be 'Yes' as we maintain it's stock. Refer Manufacturing and Inventory section.", raise_exception=1)
+
+ if self.doc.has_serial_no == 'Yes' and self.doc.is_stock_item == 'No':
+ msgprint("'Has Serial No' can not be 'Yes' for non-stock item", raise_exception=1)
+
+ def check_for_active_boms(self):
+ def _check_for_active_boms(field_label):
+ if field_label in ['Is Active', 'Is Purchase Item']:
+ bom_mat = webnotes.conn.sql("""select distinct t1.parent
+ from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent
+ and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1
+ and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name)
+ if bom_mat and bom_mat[0][0]:
+ msgprint(_(field_label) + _(" should be 'Yes'. As Item: ") + self.doc.name +
+ _(" is present in one or many Active BOMs"), raise_exception=1)
+
+ if ((field_label == 'Allow Production Order'
+ and self.doc.is_sub_contracted_item != 'Yes')
+ or (field_label == 'Is Sub Contracted Item'
+ and self.doc.is_manufactured_item != 'Yes')):
+ bom = webnotes.conn.sql("""select name from `tabBOM` where item = %s
+ and is_active = 1""", (self.doc.name,))
+ if bom and bom[0][0]:
+ msgprint(_(field_label) + _(" should be 'Yes'. As Item: ") + self.doc.name +
+ _(" is present in one or many Active BOMs"), raise_exception=1)
+
+ if not cint(self.doc.fields.get("__islocal")):
+ fl = {'is_manufactured_item' :'Allow Bill of Materials',
+ 'is_sub_contracted_item':'Is Sub Contracted Item',
+ 'is_purchase_item' :'Is Purchase Item',
+ 'is_pro_applicable' :'Allow Production Order'}
+ for d in fl:
+ if cstr(self.doc.fields.get(d)) != 'Yes':
+ _check_for_active_boms(fl[d])
+
+ def validate_price_lists(self):
+ price_lists=[]
+ for d in getlist(self.doclist,'ref_rate_details'):
+ if d.price_list_name in price_lists:
+ msgprint(_("Cannot have two prices for same Price List") + ": " + d.price_list_name,
+ raise_exception= webnotes.DuplicateEntryError)
+ else:
+ price_list_currency = webnotes.conn.get_value("Price List", d.price_list_name, "currency")
+ if price_list_currency and d.ref_currency != price_list_currency:
+ msgprint(_("Currency does not match Price List Currency for Price List") \
+ + ": " + d.price_list_name, raise_exception=PriceListCurrencyMismatch)
+
+ price_lists.append(d.price_list_name)
+
+
+ def fill_customer_code(self):
+ """ Append all the customer codes and insert into "customer_code" field of item table """
+ cust_code=[]
+ for d in getlist(self.doclist,'item_customer_details'):
+ cust_code.append(d.ref_code)
+ self.doc.customer_code=','.join(cust_code)
+
+ def check_item_tax(self):
+ """Check whether Tax Rate is not entered twice for same Tax Type"""
+ check_list=[]
+ for d in getlist(self.doclist,'item_tax'):
+ if d.tax_type:
+ account_type = webnotes.conn.get_value("Account", d.tax_type, "account_type")
+
+ if account_type not in ['Tax', 'Chargeable']:
+ msgprint("'%s' is not Tax / Chargeable Account" % d.tax_type, raise_exception=1)
+ else:
+ if d.tax_type in check_list:
+ msgprint("Rate is entered twice for: '%s'" % d.tax_type, raise_exception=1)
+ else:
+ check_list.append(d.tax_type)
+
+ def validate_barcode(self):
+ if self.doc.barcode:
+ duplicate = webnotes.conn.sql("""select name from tabItem where barcode = %s
+ and name != %s""", (self.doc.barcode, self.doc.name))
+ if duplicate:
+ msgprint("Barcode: %s already used in item: %s" %
+ (self.doc.barcode, cstr(duplicate[0][0])), raise_exception = 1)
+
+ def check_non_asset_warehouse(self):
+ if not self.doc.__islocal and self.doc.is_asset_item == "Yes":
+ existing_qty = webnotes.conn.sql("select t1.warehouse, t1.actual_qty from tabBin t1, tabWarehouse t2 where t1.item_code=%s and (t2.warehouse_type!='Fixed Asset' or t2.warehouse_type is null) and t1.warehouse=t2.name and t1.actual_qty > 0", self.doc.name)
+ for e in existing_qty:
+ msgprint("%s Units exist in Warehouse %s, which is not an Asset Warehouse." %
+ (e[1],e[0]))
+ if existing_qty:
+ self.doc.is_asset_item = 'No'
+ msgprint(_("""Please transfer the above quantities to an asset warehouse \
+ before changing this item to an asset item"""), raise_exception=1)
+
+ def cant_change(self):
+ if not self.doc.fields.get("__islocal"):
+ vals = webnotes.conn.get_value("Item", self.doc.name,
+ ["has_serial_no", "is_stock_item", "valuation_method"], as_dict=True)
+
+ if vals and ((self.doc.is_stock_item == "No" and vals.is_stock_item == "Yes") or
+ vals.has_serial_no != self.doc.has_serial_no or
+ vals.valuation_method != self.doc.valuation_method):
+ if self.check_if_sle_exists() == "exists":
+ webnotes.msgprint(_("As there are existing stock transactions for this \
+ item, you can not change the values of 'Has Serial No', \
+ 'Is Stock Item' and 'Valuation Method'"), raise_exception=1)
+
+ def validate_item_type_for_reorder(self):
+ if self.doc.re_order_level or len(self.doclist.get({"parentfield": "item_reorder",
+ "material_request_type": "Purchase"})):
+ if not self.doc.is_purchase_item:
+ webnotes.msgprint(_("""To set reorder level, item must be Purchase Item"""),
+ raise_exception=1)
+
+ def check_if_sle_exists(self):
+ sle = webnotes.conn.sql("""select name from `tabStock Ledger Entry`
+ where item_code = %s and ifnull(is_cancelled, 'No') = 'No'""", self.doc.name)
+ return sle and 'exists' or 'not exists'
def validate_name_with_item_group(self):
if webnotes.conn.exists("Item Group", self.doc.name):
@@ -104,107 +250,17 @@ class DocType(DocListController):
webnotes.conn.set(self.doc, "page_name", None)
- # On delete 1. Delete BIN (if none of the corrosponding transactions present, it gets deleted. if present, rolled back due to exception)
- def on_trash(self):
- webnotes.conn.sql("""delete from tabBin where item_code=%s""", self.doc.item_code)
- webnotes.conn.sql("""delete from `tabStock Ledger Entry`
- where item_code=%s and is_cancelled='Yes' """, self.doc.item_code)
-
- if self.doc.page_name:
- from webnotes.webutils import clear_cache
- clear_cache(self.doc.page_name)
-
- # Check whether Ref Rate is not entered twice for same Price List and Currency
- def check_ref_rate_detail(self):
- check_list=[]
- for d in getlist(self.doclist,'ref_rate_details'):
- if [cstr(d.price_list_name),cstr(d.ref_currency),cint(d.selling),cint(d.buying)] in check_list:
- msgprint("Ref Rate is entered twice for Price List : '%s' and Currency : '%s'." % (d.price_list_name,d.ref_currency))
- raise Exception
- else:
- check_list.append([cstr(d.price_list_name),cstr(d.ref_currency)])
+ def get_tax_rate(self, tax_type):
+ return { "tax_rate": webnotes.conn.get_value("Account", tax_type, "tax_rate") }
- # Append all the customer codes and insert into "customer_code" field of item table
- def fill_customer_code(self):
- cust_code=[]
- for d in getlist(self.doclist,'item_customer_details'):
- cust_code.append(d.ref_code)
- self.doc.customer_code=','.join(cust_code)
+ def prepare_template_args(self):
+ from website.helpers.product import get_parent_item_groups
+ self.parent_groups = get_parent_item_groups(self.doc.item_group) + [{"name":self.doc.name}]
+ self.doc.title = self.doc.item_name
- def check_item_tax(self):
- """Check whether Tax Rate is not entered twice for same Tax Type"""
- check_list=[]
- for d in getlist(self.doclist,'item_tax'):
- if d.tax_type:
- account_type = webnotes.conn.get_value("Account", d.tax_type, "account_type")
-
- if account_type not in ['Tax', 'Chargeable']:
- msgprint("'%s' is not Tax / Chargeable Account" % d.tax_type, raise_exception=1)
- else:
- if d.tax_type in check_list:
- msgprint("Rate is entered twice for: '%s'" % d.tax_type, raise_exception=1)
- else:
- check_list.append(d.tax_type)
-
- def check_for_active_boms(self, field_label):
- if field_label in ['Is Active', 'Is Purchase Item']:
- bom_mat = webnotes.conn.sql("select distinct t1.parent from `tabBOM Item` t1, `tabBOM` t2 where t1.item_code =%s and (t1.bom_no = '' or t1.bom_no is NULL) and t2.name = t1.parent and t2.is_active = 1 and t2.docstatus = 1 and t1.docstatus =1 ", self.doc.name)
- if bom_mat and bom_mat[0][0]:
- msgprint("%s should be 'Yes'. As Item %s is present in one or many Active BOMs." % (cstr(field_label), cstr(self.doc.name)))
- raise Exception
- if ((field_label == 'Allow Production Order'
- and self.doc.is_sub_contracted_item != 'Yes')
- or (field_label == 'Is Sub Contracted Item'
- and self.doc.is_manufactured_item != 'Yes')):
- bom = webnotes.conn.sql("select name from `tabBOM` where item = %s and is_active = 1",
- (self.doc.name,))
- if bom and bom[0][0]:
- msgprint("%s should be 'Yes'. As Item %s is present in one or many Active BOMs." % (cstr(field_label), cstr(self.doc.name)))
- raise Exception
-
- def validate_barcode(self):
- if self.doc.barcode:
- duplicate = webnotes.conn.sql("select name from tabItem where barcode = %s and name != %s", (self.doc.barcode, self.doc.name))
- if duplicate:
- msgprint("Barcode: %s already used in item: %s" % (self.doc.barcode, cstr(duplicate[0][0])), raise_exception = 1)
-
- def validate(self):
- if not cint(self.doc.fields.get("__islocal")):
- fl = {'is_manufactured_item' :'Allow Bill of Materials',
- 'is_sub_contracted_item':'Is Sub Contracted Item',
- 'is_purchase_item' :'Is Purchase Item',
- 'is_pro_applicable' :'Allow Production Order'}
- for d in fl:
- if cstr(self.doc.fields.get(d)) != 'Yes':
- self.check_for_active_boms(fl[d])
- self.check_ref_rate_detail()
- self.fill_customer_code()
- self.check_item_tax()
- self.validate_barcode()
- self.check_non_asset_warehouse()
- self.cant_change()
-
- if cstr(self.doc.is_manufactured_item) == "No":
- self.doc.is_pro_applicable = "No"
-
- if self.doc.is_pro_applicable == 'Yes' and self.doc.is_stock_item == 'No':
- msgprint("As Production Order can be made for this Item, then Is Stock Item Should be 'Yes' as we maintain it's stock. Refer Manufacturing and Inventory section.", raise_exception=1)
-
- if self.doc.has_serial_no == 'Yes' and self.doc.is_stock_item == 'No':
- msgprint("'Has Serial No' can not be 'Yes' for non-stock item", raise_exception=1)
-
- if self.doc.name:
- self.old_page_name = webnotes.conn.get_value('Item', self.doc.name, 'page_name')
-
- def check_non_asset_warehouse(self):
- if self.doc.is_asset_item == "Yes":
- existing_qty = webnotes.conn.sql("select t1.warehouse, t1.actual_qty from tabBin t1, tabWarehouse t2 where t1.item_code=%s and (t2.warehouse_type!='Fixed Asset' or t2.warehouse_type is null) and t1.warehouse=t2.name and t1.actual_qty > 0", self.doc.name)
- for e in existing_qty:
- msgprint("%s Units exist in Warehouse %s, which is not an Asset Warehouse." % (e[1],e[0]))
- if existing_qty:
- msgprint("Please transfer the above quantities to an asset warehouse before changing this item to an asset item.")
- self.doc.is_asset_item = 'No'
- raise Exception
+ if self.doc.slideshow:
+ from website.helpers.slideshow import get_slideshow
+ get_slideshow(self)
def get_file_details(self, arg = ''):
file = webnotes.conn.sql("select file_group, description from tabFile where name = %s", eval(arg)['file_name'], as_dict = 1)
@@ -215,35 +271,17 @@ class DocType(DocListController):
}
return ret
+ def on_trash(self):
+ webnotes.conn.sql("""delete from tabBin where item_code=%s""", self.doc.item_code)
+ webnotes.conn.sql("""delete from `tabStock Ledger Entry`
+ where item_code=%s and is_cancelled='Yes' """, self.doc.item_code)
- def check_if_sle_exists(self):
- sle = webnotes.conn.sql("select name from `tabStock Ledger Entry` where item_code = %s and ifnull(is_cancelled, 'No') = 'No'", self.doc.name)
- return sle and 'exists' or 'not exists'
-
- def on_rename(self,newdn,olddn):
- webnotes.conn.sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
if self.doc.page_name:
from webnotes.webutils import clear_cache
clear_cache(self.doc.page_name)
-
- def prepare_template_args(self):
- from website.helpers.product import get_parent_item_groups
- self.parent_groups = get_parent_item_groups(self.doc.item_group) + [{"name":self.doc.name}]
- self.doc.title = self.doc.item_name
- if self.doc.slideshow:
- from website.helpers.slideshow import get_slideshow
- get_slideshow(self)
-
- def cant_change(self):
- if not self.doc.fields.get("__islocal"):
- vals = webnotes.conn.get_value("Item", self.doc.name,
- ["has_serial_no", "is_stock_item", "valuation_method"], as_dict=True)
-
- if vals and ((self.doc.is_stock_item == "No" and vals.is_stock_item == "Yes") or
- vals.has_serial_no != self.doc.has_serial_no or
- vals.valuation_method != self.doc.valuation_method):
- if self.check_if_sle_exists() == "exists":
- webnotes.msgprint(_("As there are existing stock transactions for this \
- item, you can not change the values of 'Has Serial No', \
- 'Is Stock Item' and 'Valuation Method'"), raise_exception=1)
+ def on_rename(self,newdn,olddn, merge=False):
+ webnotes.conn.sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
+ if self.doc.page_name:
+ from webnotes.webutils import clear_cache
+ clear_cache(self.doc.page_name)
\ No newline at end of file
diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt
index b7f7be45ad3..9e0a2fb24e7 100644
--- a/stock/doctype/item/item.txt
+++ b/stock/doctype/item/item.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-07 15:53:11",
+ "creation": "2013-05-03 10:45:46",
"docstatus": 0,
- "modified": "2013-03-20 15:10:12",
+ "modified": "2013-05-22 15:48:27",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -33,6 +33,7 @@
"parent": "Item",
"parentfield": "permissions",
"parenttype": "DocType",
+ "permlevel": 0,
"read": 1,
"report": 1,
"submit": 0
@@ -47,7 +48,16 @@
"fieldtype": "Section Break",
"label": "Item",
"no_copy": 0,
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "naming_series",
+ "fieldtype": "Select",
+ "label": "Naming Series",
+ "options": "\nITEM",
+ "read_only": 0
},
{
"description": "Item will be saved by this name in the data base.",
@@ -56,9 +66,11 @@
"fieldtype": "Data",
"in_filter": 0,
"label": "Item Code",
+ "no_copy": 1,
"oldfieldname": "item_code",
"oldfieldtype": "Data",
- "reqd": 1,
+ "read_only": 0,
+ "reqd": 0,
"search_index": 0
},
{
@@ -70,6 +82,7 @@
"label": "Item Name",
"oldfieldname": "item_name",
"oldfieldtype": "Data",
+ "read_only": 0,
"reqd": 1,
"search_index": 1
},
@@ -83,6 +96,7 @@
"oldfieldname": "item_group",
"oldfieldtype": "Link",
"options": "Item Group",
+ "read_only": 0,
"reqd": 1
},
{
@@ -94,7 +108,8 @@
"oldfieldname": "stock_uom",
"oldfieldtype": "Link",
"options": "UOM",
- "reqd": 0
+ "read_only": 0,
+ "reqd": 1
},
{
"doctype": "DocField",
@@ -106,25 +121,29 @@
"oldfieldtype": "Link",
"options": "Brand",
"print_hide": 1,
+ "read_only": 0,
"reqd": 0
},
{
"doctype": "DocField",
"fieldname": "barcode",
"fieldtype": "Data",
- "label": "Barcode"
+ "label": "Barcode",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break0",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "image",
"fieldtype": "Select",
"label": "Image",
- "options": "attach_files:"
+ "options": "attach_files:",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -132,7 +151,8 @@
"fieldtype": "Image",
"in_list_view": 1,
"label": "Image View",
- "options": "image"
+ "options": "image",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -143,6 +163,7 @@
"label": "Description",
"oldfieldname": "description",
"oldfieldtype": "Text",
+ "read_only": 0,
"reqd": 1,
"search_index": 0
},
@@ -150,21 +171,24 @@
"doctype": "DocField",
"fieldname": "description_html",
"fieldtype": "Small Text",
- "label": "Description HTML"
+ "label": "Description HTML",
+ "read_only": 0
},
{
"description": "Generates HTML to include selected image in the description",
"doctype": "DocField",
"fieldname": "add_image",
"fieldtype": "Button",
- "label": "Generate Description HTML"
+ "label": "Generate Description HTML",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "inventory",
"fieldtype": "Section Break",
"label": "Inventory",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"default": "Yes",
@@ -176,6 +200,7 @@
"oldfieldname": "is_stock_item",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -187,7 +212,8 @@
"label": "Default Reserved Warehouse",
"oldfieldname": "default_warehouse",
"oldfieldtype": "Link",
- "options": "Warehouse"
+ "options": "Warehouse",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
@@ -197,7 +223,8 @@
"fieldtype": "Float",
"label": "Allowance Percent",
"oldfieldname": "tolerance",
- "oldfieldtype": "Currency"
+ "oldfieldtype": "Currency",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
@@ -205,7 +232,8 @@
"fieldname": "valuation_method",
"fieldtype": "Select",
"label": "Valuation Method",
- "options": "\nFIFO\nMoving Average"
+ "options": "\nFIFO\nMoving Average",
+ "read_only": 0
},
{
"default": "0.00",
@@ -217,7 +245,8 @@
"hidden": 0,
"label": "Minimum Order Qty",
"oldfieldname": "min_order_qty",
- "oldfieldtype": "Currency"
+ "oldfieldtype": "Currency",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
@@ -225,6 +254,7 @@
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -238,6 +268,7 @@
"oldfieldname": "is_asset_item",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -250,6 +281,7 @@
"oldfieldname": "has_batch_no",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -264,6 +296,7 @@
"oldfieldname": "has_serial_no",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -273,7 +306,8 @@
"fieldtype": "Data",
"label": "Warranty Period (in days)",
"oldfieldname": "warranty_period",
- "oldfieldtype": "Data"
+ "oldfieldtype": "Data",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
@@ -282,7 +316,8 @@
"fieldtype": "Date",
"label": "End of Life",
"oldfieldname": "end_of_life",
- "oldfieldtype": "Date"
+ "oldfieldtype": "Date",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
@@ -290,7 +325,8 @@
"doctype": "DocField",
"fieldname": "net_weight",
"fieldtype": "Float",
- "label": "Net Weight"
+ "label": "Net Weight",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
@@ -298,14 +334,16 @@
"fieldname": "weight_uom",
"fieldtype": "Link",
"label": "Weight UOM",
- "options": "UOM"
+ "options": "UOM",
+ "read_only": 0
},
{
"description": "Auto-raise Material Request if quantity goes below re-order level in a warehouse",
"doctype": "DocField",
"fieldname": "reorder_section",
"fieldtype": "Section Break",
- "label": "Re-order"
+ "label": "Re-order",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
@@ -314,47 +352,39 @@
"fieldtype": "Float",
"label": "Re-Order Level",
"oldfieldname": "re_order_level",
- "oldfieldtype": "Currency"
+ "oldfieldtype": "Currency",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"doctype": "DocField",
"fieldname": "re_order_qty",
"fieldtype": "Float",
- "label": "Re-Order Qty"
- },
- {
- "doctype": "DocField",
- "fieldname": "column_break_31",
- "fieldtype": "Column Break"
- },
- {
- "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"
+ "label": "Re-Order Qty",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "section_break_31",
"fieldtype": "Section Break",
- "options": "Simple"
+ "options": "Simple",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "item_reorder",
"fieldtype": "Table",
"label": "Warehouse-wise Item Reorder",
- "options": "Item Reorder"
+ "options": "Item Reorder",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "purchase_details",
"fieldtype": "Section Break",
"label": "Purchase Details",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"default": "Yes",
@@ -366,6 +396,7 @@
"oldfieldname": "is_purchase_item",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -377,7 +408,8 @@
"label": "Lead Time Days",
"no_copy": 1,
"oldfieldname": "lead_time_days",
- "oldfieldtype": "Int"
+ "oldfieldtype": "Int",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
@@ -388,7 +420,8 @@
"label": "Default Expense Account",
"oldfieldname": "purchase_account",
"oldfieldtype": "Link",
- "options": "Account"
+ "options": "Account",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
@@ -399,7 +432,8 @@
"label": "Default Cost Center",
"oldfieldname": "cost_center",
"oldfieldtype": "Link",
- "options": "Cost Center"
+ "options": "Cost Center",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
@@ -419,7 +453,8 @@
"fieldtype": "Float",
"label": "Standard Rate",
"oldfieldname": "standard_rate",
- "oldfieldtype": "Currency"
+ "oldfieldtype": "Currency",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
@@ -427,6 +462,7 @@
"fieldname": "column_break2",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -438,21 +474,24 @@
"no_copy": 1,
"oldfieldname": "uom_conversion_details",
"oldfieldtype": "Table",
- "options": "UOM Conversion Detail"
+ "options": "UOM Conversion Detail",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"doctype": "DocField",
"fieldname": "manufacturer",
"fieldtype": "Data",
- "label": "Manufacturer"
+ "label": "Manufacturer",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"doctype": "DocField",
"fieldname": "manufacturer_part_no",
"fieldtype": "Data",
- "label": "Manufacturer Part Number"
+ "label": "Manufacturer Part Number",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
@@ -460,14 +499,16 @@
"fieldname": "item_supplier_details",
"fieldtype": "Table",
"label": "Item Supplier Details",
- "options": "Item Supplier"
+ "options": "Item Supplier",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "sales_details",
"fieldtype": "Section Break",
"label": "Sales Details",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"default": "Yes",
@@ -480,6 +521,7 @@
"oldfieldname": "is_sales_item",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -494,6 +536,7 @@
"oldfieldname": "is_service_item",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -507,6 +550,7 @@
"oldfieldname": "is_sample_item",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -516,7 +560,8 @@
"fieldtype": "Float",
"label": "Max Discount (%)",
"oldfieldname": "max_discount",
- "oldfieldtype": "Currency"
+ "oldfieldtype": "Currency",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
@@ -524,7 +569,8 @@
"fieldname": "default_income_account",
"fieldtype": "Link",
"label": "Default Income Account",
- "options": "Account"
+ "options": "Account",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
@@ -532,7 +578,8 @@
"fieldname": "default_sales_cost_center",
"fieldtype": "Link",
"label": "Cost Center",
- "options": "Cost Center"
+ "options": "Cost Center",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
@@ -542,7 +589,8 @@
"hidden": 1,
"label": "Sales Rate",
"oldfieldname": "sales_rate",
- "oldfieldtype": "Currency"
+ "oldfieldtype": "Currency",
+ "read_only": 0
},
{
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
@@ -550,6 +598,7 @@
"fieldname": "column_break3",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -559,14 +608,16 @@
"fieldname": "item_customer_details",
"fieldtype": "Table",
"label": "Customer Codes",
- "options": "Item Customer Detail"
+ "options": "Item Customer Detail",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "item_tax_section_break",
"fieldtype": "Section Break",
"label": "Item Tax",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -575,13 +626,15 @@
"label": "Item Tax1",
"oldfieldname": "item_tax",
"oldfieldtype": "Table",
- "options": "Item Tax"
+ "options": "Item Tax",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "price_list_section",
"fieldtype": "Section Break",
- "label": "Price Lists and Rates"
+ "label": "Price Lists and Rates",
+ "read_only": 0
},
{
"description": "Create a price list from Price List master and enter standard ref rates against each of them. On selection of a price list in Quotation, Sales Order or Delivery Note, corresponding ref rate will be fetched for this item.",
@@ -591,14 +644,16 @@
"label": "Item Prices",
"oldfieldname": "ref_rate_details",
"oldfieldtype": "Table",
- "options": "Item Price"
+ "options": "Item Price",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "inspection_criteria",
"fieldtype": "Section Break",
"label": "Inspection Criteria",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"default": "No",
@@ -610,6 +665,7 @@
"oldfieldname": "inspection_required",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -621,14 +677,16 @@
"label": "Item Quality Inspection Parameter",
"oldfieldname": "item_specification_details",
"oldfieldtype": "Table",
- "options": "Item Quality Inspection Parameter"
+ "options": "Item Quality Inspection Parameter",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "manufacturing",
"fieldtype": "Section Break",
"label": "Manufacturing",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"default": "No",
@@ -640,6 +698,7 @@
"oldfieldname": "is_manufactured_item",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -665,6 +724,7 @@
"oldfieldname": "is_pro_applicable",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
{
@@ -677,17 +737,9 @@
"oldfieldname": "is_sub_contracted_item",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"reqd": 1
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"doctype": "DocField",
"fieldname": "customer_code",
@@ -696,19 +748,22 @@
"in_filter": 1,
"label": "Customer Code",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "website_section",
"fieldtype": "Section Break",
- "label": "Website"
+ "label": "Website",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "show_in_website",
"fieldtype": "Check",
- "label": "Show in Website"
+ "label": "Show in Website",
+ "read_only": 0
},
{
"depends_on": "show_in_website",
@@ -726,6 +781,7 @@
"fieldname": "weightage",
"fieldtype": "Int",
"label": "Weightage",
+ "read_only": 0,
"search_index": 1
},
{
@@ -735,7 +791,8 @@
"fieldname": "slideshow",
"fieldtype": "Link",
"label": "Slideshow",
- "options": "Website Slideshow"
+ "options": "Website Slideshow",
+ "read_only": 0
},
{
"depends_on": "show_in_website",
@@ -744,12 +801,14 @@
"fieldname": "website_image",
"fieldtype": "Select",
"label": "Image",
- "options": "attach_files:"
+ "options": "attach_files:",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "cb72",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "read_only": 0
},
{
"depends_on": "show_in_website",
@@ -758,7 +817,8 @@
"fieldname": "website_price_list",
"fieldtype": "Link",
"label": "Website Price List",
- "options": "Price List"
+ "options": "Price List",
+ "read_only": 0
},
{
"depends_on": "show_in_website",
@@ -767,7 +827,8 @@
"fieldname": "website_warehouse",
"fieldtype": "Link",
"label": "Website Warehouse",
- "options": "Warehouse"
+ "options": "Warehouse",
+ "read_only": 0
},
{
"depends_on": "show_in_website",
@@ -776,19 +837,22 @@
"fieldname": "website_item_groups",
"fieldtype": "Table",
"label": "Website Item Groups",
- "options": "Website Item Group"
+ "options": "Website Item Group",
+ "read_only": 0
},
{
"depends_on": "show_in_website",
"doctype": "DocField",
"fieldname": "sb72",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "copy_from_item_group",
"fieldtype": "Button",
- "label": "Copy From Item Group"
+ "label": "Copy From Item Group",
+ "read_only": 0
},
{
"depends_on": "show_in_website",
@@ -796,37 +860,21 @@
"fieldname": "item_website_specifications",
"fieldtype": "Table",
"label": "Item Website Specifications",
- "options": "Item Website Specification"
+ "options": "Item Website Specification",
+ "read_only": 0
},
{
"depends_on": "show_in_website",
"doctype": "DocField",
"fieldname": "web_long_description",
"fieldtype": "Text Editor",
- "label": "Website Description"
+ "label": "Website Description",
+ "read_only": 0
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
- "permlevel": 0,
- "role": "System Manager",
- "write": 1
- },
- {
- "amend": 0,
- "cancel": 0,
- "create": 0,
- "doctype": "DocPerm",
- "permlevel": 1,
- "role": "Material Master Manager",
- "write": 0
- },
- {
- "cancel": 1,
- "create": 1,
- "doctype": "DocPerm",
- "permlevel": 0,
"role": "Material Master Manager",
"write": 1
},
@@ -835,15 +883,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "permlevel": 1,
- "role": "System Manager"
- },
- {
- "amend": 0,
- "cancel": 0,
- "create": 0,
- "doctype": "DocPerm",
- "permlevel": 1,
"role": "Material Manager",
"write": 0
},
@@ -852,25 +891,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "permlevel": 0,
- "role": "Material Manager",
- "write": 0
- },
- {
- "amend": 0,
- "cancel": 0,
- "create": 0,
- "doctype": "DocPerm",
- "permlevel": 1,
- "role": "Material User",
- "write": 0
- },
- {
- "amend": 0,
- "cancel": 0,
- "create": 0,
- "doctype": "DocPerm",
- "permlevel": 0,
"role": "Material User",
"write": 0
}
diff --git a/stock/doctype/item/test_item.py b/stock/doctype/item/test_item.py
index dbbeecc85b3..f5a688ca701 100644
--- a/stock/doctype/item/test_item.py
+++ b/stock/doctype/item/test_item.py
@@ -20,6 +20,22 @@ import webnotes
test_ignore = ["BOM"]
+class TestItem(unittest.TestCase):
+ def test_duplicate_price_list(self):
+ item = webnotes.bean(copy=test_records[0])
+ item.doc.item_code = "_Test Item 10"
+ item_price = item.doclist.get({"doctype": "Item Price"})[0]
+ item.doclist.append(webnotes.doc(item_price.fields.copy()))
+ self.assertRaises(webnotes.DuplicateEntryError, item.insert)
+
+ def test_price_list_mismatch(self):
+ from stock.doctype.item.item import PriceListCurrencyMismatch
+ item = webnotes.bean(copy=test_records[0])
+ item.doc.item_code = "_Test Item 11"
+ item_price = item.doclist.get({"doctype": "Item Price"})[0].ref_currency="USD"
+ self.assertRaises(PriceListCurrencyMismatch, item.insert)
+
+
test_records = [
[{
"doctype": "Item",
@@ -45,7 +61,14 @@ test_records = [
"warehouse": "_Test Warehouse",
"warehouse_reorder_level": 20,
"warehouse_reorder_qty": 20
- }],
+ }, {
+ "doctype": "Item Price",
+ "parentfield": "ref_rate_details",
+ "price_list_name": "_Test Price List",
+ "ref_rate": 100,
+ "ref_currency": "INR"
+ }
+ ],
[{
"doctype": "Item",
"item_code": "_Test Item Home Desktop 100",
diff --git a/stock/doctype/item_price/item_price.txt b/stock/doctype/item_price/item_price.txt
index 721902bc72b..ad0b840c112 100644
--- a/stock/doctype/item_price/item_price.txt
+++ b/stock/doctype/item_price/item_price.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-08 15:37:16",
+ "creation": "2013-04-29 15:18:04",
"docstatus": 0,
- "modified": "2013-03-21 17:29:15",
+ "modified": "2013-04-29 19:16:45",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -68,13 +68,13 @@
"doctype": "DocField",
"fieldname": "selling",
"fieldtype": "Check",
- "label": "For Selling"
+ "label": "Valid For Selling"
},
{
"description": "Allow this price in purchase related forms",
"doctype": "DocField",
"fieldname": "buying",
"fieldtype": "Check",
- "label": "For Buying"
+ "label": "Valid For Buying"
}
]
\ No newline at end of file
diff --git a/stock/doctype/material_request/material_request.txt b/stock/doctype/material_request/material_request.txt
index f2e6b3573a1..eb788e41edf 100644
--- a/stock/doctype/material_request/material_request.txt
+++ b/stock/doctype/material_request/material_request.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-02-21 14:15:25",
+ "creation": "2013-03-07 14:48:38",
"docstatus": 0,
"modified": "2013-02-25 15:38:02",
"modified_by": "Administrator",
@@ -331,15 +331,6 @@
"options": "Print Heading",
"print_hide": 1
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"amend": 0,
"cancel": 0,
diff --git a/stock/doctype/material_request/test_material_request.py b/stock/doctype/material_request/test_material_request.py
index 080989f2d90..f5dbb52bbef 100644
--- a/stock/doctype/material_request/test_material_request.py
+++ b/stock/doctype/material_request/test_material_request.py
@@ -263,6 +263,12 @@ class TestMaterialRequest(unittest.TestCase):
se = webnotes.bean(copy=se_doclist)
self.assertRaises(webnotes.MappingMismatchError, se.insert)
+ def test_warehouse_company_validation(self):
+ from controllers.buying_controller import WrongWarehouseCompany
+ mr = webnotes.bean(copy=test_records[0])
+ mr.doc.company = "_Test Company 1"
+ self.assertRaises(WrongWarehouseCompany, mr.insert)
+
test_records = [
[
{
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.txt b/stock/doctype/purchase_receipt/purchase_receipt.txt
index 3ecbb039473..350777d95c1 100755
--- a/stock/doctype/purchase_receipt/purchase_receipt.txt
+++ b/stock/doctype/purchase_receipt/purchase_receipt.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-01-22 15:24:18",
+ "creation": "2013-03-25 16:01:29",
"docstatus": 0,
"modified": "2013-02-02 19:09:37",
"modified_by": "Administrator",
@@ -31,9 +31,7 @@
"parent": "Purchase Receipt",
"parentfield": "permissions",
"parenttype": "DocType",
- "permlevel": 0,
- "read": 1,
- "report": 1
+ "read": 1
},
{
"doctype": "DocType",
@@ -886,44 +884,78 @@
"read_only": 1
},
{
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
- {
- "amend": 1,
- "cancel": 1,
- "create": 1,
- "doctype": "DocPerm",
- "role": "Purchase User",
- "submit": 1,
- "write": 1
- },
- {
- "doctype": "DocPerm",
- "match": "supplier",
- "role": "Supplier"
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "match": "",
+ "permlevel": 1,
+ "report": 0,
+ "role": "Material Manager",
+ "submit": 0,
+ "write": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
+ "permlevel": 0,
+ "report": 1,
"role": "Material Manager",
"submit": 1,
"write": 1
},
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "match": "",
+ "permlevel": 1,
+ "report": 0,
+ "role": "Material User",
+ "submit": 0,
+ "write": 0
+ },
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
+ "permlevel": 0,
+ "report": 1,
"role": "Material User",
"submit": 1,
"write": 1
+ },
+ {
+ "amend": 1,
+ "cancel": 1,
+ "create": 1,
+ "doctype": "DocPerm",
+ "match": "",
+ "permlevel": 0,
+ "report": 1,
+ "role": "Purchase User",
+ "submit": 1,
+ "write": 1
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
+ "doctype": "DocPerm",
+ "match": "",
+ "permlevel": 1,
+ "role": "Purchase User",
+ "submit": 0
+ },
+ {
+ "doctype": "DocPerm",
+ "match": "supplier",
+ "permlevel": 0,
+ "report": 1,
+ "role": "Supplier"
}
]
\ No newline at end of file
diff --git a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
index 7f4e827aa30..8cef6a35340 100755
--- a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
+++ b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-02-22 01:28:03",
+ "creation": "2013-03-07 11:42:59",
"docstatus": 0,
- "modified": "2013-03-07 07:03:28",
+ "modified": "2013-05-22 12:01:08",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -35,6 +35,7 @@
"oldfieldtype": "Link",
"options": "Item",
"print_width": "100px",
+ "read_only": 0,
"reqd": 1,
"search_index": 1,
"width": "100px"
@@ -48,6 +49,7 @@
"oldfieldname": "item_name",
"oldfieldtype": "Data",
"print_hide": 1,
+ "read_only": 0,
"reqd": 1,
"search_index": 0
},
@@ -59,6 +61,7 @@
"oldfieldname": "description",
"oldfieldtype": "Text",
"print_width": "300px",
+ "read_only": 0,
"reqd": 1,
"width": "300px"
},
@@ -72,6 +75,7 @@
"oldfieldtype": "Currency",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"reqd": 1,
"width": "100px"
},
@@ -84,6 +88,7 @@
"oldfieldname": "qty",
"oldfieldtype": "Currency",
"print_width": "100px",
+ "read_only": 0,
"width": "100px"
},
{
@@ -97,6 +102,7 @@
"oldfieldtype": "Currency",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"search_index": 0,
"width": "100px"
},
@@ -110,6 +116,7 @@
"options": "UOM",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"reqd": 1,
"width": "100px"
},
@@ -119,14 +126,16 @@
"fieldtype": "Currency",
"label": "Ref Rate ",
"options": "currency",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "discount_rate",
"fieldtype": "Float",
"label": "Discount %",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"default": "0.00",
@@ -139,6 +148,7 @@
"options": "currency",
"print_hide": 0,
"print_width": "100px",
+ "read_only": 0,
"width": "100px"
},
{
@@ -157,7 +167,8 @@
"fieldtype": "Currency",
"label": "Ref Rate*",
"options": "Company:company:default_currency",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"default": "0.00",
@@ -170,6 +181,7 @@
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"reqd": 1,
"width": "100px"
},
@@ -184,6 +196,7 @@
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"reqd": 0,
"width": "100px"
},
@@ -198,6 +211,7 @@
"options": "Warehouse",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"width": "100px"
},
{
@@ -209,6 +223,7 @@
"oldfieldtype": "Currency",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"reqd": 1,
"width": "100px"
},
@@ -235,6 +250,7 @@
"oldfieldname": "serial_no",
"oldfieldtype": "Text",
"print_hide": 0,
+ "read_only": 0,
"report_hide": 0
},
{
@@ -242,7 +258,8 @@
"fieldname": "rejected_serial_no",
"fieldtype": "Text",
"label": "Rejected Serial No",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -252,7 +269,8 @@
"oldfieldname": "batch_no",
"oldfieldtype": "Link",
"options": "Batch",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -278,6 +296,7 @@
"oldfieldname": "schedule_date",
"oldfieldtype": "Date",
"print_hide": 1,
+ "read_only": 0,
"report_hide": 0,
"reqd": 0
},
@@ -288,7 +307,8 @@
"in_filter": 1,
"label": "Project Name",
"options": "Project",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -299,7 +319,8 @@
"oldfieldname": "qa_no",
"oldfieldtype": "Link",
"options": "Quality Inspection",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -336,6 +357,7 @@
"oldfieldtype": "Currency",
"print_hide": 1,
"print_width": "100px",
+ "read_only": 0,
"width": "100px"
},
{
@@ -344,9 +366,11 @@
"fieldtype": "Data",
"hidden": 1,
"label": "Prevdoc Doctype",
+ "no_copy": 1,
"oldfieldname": "prevdoc_doctype",
"oldfieldtype": "Data",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -355,7 +379,7 @@
"hidden": 0,
"in_filter": 1,
"label": "PO No",
- "no_copy": 0,
+ "no_copy": 1,
"oldfieldname": "prevdoc_docname",
"oldfieldtype": "Link",
"options": "Purchase Order",
@@ -373,6 +397,7 @@
"hidden": 1,
"in_filter": 1,
"label": "PO Date",
+ "no_copy": 1,
"oldfieldname": "prevdoc_date",
"oldfieldtype": "Date",
"print_hide": 1,
@@ -418,7 +443,7 @@
"hidden": 1,
"in_filter": 1,
"label": "Purchase Order Item No",
- "no_copy": 0,
+ "no_copy": 1,
"oldfieldname": "prevdoc_detail_docname",
"oldfieldtype": "Data",
"print_hide": 1,
@@ -479,6 +504,7 @@
"label": "Page Break",
"oldfieldname": "page_break",
"oldfieldtype": "Check",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 0
}
]
\ No newline at end of file
diff --git a/stock/doctype/sales_bom/__init__.py b/stock/doctype/sales_bom/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/stock/doctype/sales_bom/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/doctype/sales_bom_item/__init__.py b/stock/doctype/sales_bom_item/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/stock/doctype/sales_bom_item/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py
index bbf55b35e37..09181db0d27 100644
--- a/stock/doctype/serial_no/serial_no.py
+++ b/stock/doctype/serial_no/serial_no.py
@@ -19,7 +19,7 @@ import webnotes
from webnotes.utils import cint, getdate, nowdate
import datetime
-from webnotes import msgprint
+from webnotes import msgprint, _
from controllers.stock_controller import StockController
@@ -117,8 +117,11 @@ class DocType(StockController):
self.make_stock_ledger_entry(1)
self.make_gl_entries()
- def on_rename(self, new, old):
+ def on_rename(self, new, old, merge=False):
"""rename serial_no text fields"""
+ if merge:
+ msgprint(_("Sorry. Serial Nos. cannot be merged"), raise_exception=True)
+
for dt in webnotes.conn.sql("""select parent from tabDocField
where fieldname='serial_no' and fieldtype='Text'"""):
@@ -139,7 +142,8 @@ class DocType(StockController):
gl_entries = self.get_gl_entries_for_stock(against_stock_account, self.doc.purchase_rate)
for entry in gl_entries:
- entry["posting_date"] = self.doc.purchase_date
+ entry["posting_date"] = self.doc.purchase_date or (self.doc.creation and
+ self.doc.creation.split(' ')[0]) or nowdate()
if gl_entries:
make_gl_entries(gl_entries, cancel)
\ No newline at end of file
diff --git a/stock/doctype/serial_no/serial_no.txt b/stock/doctype/serial_no/serial_no.txt
index 086575f5936..33160c785fe 100644
--- a/stock/doctype/serial_no/serial_no.txt
+++ b/stock/doctype/serial_no/serial_no.txt
@@ -1,14 +1,14 @@
[
{
- "creation": "2013-01-10 16:34:29",
+ "creation": "2013-05-16 10:59:15",
"docstatus": 0,
- "modified": "2013-01-29 16:27:57",
+ "modified": "2013-06-20 11:23:01",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 1,
- "allow_rename": 1,
+ "allow_rename": 0,
"autoname": "field:serial_no",
"description": "Distinct unit of an Item",
"doctype": "DocType",
@@ -32,7 +32,9 @@
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
- "read": 1
+ "read": 1,
+ "report": 1,
+ "submit": 0
},
{
"doctype": "DocType",
@@ -43,12 +45,14 @@
"fieldname": "details",
"fieldtype": "Section Break",
"label": "Details",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break0",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "read_only": 0
},
{
"default": "In Store",
@@ -75,6 +79,7 @@
"no_copy": 1,
"oldfieldname": "serial_no",
"oldfieldtype": "Data",
+ "read_only": 0,
"reqd": 1,
"search_index": 1
},
@@ -88,13 +93,15 @@
"oldfieldname": "item_code",
"oldfieldtype": "Link",
"options": "Item",
+ "read_only": 0,
"reqd": 1,
"search_index": 0
},
{
"doctype": "DocField",
"fieldname": "column_break1",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -146,12 +153,14 @@
"doctype": "DocField",
"fieldname": "purchase_details",
"fieldtype": "Section Break",
- "label": "Purchase Details"
+ "label": "Purchase Details",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break2",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -160,7 +169,8 @@
"fieldtype": "Select",
"label": "Purchase Document Type",
"no_copy": 1,
- "options": "\nPurchase Receipt\nStock Entry"
+ "options": "\nPurchase Receipt\nStock Entry",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -168,7 +178,8 @@
"fieldtype": "Data",
"hidden": 0,
"label": "Purchase Document No",
- "no_copy": 1
+ "no_copy": 1,
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -179,6 +190,7 @@
"no_copy": 1,
"oldfieldname": "purchase_date",
"oldfieldtype": "Date",
+ "read_only": 0,
"reqd": 0,
"search_index": 0
},
@@ -188,6 +200,7 @@
"fieldtype": "Time",
"label": "Incoming Time",
"no_copy": 1,
+ "read_only": 0,
"reqd": 1
},
{
@@ -200,6 +213,7 @@
"oldfieldname": "purchase_rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
+ "read_only": 0,
"reqd": 1,
"search_index": 0
},
@@ -207,6 +221,7 @@
"doctype": "DocField",
"fieldname": "column_break3",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -220,6 +235,7 @@
"oldfieldname": "warehouse",
"oldfieldtype": "Link",
"options": "Warehouse",
+ "read_only": 0,
"reqd": 0,
"search_index": 1
},
@@ -230,7 +246,8 @@
"in_filter": 1,
"label": "Supplier",
"no_copy": 1,
- "options": "Supplier"
+ "options": "Supplier",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -254,12 +271,14 @@
"fieldname": "delivery_details",
"fieldtype": "Section Break",
"label": "Delivery Details",
- "oldfieldtype": "Column Break"
+ "oldfieldtype": "Column Break",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break4",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -318,12 +337,14 @@
"oldfieldname": "is_cancelled",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
+ "read_only": 0,
"report_hide": 1
},
{
"doctype": "DocField",
"fieldname": "column_break5",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -378,12 +399,14 @@
"doctype": "DocField",
"fieldname": "warranty_amc_details",
"fieldtype": "Section Break",
- "label": "Warranty / AMC Details"
+ "label": "Warranty / AMC Details",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break6",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -396,6 +419,7 @@
"oldfieldname": "maintenance_status",
"oldfieldtype": "Select",
"options": "\nUnder Warranty\nOut of Warranty\nUnder AMC\nOut of AMC",
+ "read_only": 0,
"search_index": 1,
"width": "150px"
},
@@ -406,12 +430,14 @@
"label": "Warranty Period (Days)",
"oldfieldname": "warranty_period",
"oldfieldtype": "Int",
+ "read_only": 0,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "column_break7",
"fieldtype": "Column Break",
+ "read_only": 0,
"width": "50%"
},
{
@@ -422,6 +448,7 @@
"label": "Warranty Expiry Date",
"oldfieldname": "warranty_expiry_date",
"oldfieldtype": "Date",
+ "read_only": 0,
"width": "150px"
},
{
@@ -432,6 +459,7 @@
"label": "AMC Expiry Date",
"oldfieldname": "amc_expiry_date",
"oldfieldtype": "Date",
+ "read_only": 0,
"search_index": 0,
"width": "150px"
},
@@ -439,13 +467,15 @@
"doctype": "DocField",
"fieldname": "more_info",
"fieldtype": "Section Break",
- "label": "More Info"
+ "label": "More Info",
+ "read_only": 0
},
{
"doctype": "DocField",
"fieldname": "serial_no_details",
"fieldtype": "Text Editor",
- "label": "Serial No Details"
+ "label": "Serial No Details",
+ "read_only": 0
},
{
"doctype": "DocField",
@@ -454,6 +484,7 @@
"in_filter": 1,
"label": "Company",
"options": "link:Company",
+ "read_only": 0,
"reqd": 1,
"search_index": 1
},
@@ -464,6 +495,7 @@
"in_filter": 1,
"label": "Fiscal Year",
"options": "link:Fiscal Year",
+ "read_only": 0,
"reqd": 1,
"search_index": 1
},
@@ -476,15 +508,6 @@
"oldfieldtype": "Small Text",
"read_only": 1
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"doctype": "DocField",
"fieldname": "sle_exists",
@@ -500,21 +523,30 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
- "report": 1,
- "role": "Material User",
- "submit": 0,
+ "role": "System Manager",
"write": 1
},
{
+ "cancel": 1,
+ "create": 1,
"doctype": "DocPerm",
- "role": "Sales User"
+ "role": "Material Master Manager",
+ "write": 1
},
{
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
"doctype": "DocPerm",
- "role": "Purchase User"
+ "role": "Material Manager",
+ "write": 0
},
{
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
"doctype": "DocPerm",
- "role": "Accounts User"
+ "role": "Material User",
+ "write": 0
}
]
\ No newline at end of file
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index fa600725185..522a14af6ba 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -57,6 +57,7 @@ class DocType(StockController):
self.validate_return_reference_doc()
self.validate_with_material_request()
self.validate_fiscal_year()
+ self.set_total_amount()
def on_submit(self):
self.update_serial_no(1)
@@ -174,6 +175,9 @@ class DocType(StockController):
elif self.doc.purpose != "Material Transfer":
self.doc.production_order = None
+ def set_total_amount(self):
+ self.doc.total_amount = sum([flt(item.amount) for item in self.doclist.get({"parentfield": "mtn_details"})])
+
def make_gl_entries(self):
if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")):
return
@@ -194,10 +198,10 @@ class DocType(StockController):
total_valuation_amount = 0
for item in self.doclist.get({"parentfield": "mtn_details"}):
if item.t_warehouse and not item.s_warehouse:
- total_valuation_amount += flt(item.incoming_rate) * flt(item.transfer_qty)
+ total_valuation_amount += flt(item.incoming_rate, 2) * flt(item.transfer_qty)
if item.s_warehouse and not item.t_warehouse:
- total_valuation_amount -= flt(item.incoming_rate) * flt(item.transfer_qty)
+ total_valuation_amount -= flt(item.incoming_rate, 2) * flt(item.transfer_qty)
return total_valuation_amount
@@ -220,7 +224,7 @@ class DocType(StockController):
if not flt(d.incoming_rate):
d.incoming_rate = self.get_incoming_rate(args)
- d.amount = flt(d.qty) * flt(d.incoming_rate)
+ d.amount = flt(d.transfer_qty) * flt(d.incoming_rate)
def get_incoming_rate(self, args):
incoming_rate = 0
@@ -502,17 +506,13 @@ class DocType(StockController):
if self.doc.use_multi_level_bom:
# get all raw materials with sub assembly childs
- fl_bom_sa_child_item = sql("""select
- item_code,ifnull(sum(qty_consumed_per_unit),0)*%s as qty,
- description,stock_uom
- from ( select distinct fb.name, fb.description, fb.item_code,
- fb.qty_consumed_per_unit, fb.stock_uom
- from `tabBOM Explosion Item` fb,`tabItem` it
- where it.name = fb.item_code and ifnull(it.is_pro_applicable, 'No') = 'No'
- and ifnull(it.is_sub_contracted_item, 'No') = 'No' and fb.docstatus<2
- and fb.parent=%s
- ) a
- group by item_code, stock_uom""" , (qty, self.doc.bom_no), as_dict=1)
+ fl_bom_sa_child_item = sql("""select fb.item_code,
+ ifnull(sum(fb.qty_consumed_per_unit),0)*%s as qty, fb.description, fb.stock_uom
+ from `tabBOM Explosion Item` fb,`tabItem` it
+ where it.name = fb.item_code and ifnull(it.is_pro_applicable, 'No') = 'No'
+ and ifnull(it.is_sub_contracted_item, 'No') = 'No' and fb.docstatus < 2
+ and fb.parent=%s group by item_code, stock_uom""",
+ (qty, self.doc.bom_no), as_dict=1)
if fl_bom_sa_child_item:
_make_items_dict(fl_bom_sa_child_item)
@@ -520,10 +520,10 @@ class DocType(StockController):
# Get all raw materials considering multi level BOM,
# if multi level bom consider childs of Sub-Assembly items
fl_bom_sa_items = sql("""select item_code,
- ifnull(sum(qty_consumed_per_unit), 0) * '%s' as qty,
+ ifnull(sum(qty_consumed_per_unit), 0) *%s as qty,
description, stock_uom from `tabBOM Item`
- where parent = '%s' and docstatus < 2
- group by item_code""" % (qty, self.doc.bom_no), as_dict=1)
+ where parent = %s and docstatus < 2
+ group by item_code""", (qty, self.doc.bom_no), as_dict=1)
if fl_bom_sa_items:
_make_items_dict(fl_bom_sa_items)
@@ -607,7 +607,7 @@ class DocType(StockController):
'voucher_no': self.doc.name,
'voucher_detail_no': d.name,
'actual_qty': qty,
- 'incoming_rate': flt(d.incoming_rate) or 0,
+ 'incoming_rate': flt(d.incoming_rate, 2) or 0,
'stock_uom': d.stock_uom,
'company': self.doc.company,
'is_cancelled': (is_cancelled ==1) and 'Yes' or 'No',
diff --git a/stock/doctype/stock_entry/stock_entry.txt b/stock/doctype/stock_entry/stock_entry.txt
index fef710b513e..d88b0b76fde 100644
--- a/stock/doctype/stock_entry/stock_entry.txt
+++ b/stock/doctype/stock_entry/stock_entry.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-28 15:56:40",
+ "creation": "2013-04-09 11:43:55",
"docstatus": 0,
- "modified": "2013-03-29 15:31:42",
+ "modified": "2013-05-09 13:31:00",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -518,6 +518,14 @@
"read_only": 0,
"width": "50%"
},
+ {
+ "doctype": "DocField",
+ "fieldname": "total_amount",
+ "fieldtype": "Currency",
+ "label": "Total Amount",
+ "options": "Company:company:default_currency",
+ "read_only": 1
+ },
{
"doctype": "DocField",
"fieldname": "project_name",
@@ -558,6 +566,14 @@
"read_only": 0,
"reqd": 1
},
+ {
+ "doctype": "DocField",
+ "fieldname": "col5",
+ "fieldtype": "Column Break",
+ "print_width": "50%",
+ "read_only": 0,
+ "width": "50%"
+ },
{
"allow_on_submit": 0,
"doctype": "DocField",
@@ -576,14 +592,6 @@
"reqd": 1,
"search_index": 0
},
- {
- "doctype": "DocField",
- "fieldname": "col5",
- "fieldtype": "Column Break",
- "print_width": "50%",
- "read_only": 0,
- "width": "50%"
- },
{
"allow_on_submit": 0,
"doctype": "DocField",
diff --git a/stock/doctype/stock_entry/test_stock_entry.py b/stock/doctype/stock_entry/test_stock_entry.py
index 7c406f8e8cb..2ab2b1dad8f 100644
--- a/stock/doctype/stock_entry/test_stock_entry.py
+++ b/stock/doctype/stock_entry/test_stock_entry.py
@@ -21,10 +21,15 @@ class TestStockEntry(unittest.TestCase):
st2.insert()
st2.submit()
+ from stock.utils import reorder_item
+ reorder_item()
+
mr_name = webnotes.conn.sql("""select parent from `tabMaterial Request Item`
where item_code='_Test Item'""")
self.assertTrue(mr_name)
+
+ webnotes.conn.set_default("company", self.old_default_company)
def test_warehouse_company_validation(self):
from stock.doctype.stock_ledger_entry.stock_ledger_entry import InvalidWarehouseCompany
@@ -71,7 +76,7 @@ class TestStockEntry(unittest.TestCase):
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
def test_material_issue_gl_entry(self):
- webnotes.conn.sql("delete from `tabStock Ledger Entry`")
+ self._clear_stock()
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
mr = webnotes.bean(copy=test_records[0])
@@ -111,9 +116,10 @@ class TestStockEntry(unittest.TestCase):
)
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
+ webnotes.conn.set_default("company", self.old_default_company)
def test_material_transfer_gl_entry(self):
- webnotes.conn.sql("delete from `tabStock Ledger Entry`")
+ self._clear_stock()
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
mr = webnotes.bean(copy=test_records[0])
@@ -145,6 +151,7 @@ class TestStockEntry(unittest.TestCase):
self.assertFalse(gl_entries)
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
+ webnotes.conn.set_default("company", self.old_default_company)
def check_stock_ledger_entries(self, voucher_type, voucher_no, expected_sle):
# check stock ledger entries
@@ -173,6 +180,9 @@ class TestStockEntry(unittest.TestCase):
def _clear_stock(self):
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
webnotes.conn.sql("""delete from `tabBin`""")
+
+ self.old_default_company = webnotes.conn.get_default("company")
+ webnotes.conn.set_default("company", "_Test Company")
def _insert_material_receipt(self):
self._clear_stock()
@@ -185,6 +195,8 @@ class TestStockEntry(unittest.TestCase):
se2.insert()
se2.submit()
+ webnotes.conn.set_default("company", self.old_default_company)
+
def _get_actual_qty(self):
return flt(webnotes.conn.get_value("Bin", {"item_code": "_Test Item",
"warehouse": "_Test Warehouse"}, "actual_qty"))
@@ -463,6 +475,8 @@ class TestStockEntry(unittest.TestCase):
self.assertEquals(actual_qty_1 - 5, actual_qty_2)
+ webnotes.conn.set_default("company", self.old_default_company)
+
return se, pr.doc.name
def test_over_stock_return(self):
@@ -563,6 +577,8 @@ class TestStockEntry(unittest.TestCase):
self.assertEquals(actual_qty_1 - 5, actual_qty_2)
+ webnotes.conn.set_default("company", self.old_default_company)
+
return se, pr.doc.name
test_records = [
diff --git a/stock/doctype/stock_ledger/stock_ledger.py b/stock/doctype/stock_ledger/stock_ledger.py
index 3c83de32600..8fdb50e7a44 100644
--- a/stock/doctype/stock_ledger/stock_ledger.py
+++ b/stock/doctype/stock_ledger/stock_ledger.py
@@ -114,7 +114,8 @@ class DocType:
def update_serial_purchase_details(self, obj, d, serial_no, is_submit, purpose = '', rejected=None):
exists = webnotes.conn.sql("select name, status, docstatus from `tabSerial No` where name = '%s'" % (serial_no))
if is_submit:
- if exists and exists[0][2] != 2 and purpose not in ['Material Transfer', 'Sales Return']:
+ if exists and exists[0][2] != 2 and \
+ purpose not in ['Material Transfer', "Material Receipt", 'Sales Return']:
msgprint("Serial No: %s already %s" % (serial_no, exists and exists[0][1]), raise_exception = 1)
elif exists:
s = Document('Serial No', exists and exists[0][0])
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.txt b/stock/doctype/stock_reconciliation/stock_reconciliation.txt
index 760620bb734..9b5b2a128a2 100644
--- a/stock/doctype/stock_reconciliation/stock_reconciliation.txt
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-26 06:51:17",
+ "creation": "2013-03-28 10:35:31",
"docstatus": 0,
- "modified": "2013-03-26 08:32:03",
+ "modified": "2013-04-10 13:44:19",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -52,6 +52,7 @@
"fieldname": "posting_date",
"fieldtype": "Date",
"in_filter": 0,
+ "in_list_view": 1,
"label": "Posting Date",
"oldfieldname": "reconciliation_date",
"oldfieldtype": "Date",
@@ -63,6 +64,7 @@
"fieldname": "posting_time",
"fieldtype": "Time",
"in_filter": 0,
+ "in_list_view": 1,
"label": "Posting Time",
"oldfieldname": "reconciliation_time",
"oldfieldtype": "Time",
@@ -148,6 +150,7 @@
"fieldname": "stock_value_difference",
"fieldtype": "Currency",
"hidden": 1,
+ "in_list_view": 1,
"label": "Stock Value Difference",
"print_hide": 1
},
diff --git a/stock/doctype/warehouse/test_warehouse.py b/stock/doctype/warehouse/test_warehouse.py
index 26501beab90..f3a04581a94 100644
--- a/stock/doctype/warehouse/test_warehouse.py
+++ b/stock/doctype/warehouse/test_warehouse.py
@@ -2,7 +2,8 @@ test_records = [
[{
"doctype": "Warehouse",
"warehouse_name": "_Test Warehouse",
- "warehouse_type": "_Test Warehouse Type"
+ "warehouse_type": "_Test Warehouse Type",
+ "company": "_Test Company"
}],
[{
"doctype": "Warehouse",
diff --git a/stock/page/stock_ageing/stock_ageing.js b/stock/page/stock_ageing/stock_ageing.js
index edad9a76a18..456f5f13670 100644
--- a/stock/page/stock_ageing/stock_ageing.js
+++ b/stock/page/stock_ageing/stock_ageing.js
@@ -95,6 +95,8 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
this.data = [].concat(this._data);
+ this.serialized_buying_rates = this.get_serialized_buying_rates();
+
$.each(this.data, function(i, d) {
me.reset_item_values(d);
});
diff --git a/stock/page/stock_balance/stock_balance.js b/stock/page/stock_balance/stock_balance.js
index 163b74f6291..f4deb4fcd48 100644
--- a/stock/page/stock_balance/stock_balance.js
+++ b/stock/page/stock_balance/stock_balance.js
@@ -119,7 +119,7 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({
var qty_diff = sl.qty;
var value_diff = me.get_value_diff(wh, sl, is_fifo);
-
+
if(sl_posting_date < from_date) {
item.opening_qty += qty_diff;
item.opening_value += value_diff;
@@ -146,6 +146,8 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({
} else {
break;
}
+
+ me.round_item_values(item);
}
}
diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js
index db77fced0ea..532eb664062 100644
--- a/stock/page/stock_home/stock_home.js
+++ b/stock/page/stock_home/stock_home.js
@@ -197,6 +197,42 @@ wn.module_page["Stock"] = [
route: "query-report/Item-Wise Price List",
doctype: "Item"
},
+ {
+ "label":wn._("Purchase In Transit"),
+ route: "query-report/Purchase In Transit",
+ },
+ {
+ "label":wn._("Requested Items To Be Transferred"),
+ route: "query-report/Requested Items To Be Transferred",
+ },
+ {
+ "label":wn._("Batch-Wise Balance History"),
+ route: "query-report/Batch-Wise Balance History",
+ },
+ {
+ "label":wn._("Warehouse-Wise Stock Balance"),
+ route: "query-report/Warehouse-Wise Stock Balance",
+ },
+ {
+ "label":wn._("Item Prices"),
+ route: "query-report/Item Prices",
+
+ },
+ {
+ "label":wn._("Itemwise Recommended Reorder Level"),
+ route: "query-report/Itemwise Recommended Reorder Level",
+ doctype: "Item"
+ },
+ {
+ "label":wn._("Delivery Note Trends"),
+ route: "query-report/Delivery Note Trends",
+ doctype: "Delivery Note"
+ },
+ {
+ "label":wn._("Purchase Receipt Trends"),
+ route: "query-report/Purchase Receipt Trends",
+ doctype: "Purchase Receipt"
+ },
]
}
]
diff --git a/stock/report/batch_wise_balance_history/__init__.py b/stock/report/batch_wise_balance_history/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/stock/report/batch_wise_balance_history/batch_wise_balance_history.js b/stock/report/batch_wise_balance_history/batch_wise_balance_history.js
new file mode 100644
index 00000000000..98293e45f70
--- /dev/null
+++ b/stock/report/batch_wise_balance_history/batch_wise_balance_history.js
@@ -0,0 +1,18 @@
+wn.query_reports["Batch-Wise Balance History"] = {
+ "filters": [
+ {
+ "fieldname":"from_date",
+ "label": "From Date",
+ "fieldtype": "Date",
+ "width": "80",
+ "default": sys_defaults.year_start_date,
+ },
+ {
+ "fieldname":"to_date",
+ "label": "To Date",
+ "fieldtype": "Date",
+ "width": "80",
+ "default": wn.datetime.get_today()
+ }
+ ]
+}
\ No newline at end of file
diff --git a/stock/report/batch_wise_balance_history/batch_wise_balance_history.py b/stock/report/batch_wise_balance_history/batch_wise_balance_history.py
new file mode 100644
index 00000000000..530465e9ae7
--- /dev/null
+++ b/stock/report/batch_wise_balance_history/batch_wise_balance_history.py
@@ -0,0 +1,98 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import flt
+
+def execute(filters=None):
+ if not filters: filters = {}
+
+ columns = get_columns(filters)
+ item_map = get_item_details(filters)
+ iwb_map = get_item_warehouse_batch_map(filters)
+
+ data = []
+ for item in sorted(iwb_map):
+ for wh in sorted(iwb_map[item]):
+ for batch in sorted(iwb_map[item][wh]):
+ qty_dict = iwb_map[item][wh][batch]
+ data.append([item, item_map[item]["item_name"],
+ item_map[item]["description"], wh, batch,
+ qty_dict.opening_qty, qty_dict.in_qty,
+ qty_dict.out_qty, qty_dict.bal_qty
+ ])
+
+ return columns, data
+
+def get_columns(filters):
+ """return columns based on filters"""
+
+ columns = ["Item:Link/Item:100"] + ["Item Name::150"] + ["Description::150"] + \
+ ["Warehouse:Link/Warehouse:100"] + ["Batch:Link/Batch:100"] + ["Opening Qty::90"] + \
+ ["In Qty::80"] + ["Out Qty::80"] + ["Balance Qty::90"]
+
+ return columns
+
+def get_conditions(filters):
+ conditions = ""
+ if not filters.get("from_date"):
+ webnotes.msgprint("Please enter From Date", raise_exception=1)
+
+ if filters.get("to_date"):
+ conditions += " and posting_date <= '%s'" % filters["to_date"]
+ else:
+ webnotes.msgprint("Please enter To Date", raise_exception=1)
+
+ return conditions
+
+#get all details
+def get_stock_ledger_entries(filters):
+ conditions = get_conditions(filters)
+ return webnotes.conn.sql("""select item_code, batch_no, warehouse,
+ posting_date, actual_qty
+ from `tabStock Ledger Entry`
+ where ifnull(is_cancelled, 'No') = 'No' %s order by item_code, warehouse""" %
+ conditions, as_dict=1)
+
+def get_item_warehouse_batch_map(filters):
+ sle = get_stock_ledger_entries(filters)
+ iwb_map = {}
+
+ for d in sle:
+ iwb_map.setdefault(d.item_code, {}).setdefault(d.warehouse, {})\
+ .setdefault(d.batch_no, webnotes._dict({
+ "opening_qty": 0.0, "in_qty": 0.0, "out_qty": 0.0, "bal_qty": 0.0
+ }))
+ qty_dict = iwb_map[d.item_code][d.warehouse][d.batch_no]
+ if d.posting_date < filters["from_date"]:
+ qty_dict.opening_qty += flt(d.actual_qty)
+ elif d.posting_date >= filters["from_date"] and d.posting_date <= filters["to_date"]:
+ if flt(d.actual_qty) > 0:
+ qty_dict.in_qty += flt(d.actual_qty)
+ else:
+ qty_dict.out_qty += abs(flt(d.actual_qty))
+
+ qty_dict.bal_qty += flt(d.actual_qty)
+
+ return iwb_map
+
+def get_item_details(filters):
+ item_map = {}
+ for d in webnotes.conn.sql("select name, item_name, description from tabItem", as_dict=1):
+ item_map.setdefault(d.name, d)
+
+ return item_map
\ No newline at end of file
diff --git a/stock/report/batch_wise_balance_history/batch_wise_balance_history.txt b/stock/report/batch_wise_balance_history/batch_wise_balance_history.txt
new file mode 100644
index 00000000000..9e795b9f318
--- /dev/null
+++ b/stock/report/batch_wise_balance_history/batch_wise_balance_history.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-04 11:03:47",
+ "docstatus": 0,
+ "modified": "2013-06-04 19:32:27",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Stock Ledger Entry",
+ "report_name": "Batch-Wise Balance History",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Batch-Wise Balance History"
+ }
+]
\ No newline at end of file
diff --git a/stock/report/delivery_note_trends/__init__.py b/stock/report/delivery_note_trends/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/stock/report/delivery_note_trends/delivery_note_trends.js b/stock/report/delivery_note_trends/delivery_note_trends.js
new file mode 100644
index 00000000000..3ec5e594d7b
--- /dev/null
+++ b/stock/report/delivery_note_trends/delivery_note_trends.js
@@ -0,0 +1,5 @@
+wn.require("app/js/sales_trends_filters.js");
+
+wn.query_reports["Delivery Note Trends"] = {
+ filters: get_filters()
+ }
\ No newline at end of file
diff --git a/stock/report/delivery_note_trends/delivery_note_trends.py b/stock/report/delivery_note_trends/delivery_note_trends.py
new file mode 100644
index 00000000000..e5b2cd094be
--- /dev/null
+++ b/stock/report/delivery_note_trends/delivery_note_trends.py
@@ -0,0 +1,27 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from controllers.trends import get_columns,get_data
+
+def execute(filters=None):
+ if not filters: filters ={}
+ data = []
+ conditions = get_columns(filters, "Delivery Note")
+ data = get_data(filters, conditions)
+
+ return conditions["columns"], data
\ No newline at end of file
diff --git a/stock/report/delivery_note_trends/delivery_note_trends.txt b/stock/report/delivery_note_trends/delivery_note_trends.txt
new file mode 100644
index 00000000000..bb8720074a6
--- /dev/null
+++ b/stock/report/delivery_note_trends/delivery_note_trends.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-13 18:42:11",
+ "docstatus": 0,
+ "modified": "2013-06-13 18:42:11",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Delivery Note",
+ "report_name": "Delivery Note Trends",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Delivery Note Trends"
+ }
+]
\ No newline at end of file
diff --git a/stock/report/item_prices/__init__.py b/stock/report/item_prices/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/stock/report/item_prices/item_prices.py b/stock/report/item_prices/item_prices.py
new file mode 100644
index 00000000000..fb69086252d
--- /dev/null
+++ b/stock/report/item_prices/item_prices.py
@@ -0,0 +1,150 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import flt
+
+def execute(filters=None):
+ if not filters: filters = {}
+
+ columns = get_columns(filters)
+ item_map = get_item_details()
+ pl = get_price_list()
+ last_purchase_rate = get_last_purchase_rate()
+ bom_rate = get_item_bom_rate()
+ val_rate_map = get_valuation_rate()
+
+ precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2
+
+ data = []
+ for item in sorted(item_map):
+ data.append([item, item_map[item]["item_name"],
+ item_map[item]["description"], item_map[item]["stock_uom"],
+ flt(last_purchase_rate.get(item, 0), precision),
+ flt(val_rate_map.get(item, 0), precision),
+ pl.get(item, {}).get("selling"),
+ pl.get(item, {}).get("buying"),
+ flt(bom_rate.get(item, 0), precision),
+ flt(item_map[item]["standard_rate"], precision)
+ ])
+
+ return columns, data
+
+def get_columns(filters):
+ """return columns based on filters"""
+
+ columns = ["Item:Link/Item:100", "Item Name::150", "Description::150", "UOM:Link/UOM:80",
+ "Last Purchase Rate:Currency:90", "Valuation Rate:Currency:80", "Sales Price List::80",
+ "Purchase Price List::80", "BOM Rate:Currency:90", "Standard Rate:Currency:100"]
+
+ return columns
+
+def get_item_details():
+ """returns all items details"""
+
+ item_map = {}
+
+ for i in webnotes.conn.sql("select name, item_name, description, \
+ stock_uom, standard_rate from tabItem \
+ order by item_code", as_dict=1):
+ item_map.setdefault(i.name, i)
+
+ return item_map
+
+def get_price_list():
+ """Get selling & buying price list of every item"""
+
+ rate = {}
+
+ price_list = webnotes.conn.sql("""select parent, selling, buying,
+ concat(price_list_name, " - ", ref_currency, " ", ref_rate) as price
+ from `tabItem Price` where docstatus<2""", as_dict=1)
+
+ for j in price_list:
+ if j.price:
+ if j.selling:
+ rate.setdefault(j.parent, {}).setdefault("selling", []).append(j.price)
+ if j.buying:
+ rate.setdefault(j.parent, {}).setdefault("buying", []).append(j.price)
+
+ item_rate_map = {}
+
+ for item in rate:
+ item_rate_map.setdefault(item, {}).setdefault("selling",
+ ", ".join(rate[item].get("selling", [])))
+ item_rate_map[item]["buying"] = ", ".join(rate[item].get("buying", []))
+
+ return item_rate_map
+
+def get_last_purchase_rate():
+
+ item_last_purchase_rate_map = {}
+
+ query = """select * from (select
+ result.item_code,
+ result.purchase_rate
+ from (
+ (select
+ po_item.item_code,
+ po_item.item_name,
+ po.transaction_date as posting_date,
+ po_item.purchase_ref_rate,
+ po_item.discount_rate,
+ po_item.purchase_rate
+ from `tabPurchase Order` po, `tabPurchase Order Item` po_item
+ where po.name = po_item.parent and po.docstatus = 1)
+ union
+ (select
+ pr_item.item_code,
+ pr_item.item_name,
+ pr.posting_date,
+ pr_item.purchase_ref_rate,
+ pr_item.discount_rate,
+ pr_item.purchase_rate
+ from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item
+ where pr.name = pr_item.parent and pr.docstatus = 1)
+ ) result
+ order by result.item_code asc, result.posting_date desc) result_wrapper
+ group by item_code"""
+
+ for d in webnotes.conn.sql(query, as_dict=1):
+ item_last_purchase_rate_map.setdefault(d.item_code, d.purchase_rate)
+
+ return item_last_purchase_rate_map
+
+def get_item_bom_rate():
+ """Get BOM rate of an item from BOM"""
+
+ item_bom_map = {}
+
+ for b in webnotes.conn.sql("""select item, (total_cost/quantity) as bom_rate
+ from `tabBOM` where is_active=1 and is_default=1""", as_dict=1):
+ item_bom_map.setdefault(b.item, flt(b.bom_rate))
+
+ return item_bom_map
+
+def get_valuation_rate():
+ """Get an average valuation rate of an item from all warehouses"""
+
+ item_val_rate_map = {}
+
+ for d in webnotes.conn.sql("""select item_code,
+ sum(actual_qty*valuation_rate)/sum(actual_qty) as val_rate
+ from tabBin where actual_qty > 0 group by item_code""", as_dict=1):
+ item_val_rate_map.setdefault(d.item_code, d.val_rate)
+
+ return item_val_rate_map
diff --git a/stock/report/item_prices/item_prices.txt b/stock/report/item_prices/item_prices.txt
new file mode 100644
index 00000000000..4c49ca17489
--- /dev/null
+++ b/stock/report/item_prices/item_prices.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-05 11:43:30",
+ "docstatus": 0,
+ "modified": "2013-06-05 11:43:30",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Stock Ledger Entry",
+ "report_name": "Item Prices",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Item Prices"
+ }
+]
\ No newline at end of file
diff --git a/stock/report/item_wise_price_list/item_wise_price_list.txt b/stock/report/item_wise_price_list/item_wise_price_list.txt
index 6c2afad8972..824c603597d 100644
--- a/stock/report/item_wise_price_list/item_wise_price_list.txt
+++ b/stock/report/item_wise_price_list/item_wise_price_list.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-01-02 14:22:51",
+ "creation": "2013-02-22 18:01:55",
"docstatus": 0,
- "modified": "2013-02-22 15:53:01",
+ "modified": "2013-05-07 11:50:46",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -10,7 +10,7 @@
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
- "query": "select\n item.name as \"ID:Link/Item:120\", \n item.item_name as \"Item Name::120\", \n item_price.price_list_name as \"Price List::80\",\n item_price.ref_currency as \"Currency::40\", \n item_price.ref_rate as \"Rate:Currency:80\",\n item.description as \"Description::160\",\n item.item_group as \"Item Group:Link/Item Group:100\",\n item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price\nwhere\n item_price.parent = item.name",
+ "query": "select\n item.name as \"ID:Link/Item:120\", \n item.item_name as \"Item Name::120\", \n item_price.price_list_name as \"Price List::80\",\n item_price.ref_currency as \"Currency::40\", \n item_price.ref_rate as \"Rate:Float:80\",\n item.description as \"Description::160\",\n item.item_group as \"Item Group:Link/Item Group:100\",\n item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price\nwhere\n item_price.parent = item.name",
"ref_doctype": "Item",
"report_name": "Item-Wise Price List",
"report_type": "Query Report"
diff --git a/stock/report/itemwise_recommended_reorder_level/__init__.py b/stock/report/itemwise_recommended_reorder_level/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.js b/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.js
new file mode 100644
index 00000000000..b8aa378828f
--- /dev/null
+++ b/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.js
@@ -0,0 +1,16 @@
+wn.query_reports["Itemwise Recommended Reorder Level"] = {
+ "filters": [
+ {
+ "fieldname":"from_date",
+ "label": "From Date",
+ "fieldtype": "Date",
+ "default": sys_defaults.year_start_date
+ },
+ {
+ "fieldname":"to_date",
+ "label": "To Date",
+ "fieldtype": "Date",
+ "default": get_today()
+ }
+ ]
+}
\ No newline at end of file
diff --git a/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.py b/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.py
new file mode 100644
index 00000000000..588132f9616
--- /dev/null
+++ b/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.py
@@ -0,0 +1,104 @@
+# 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 .
+
+import webnotes
+from webnotes.utils import getdate, flt
+
+def execute(filters=None):
+ if not filters: filters = {}
+ float_preceision = webnotes.conn.get_default("float_preceision")
+
+ condition =get_condition(filters)
+
+ avg_daily_outgoing = 0
+ diff = ((getdate(filters.get("to_date")) - getdate(filters.get("from_date"))).days)+1
+ if diff <= 0:
+ webnotes.msgprint("To Date should not be less than eual to From Date",raise_exception=1)
+
+ columns = get_columns()
+ items = get_item_info()
+ consumed_item_map = get_consumed_items(condition)
+ delivered_item_map = get_delivered_items(condition)
+
+ data = []
+ for item in items:
+
+ total_outgoing = consumed_item_map.get(item.name, 0)+delivered_item_map.get(item.name,0)
+ avg_daily_outgoing = flt(total_outgoing/diff, float_preceision)
+ reorder_level = (avg_daily_outgoing * flt(item.lead_time_days)) + flt(item.min_order_qty)
+
+ data.append([item.name, item.item_name, item.description, item.min_order_qty, item.lead_time_days,
+ consumed_item_map.get(item.name, 0), delivered_item_map.get(item.name,0), total_outgoing,
+ avg_daily_outgoing, reorder_level])
+
+ return columns , data
+
+def get_columns():
+ return[
+ "Item:Link/Item:120", "Item name:Data:120", "Description::160",
+ "Minimum Inventory Level:Float:160", "Lead Time Days:Float:120", "Consumed:Float:120",
+ "Delivered:Float:120", "Total Outgoing:Float:120", "Avg Daily Outgoing:Float:160",
+ "Reorder Level:Float:120"
+ ]
+
+def get_item_info():
+ return webnotes.conn.sql("""select name, item_name, description, min_order_qty,
+ lead_time_days from tabItem""", as_dict=1)
+
+def get_consumed_items(condition):
+
+ cn_items = webnotes.conn.sql("""select se_item.item_code,
+ sum(se_item.actual_qty) as 'consume_qty'
+ from `tabStock Entry` se, `tabStock Entry Detail` se_item
+ where se.name = se_item.parent and se.docstatus = 1
+ and ifnull(se_item.t_warehouse, '') = '' %s
+ group by se_item.item_code""" % (condition), as_dict=1)
+
+ cn_items_map = {}
+ for item in cn_items:
+ cn_items_map.setdefault(item.item_code, item.consume_qty)
+
+ return cn_items_map
+
+def get_delivered_items(condition):
+
+ dn_items = webnotes.conn.sql("""select dn_item.item_code, sum(dn_item.qty) as dn_qty
+ from `tabDelivery Note` dn, `tabDelivery Note Item` dn_item
+ where dn.name = dn_item.parent and dn.docstatus = 1 %s
+ group by dn_item.item_code""" % (condition), as_dict=1)
+
+ si_items = webnotes.conn.sql("""select si_item.item_name, sum(si_item.qty) as si_qty
+ from `tabSales Invoice` si, `tabSales Invoice Item` si_item
+ where si.name = si_item.parent and si.docstatus = 1 and
+ ifnull(si.update_stock, 0) = 1 and ifnull(si.is_pos, 0) = 1 %s
+ group by si_item.item_name""" % (condition), as_dict=1)
+
+ dn_item_map = {}
+ for item in dn_items:
+ dn_item_map.setdefault(item.item_code, item.dn_qty)
+
+ for item in si_items:
+ dn_item_map.setdefault(item.item_code, item.si_qty)
+
+ return dn_item_map
+
+def get_condition(filters):
+ conditions = ""
+ if filters.get("from_date") and filters.get("to_date"):
+ conditions += " and posting_date between '%s' and '%s'" % (filters["from_date"],filters["to_date"])
+ else:
+ webnotes.msgprint("Please set date in from date field",raise_exception=1)
+ return conditions
\ No newline at end of file
diff --git a/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.txt b/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.txt
new file mode 100644
index 00000000000..2763f21dfea
--- /dev/null
+++ b/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-07 12:47:22",
+ "docstatus": 0,
+ "modified": "2013-06-07 13:03:54",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Item",
+ "report_name": "Itemwise Recommended Reorder Level",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Itemwise Recommended Reorder Level"
+ }
+]
\ No newline at end of file
diff --git a/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.txt b/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.txt
index 730e3d724c2..65ee389f071 100644
--- a/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.txt
+++ b/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-02-21 14:26:49",
+ "creation": "2013-02-22 18:01:55",
"docstatus": 0,
- "modified": "2013-02-22 15:53:01",
+ "modified": "2013-07-08 11:17:54",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -10,7 +10,7 @@
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
- "query": "select \n `tabSales Order`.`name` as \"Sales Order:Link/Sales Order:120\",\n `tabSales Order`.`customer` as \"Customer:Link/Customer:120\",\n `tabSales Order`.`status` as \"Status\",\n `tabSales Order`.`transaction_date` as \"Date:Date\",\n `tabSales Order`.`project_name` as \"Project\",\n `tabSales Order Item`.item_code as \"Item:Link/Item:120\",\n `tabSales Order Item`.qty as \"Qty:Float\",\n `tabSales Order Item`.delivered_qty as \"Delivered Qty:Float\",\n (`tabSales Order Item`.qty - ifnull(`tabSales Order Item`.delivered_qty, 0)) as \"Qty to Deliver:Float\",\n `tabSales Order Item`.item_name as \"Item Name::150\",\n `tabSales Order Item`.description as \"Description::200\"\nfrom\n `tabSales Order`, `tabSales Order Item`\nwhere\n `tabSales Order Item`.`parent` = `tabSales Order`.`name`\n and `tabSales Order`.docstatus = 1\n and `tabSales Order`.status != \"Stopped\"\n and ifnull(`tabSales Order Item`.delivered_qty,0) < ifnull(`tabSales Order Item`.qty,0)\norder by `tabSales Order`.transaction_date asc",
+ "query": "select \n `tabSales Order`.`name` as \"Sales Order:Link/Sales Order:120\",\n `tabSales Order`.`customer` as \"Customer:Link/Customer:120\",\n `tabSales Order`.`transaction_date` as \"Date:Date\",\n `tabSales Order`.`project_name` as \"Project\",\n `tabSales Order Item`.item_code as \"Item:Link/Item:120\",\n `tabSales Order Item`.qty as \"Qty:Float:140\",\n `tabSales Order Item`.delivered_qty as \"Delivered Qty:Float:140\",\n (`tabSales Order Item`.qty - ifnull(`tabSales Order Item`.delivered_qty, 0)) as \"Qty to Deliver:Float:140\",\n `tabSales Order Item`.amount as \"Amount:Float:140\",\n `tabSales Order`.`delivery_date` as \"Expected Delivery Date:Date:120\",\n `tabSales Order Item`.item_name as \"Item Name::150\",\n `tabSales Order Item`.description as \"Description::200\",\n `tabSales Order Item`.item_group as \"Item Group:Link/Item Group:120\"\nfrom\n `tabSales Order`, `tabSales Order Item`\nwhere\n `tabSales Order Item`.`parent` = `tabSales Order`.`name`\n and `tabSales Order`.docstatus = 1\n and `tabSales Order`.status != \"Stopped\"\n and ifnull(`tabSales Order Item`.delivered_qty,0) < ifnull(`tabSales Order Item`.qty,0)\norder by `tabSales Order`.transaction_date asc",
"ref_doctype": "Delivery Note",
"report_name": "Ordered Items To Be Delivered",
"report_type": "Query Report"
diff --git a/stock/report/purchase_in_transit/__init__.py b/stock/report/purchase_in_transit/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/stock/report/purchase_in_transit/purchase_in_transit.txt b/stock/report/purchase_in_transit/purchase_in_transit.txt
new file mode 100644
index 00000000000..60ce0da460d
--- /dev/null
+++ b/stock/report/purchase_in_transit/purchase_in_transit.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-05-06 12:09:05",
+ "docstatus": 0,
+ "modified": "2013-05-06 12:22:52",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "query": "SELECT\n pi.name as \"Purchase Invoice:Link/Purchase Invoice:120\",\n\tpi.posting_date as \"Posting Date:Date:100\",\n\tpi.credit_to as \"Supplier Account:Link/Account:120\",\n\tpi_item.item_code as \"Item Code:Link/Item:120\",\n\tpi_item.description as \"Description:Data:140\",\n\tpi_item.qty as \"Qty:Float:120\",\n\tpi_item.amount as \"Amount:Currency:120\",\n\tpi_item.purchase_order as \"Purchase Order:Link/Purchase Order:120\",\n\tpi_item.purchase_receipt as \"Purchase Receipt:Link/Purchase Receipt:120\",\n\tpr.posting_date as \"PR Posting Date:Date:130\",\n\tpi.company as \"Company:Link/Company:120\"\nFROM\n\t`tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item, `tabPurchase Receipt` pr\nWHERE\n\tpi.name = pi_item.parent and pi_item.purchase_receipt = pr.name\n\tand pi.docstatus = 1 and pr.posting_date > pi.posting_date\nORDER BY\n\tpi.name desc",
+ "ref_doctype": "Purchase Receipt",
+ "report_name": "Purchase In Transit",
+ "report_type": "Query Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Purchase In Transit"
+ }
+]
\ No newline at end of file
diff --git a/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt b/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt
index 45e3a42dee1..c588dde3f76 100644
--- a/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt
+++ b/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt
@@ -1,16 +1,17 @@
[
{
- "creation": "2013-02-21 14:26:49",
+ "creation": "2013-02-22 18:01:55",
"docstatus": 0,
- "modified": "2013-02-22 15:53:01",
+ "modified": "2013-05-28 16:03:15",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
+ "add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
- "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n `tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n `tabPurchase Order`.`project_name` as \"Project\",\n `tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n `tabPurchase Order Item`.qty as \"Qty:Float:100\",\n `tabPurchase Order Item`.received_qty as \"Received Qty:Float:100\", \n (`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.received_qty, 0)) as \"Qty to Receive:Float:100\",\n `tabPurchase Order Item`.item_name as \"Item Name::150\",\n `tabPurchase Order Item`.description as \"Description::200\"\nfrom\n `tabPurchase Order`, `tabPurchase Order Item`\nwhere\n `tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n and `tabPurchase Order`.docstatus = 1\n and `tabPurchase Order`.status != \"Stopped\"\n and ifnull(`tabPurchase Order Item`.received_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc",
+ "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n\t`tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Order Item`.received_qty as \"Received Qty:Float:100\", \n\t(`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.received_qty, 0)) as \"Qty to Receive:Float:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.received_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc",
"ref_doctype": "Purchase Receipt",
"report_name": "Purchase Order Items To Be Received",
"report_type": "Query Report"
diff --git a/stock/report/purchase_receipt_trends/__init__.py b/stock/report/purchase_receipt_trends/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/stock/report/purchase_receipt_trends/purchase_receipt_trends.js b/stock/report/purchase_receipt_trends/purchase_receipt_trends.js
new file mode 100644
index 00000000000..ecfa5a473e7
--- /dev/null
+++ b/stock/report/purchase_receipt_trends/purchase_receipt_trends.js
@@ -0,0 +1,5 @@
+wn.require("app/js/purchase_trends_filters.js");
+
+wn.query_reports["Purchase Receipt Trends"] = {
+ filters: get_filters()
+ }
\ No newline at end of file
diff --git a/stock/report/purchase_receipt_trends/purchase_receipt_trends.py b/stock/report/purchase_receipt_trends/purchase_receipt_trends.py
new file mode 100644
index 00000000000..b41ce281f7e
--- /dev/null
+++ b/stock/report/purchase_receipt_trends/purchase_receipt_trends.py
@@ -0,0 +1,27 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from controllers.trends import get_columns,get_data
+
+def execute(filters=None):
+ if not filters: filters ={}
+ data = []
+ conditions = get_columns(filters, "Purchase Receipt")
+ data = get_data(filters, conditions)
+
+ return conditions["columns"], data
\ No newline at end of file
diff --git a/stock/report/purchase_receipt_trends/purchase_receipt_trends.txt b/stock/report/purchase_receipt_trends/purchase_receipt_trends.txt
new file mode 100644
index 00000000000..179c524f96f
--- /dev/null
+++ b/stock/report/purchase_receipt_trends/purchase_receipt_trends.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-13 18:45:44",
+ "docstatus": 0,
+ "modified": "2013-06-13 18:45:44",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Purchase Receipt",
+ "report_name": "Purchase Receipt Trends",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Purchase Receipt Trends"
+ }
+]
\ No newline at end of file
diff --git a/stock/report/requested_items_to_be_transferred/__init__.py b/stock/report/requested_items_to_be_transferred/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt b/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt
new file mode 100644
index 00000000000..030ed242d80
--- /dev/null
+++ b/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt
@@ -0,0 +1,23 @@
+[
+ {
+ "creation": "2013-05-13 16:23:05",
+ "docstatus": 0,
+ "modified": "2013-05-13 16:25:08",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "add_total_row": 1,
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.ordered_qty as \"Transferred Qty:Float:100\", \n\t(mr_item.qty - ifnull(mr_item.ordered_qty, 0)) as \"Qty to Transfer:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Transfer\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand ifnull(mr_item.ordered_qty, 0) < ifnull(mr_item.qty, 0)\norder by mr.transaction_date asc",
+ "ref_doctype": "Stock Entry",
+ "report_name": "Requested Items To Be Transferred",
+ "report_type": "Query Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Requested Items To Be Transferred"
+ }
+]
\ No newline at end of file
diff --git a/stock/report/warehouse_wise_stock_balance/__init__.py b/stock/report/warehouse_wise_stock_balance/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.js b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.js
new file mode 100644
index 00000000000..2ce5b4b4ab9
--- /dev/null
+++ b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.js
@@ -0,0 +1,18 @@
+wn.query_reports["Warehouse-Wise Stock Balance"] = {
+ "filters": [
+ {
+ "fieldname":"from_date",
+ "label": "From Date",
+ "fieldtype": "Date",
+ "width": "80",
+ "default": sys_defaults.year_start_date,
+ },
+ {
+ "fieldname":"to_date",
+ "label": "To Date",
+ "fieldtype": "Date",
+ "width": "80",
+ "default": wn.datetime.get_today()
+ }
+ ]
+}
\ No newline at end of file
diff --git a/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py
new file mode 100644
index 00000000000..4389aa59e41
--- /dev/null
+++ b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py
@@ -0,0 +1,98 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import flt
+
+def execute(filters=None):
+ if not filters: filters = {}
+
+ columns = get_columns(filters)
+ item_map = get_item_details(filters)
+ iwb_map = get_item_warehouse_map(filters)
+
+ data = []
+ for company in sorted(iwb_map):
+ for item in sorted(iwb_map[company]):
+ for wh in sorted(iwb_map[company][item]):
+ qty_dict = iwb_map[company][item][wh]
+ data.append([item, item_map[item]["item_name"],
+ item_map[item]["description"], wh,
+ qty_dict.opening_qty, qty_dict.in_qty,
+ qty_dict.out_qty, qty_dict.bal_qty, company
+ ])
+
+ return columns, data
+
+def get_columns(filters):
+ """return columns based on filters"""
+
+ columns = ["Item:Link/Item:100", "Item Name::150", "Description::150", \
+ "Warehouse:Link/Warehouse:100", "Opening Qty::90", \
+ "In Qty::80", "Out Qty::80", "Balance Qty::90", "Company:Link/Company:100"]
+
+ return columns
+
+def get_conditions(filters):
+ conditions = ""
+ if not filters.get("from_date"):
+ webnotes.msgprint("Please enter From Date", raise_exception=1)
+
+ if filters.get("to_date"):
+ conditions += " and posting_date <= '%s'" % filters["to_date"]
+ else:
+ webnotes.msgprint("Please enter To Date", raise_exception=1)
+
+ return conditions
+
+#get all details
+def get_stock_ledger_entries(filters):
+ conditions = get_conditions(filters)
+ return webnotes.conn.sql("""select item_code, warehouse,
+ posting_date, actual_qty, company
+ from `tabStock Ledger Entry`
+ where ifnull(is_cancelled, 'No') = 'No' %s order by item_code, warehouse""" %
+ conditions, as_dict=1)
+
+def get_item_warehouse_map(filters):
+ sle = get_stock_ledger_entries(filters)
+ iwb_map = {}
+
+ for d in sle:
+ iwb_map.setdefault(d.company, {}).setdefault(d.item_code, {}).\
+ setdefault(d.warehouse, webnotes._dict({\
+ "opening_qty": 0.0, "in_qty": 0.0, "out_qty": 0.0, "bal_qty": 0.0
+ }))
+ qty_dict = iwb_map[d.company][d.item_code][d.warehouse]
+ if d.posting_date < filters["from_date"]:
+ qty_dict.opening_qty += flt(d.actual_qty)
+ elif d.posting_date >= filters["from_date"] and d.posting_date <= filters["to_date"]:
+ if flt(d.actual_qty) > 0:
+ qty_dict.in_qty += flt(d.actual_qty)
+ else:
+ qty_dict.out_qty += abs(flt(d.actual_qty))
+
+ qty_dict.bal_qty += flt(d.actual_qty)
+
+ return iwb_map
+
+def get_item_details(filters):
+ item_map = {}
+ for d in webnotes.conn.sql("select name, item_name, description from tabItem", as_dict=1):
+ item_map.setdefault(d.name, d)
+
+ return item_map
\ No newline at end of file
diff --git a/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.txt b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.txt
new file mode 100644
index 00000000000..2513587632d
--- /dev/null
+++ b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.txt
@@ -0,0 +1,21 @@
+[
+ {
+ "creation": "2013-06-05 11:00:31",
+ "docstatus": 0,
+ "modified": "2013-06-05 11:00:31",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "ref_doctype": "Stock Ledger Entry",
+ "report_name": "Warehouse-Wise Stock Balance",
+ "report_type": "Script Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Warehouse-Wise Stock Balance"
+ }
+]
\ No newline at end of file
diff --git a/stock/stock_ledger.py b/stock/stock_ledger.py
index 2480263c1f9..10e490c8e00 100644
--- a/stock/stock_ledger.py
+++ b/stock/stock_ledger.py
@@ -35,6 +35,9 @@ def update_entries_after(args, verbose=1):
"posting_time": "12:00"
}
"""
+ global _exceptions
+ _exceptions = []
+
previous_sle = get_sle_before_datetime(args)
qty_after_transaction = flt(previous_sle.get("qty_after_transaction"))
diff --git a/stock/utils.py b/stock/utils.py
index a2541dc69e9..53ad69b1572 100644
--- a/stock/utils.py
+++ b/stock/utils.py
@@ -17,15 +17,16 @@
import webnotes
from webnotes import msgprint, _
import json
-from webnotes.utils import flt, cstr
+from webnotes.utils import flt, cstr, nowdate, add_days, cint
from webnotes.defaults import get_global_default
+from webnotes.utils.email_lib import sendmail
def validate_end_of_life(item_code, end_of_life=None, verbose=1):
if not end_of_life:
end_of_life = webnotes.conn.get_value("Item", item_code, "end_of_life")
from webnotes.utils import getdate, now_datetime, formatdate
- if end_of_life and getdate(end_of_life) > now_datetime().date():
+ if end_of_life and getdate(end_of_life) <= now_datetime().date():
msg = (_("Item") + " %(item_code)s: " + _("reached its end of life on") + \
" %(date)s. " + _("Please check") + ": %(end_of_life_label)s " + \
"in Item master") % {
@@ -194,4 +195,152 @@ def _get_buying_amount(voucher_type, voucher_no, item_row, item_code, warehouse,
buying_amount = previous_stock_value - flt(sle.stock_value)
return buying_amount
- return 0.0
\ No newline at end of file
+ return 0.0
+
+
+def reorder_item():
+ """ Reorder item if stock reaches reorder level"""
+ if not hasattr(webnotes, "auto_indent"):
+ webnotes.auto_indent = webnotes.conn.get_value('Global Defaults', None, 'auto_indent')
+
+ if webnotes.auto_indent:
+ material_requests = {}
+ bin_list = webnotes.conn.sql("""select item_code, warehouse, projected_qty
+ from tabBin where ifnull(item_code, '') != '' and ifnull(warehouse, '') != ''
+ and exists (select name from `tabItem`
+ where `tabItem`.name = `tabBin`.item_code and
+ is_stock_item='Yes' and (is_purchase_item='Yes' or is_sub_contracted_item='Yes') and
+ (ifnull(end_of_life, '')='') or end_of_life > now())""",
+ as_dict=True)
+ for bin in bin_list:
+ #check if re-order is required
+ item_reorder = webnotes.conn.get("Item Reorder",
+ {"parent": bin.item_code, "warehouse": bin.warehouse})
+ if item_reorder:
+ reorder_level = item_reorder.warehouse_reorder_level
+ reorder_qty = item_reorder.warehouse_reorder_qty
+ material_request_type = item_reorder.material_request_type or "Purchase"
+ else:
+ reorder_level, reorder_qty = webnotes.conn.get_value("Item", bin.item_code,
+ ["re_order_level", "re_order_qty"])
+ material_request_type = "Purchase"
+
+ if flt(reorder_level) and flt(bin.projected_qty) < flt(reorder_level):
+ if flt(reorder_level) - flt(bin.projected_qty) > flt(reorder_qty):
+ reorder_qty = flt(reorder_level) - flt(bin.projected_qty)
+
+ company = webnotes.conn.get_value("Warehouse", bin.warehouse, "company") or \
+ webnotes.defaults.get_defaults()["company"] or \
+ webnotes.conn.sql("""select name from tabCompany limit 1""")[0][0]
+
+ material_requests.setdefault(material_request_type, webnotes._dict()).setdefault(
+ company, []).append(webnotes._dict({
+ "item_code": bin.item_code,
+ "warehouse": bin.warehouse,
+ "reorder_qty": reorder_qty
+ })
+ )
+
+ create_material_request(material_requests)
+
+def create_material_request(material_requests):
+ """ Create indent on reaching reorder level """
+ mr_list = []
+ defaults = webnotes.defaults.get_defaults()
+ exceptions_list = []
+ for request_type in material_requests:
+ for company in material_requests[request_type]:
+ try:
+ items = material_requests[request_type][company]
+ if not items:
+ continue
+
+ mr = [{
+ "doctype": "Material Request",
+ "company": company,
+ "fiscal_year": defaults.fiscal_year,
+ "transaction_date": nowdate(),
+ "material_request_type": request_type,
+ "remark": _("This is an auto generated Material Request.") + \
+ _("""It was raised because the (actual + ordered + indented - reserved)
+ quantity reaches re-order level when the following record was created""")
+ }]
+
+ for d in items:
+ item = webnotes.doc("Item", d.item_code)
+ mr.append({
+ "doctype": "Material Request Item",
+ "parenttype": "Material Request",
+ "parentfield": "indent_details",
+ "item_code": d.item_code,
+ "schedule_date": add_days(nowdate(),cint(item.lead_time_days)),
+ "uom": item.stock_uom,
+ "warehouse": d.warehouse,
+ "item_name": item.item_name,
+ "description": item.description,
+ "item_group": item.item_group,
+ "qty": d.reorder_qty,
+ "brand": item.brand,
+ })
+
+ mr_bean = webnotes.bean(mr)
+ mr_bean.insert()
+ mr_bean.submit()
+ mr_list.append(mr_bean)
+
+ except:
+ if webnotes.message_log:
+ exceptions_list.append([] + webnotes.message_log)
+ webnotes.message_log = []
+ else:
+ exceptions_list.append(webnotes.getTraceback())
+
+ if mr_list:
+ if not hasattr(webnotes, "reorder_email_notify"):
+ webnotes.reorder_email_notify = webnotes.conn.get_value('Global Defaults', None,
+ 'reorder_email_notify')
+
+ if(webnotes.reorder_email_notify):
+ send_email_notification(mr_list)
+
+ if exceptions_list:
+ notify_errors(exceptions_list)
+
+def send_email_notification(mr_list):
+ """ Notify user about auto creation of indent"""
+
+ email_list = webnotes.conn.sql_list("""select distinct r.parent
+ from tabUserRole r, tabProfile p
+ where p.name = r.parent and p.enabled = 1 and p.docstatus < 2
+ and r.role in ('Purchase Manager','Material Manager')
+ and p.name not in ('Administrator', 'All', 'Guest')""")
+
+ msg="""Following Material Requests has been raised automatically \
+ based on item reorder level:
"""
+ for mr in mr_list:
+ msg += "" + mr.doc.name + """
+ | Item Code | Warehouse | Qty | UOM |
"""
+ for item in mr.doclist.get({"parentfield": "indent_details"}):
+ msg += "| " + item.item_code + " | " + item.warehouse + " | " + \
+ cstr(item.qty) + " | " + cstr(item.uom) + " |
"
+ msg += "
"
+
+ sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg)
+
+def notify_errors(exceptions_list):
+ subject = "[Important] [ERPNext] Error(s) while creating Material Requests based on Re-order Levels"
+ msg = """Dear System Manager,
+
+ An error occured for certain Items while creating Material Requests based on Re-order level.
+
+ Please rectify these issues:
+ ---
+
+ %s
+
+ ---
+ Regards,
+ Administrator""" % ("\n\n".join(["\n".join(msg) for msg in exceptions_list]),)
+
+ from webnotes.profile import get_system_managers
+ sendmail(get_system_managers(), subject=subject, msg=msg)
diff --git a/support/doctype/maintenance_schedule/maintenance_schedule.py b/support/doctype/maintenance_schedule/maintenance_schedule.py
index 60962b1d524..baed6a9dbd8 100644
--- a/support/doctype/maintenance_schedule/maintenance_schedule.py
+++ b/support/doctype/maintenance_schedule/maintenance_schedule.py
@@ -18,7 +18,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, cstr, getdate
-from webnotes.model.doc import Document, addchild
+from webnotes.model.doc import addchild
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
@@ -26,7 +26,7 @@ from webnotes import msgprint
sql = webnotes.conn.sql
-from utilities.transaction_base import TransactionBase
+from utilities.transaction_base import TransactionBase, delete_events
class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
@@ -100,23 +100,21 @@ class DocType(TransactionBase):
for key in scheduled_date:
if email_map[d.incharge_name]:
- self.add_calender_event(key["scheduled_date"],email_map[d.incharge_name],d.item_code)
+ description = "Reference: %s, Item Code: %s and Customer: %s" % \
+ (self.doc.name, d.item_code, self.doc.customer)
+ webnotes.bean({
+ "doctype": "Event",
+ "owner": email_map[d.incharge_name] or self.doc.owner,
+ "subject": description,
+ "description": description,
+ "starts_on": key["scheduled_date"] + " 10:00:00",
+ "event_type": "Private",
+ "ref_type": self.doc.doctype,
+ "ref_name": self.doc.name
+ }).insert()
+
webnotes.conn.set(self.doc, 'status', 'Submitted')
-
- def add_calender_event(self,scheduled_date,incharge_email,item_code):
- """ Add calendar event for Maintenece Schedule in calendar of Allocated person"""
- event = Document('Event')
- event.owner = incharge_email
- event.description = "Reference:%s, Item Code:%s and Customer: %s" %(self.doc.name, item_code, self.doc.customer)
- event.event_date = scheduled_date
- event.event_hour = '10:00'
- event.event_type = 'Private'
- event.ref_type = 'Maintenance Schedule'
- event.ref_name = self.doc.name
- event.save(1)
-
-
#get schedule dates
#----------------------
def create_schedule_list(self, start_date, end_date, no_of_visit):
@@ -329,8 +327,7 @@ class DocType(TransactionBase):
if d.serial_no:
self.update_amc_date(d.serial_no, '')
webnotes.conn.set(self.doc, 'status', 'Cancelled')
- sql("delete from `tabEvent` where ref_type='Maintenance Schedule' and ref_name='%s' " %(self.doc.name))
- def on_trash(self):
- sql("delete from `tabEvent` where ref_type='Maintenance Schedule' and ref_name='%s' " %(self.doc.name))
+ delete_events(self.doc.doctype, self.doc.name)
-
+ def on_trash(self):
+ delete_events(self.doc.doctype, self.doc.name)
diff --git a/support/doctype/support_ticket/get_support_mails.py b/support/doctype/support_ticket/get_support_mails.py
index d1fe0dc8daf..82ae9a34b6e 100644
--- a/support/doctype/support_ticket/get_support_mails.py
+++ b/support/doctype/support_ticket/get_support_mails.py
@@ -50,7 +50,7 @@ class SupportMailbox(POP3Mailbox):
"subject": mail.mail["Subject"],
"raised_by": mail.from_email,
"content_type": mail.content_type,
- "status": "Open"
+ "status": "Open",
}])
ticket.insert()
new_ticket = True
@@ -58,7 +58,7 @@ class SupportMailbox(POP3Mailbox):
mail.save_attachments_in_doc(ticket.doc)
make(content=mail.content, sender=mail.from_email, subject = ticket.doc.subject,
- doctype="Support Ticket", name=ticket.doc.name,
+ doctype="Support Ticket", name=ticket.doc.name,
lead = ticket.doc.lead, contact=ticket.doc.contact, date=mail.date)
if new_ticket and cint(self.email_settings.send_autoreply) and \
diff --git a/support/doctype/support_ticket/support_ticket.js b/support/doctype/support_ticket/support_ticket.js
index 3da81d9efbe..4ee4c1d9684 100644
--- a/support/doctype/support_ticket/support_ticket.js
+++ b/support/doctype/support_ticket/support_ticket.js
@@ -29,17 +29,13 @@ $.extend(cur_frm.cscript, {
erpnext.hide_naming_series();
cur_frm.cscript.make_listing(doc);
if(!doc.__islocal) {
- if(in_list(user_roles,'System Manager')) {
- if(doc.status!='Closed') cur_frm.add_custom_button('Close Ticket', cur_frm.cscript['Close Ticket']);
- if(doc.status=='Closed') cur_frm.add_custom_button('Re-Open Ticket', cur_frm.cscript['Re-Open Ticket']);
- }else if(doc.allocated_to) {
- cur_frm.set_df_property('status','read_only', 1);
- if(user==doc.allocated_to && doc.status!='Closed') cur_frm.add_custom_button('Close Ticket', cur_frm.cscript['Close Ticket']);
+ if(user_roles.indexOf("Support Manager")!==-1) {
+ if(doc.status!='Closed') cur_frm.add_custom_button('Close Ticket', cur_frm.cscript['Close Ticket']);
+ if(doc.status=='Closed') cur_frm.add_custom_button('Re-Open Ticket', cur_frm.cscript['Re-Open Ticket']);
}
- cur_frm.set_df_property('subject','read_only', 1);
- cur_frm.set_df_property('description','hidden', 1);
- cur_frm.set_df_property('raised_by','read_only', 1);
+ cur_frm.toggle_enable(["subject", "raised_by"], false);
+ cur_frm.toggle_display("description", false);
}
refresh_field('status');
},
diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py
index 5625f1179cd..63548d3436d 100644
--- a/support/doctype/support_ticket/support_ticket.py
+++ b/support/doctype/support_ticket/support_ticket.py
@@ -18,7 +18,6 @@ from __future__ import unicode_literals
import webnotes
from utilities.transaction_base import TransactionBase
-from home import update_feed
from webnotes.utils import now
class DocType(TransactionBase):
@@ -44,13 +43,28 @@ class DocType(TransactionBase):
def validate(self):
self.update_status()
+ self.set_lead_contact(self.doc.raised_by)
+
+ if self.doc.status == "Closed":
+ from webnotes.widgets.form.assign_to import clear
+ clear(self.doc.doctype, self.doc.name)
def on_communication_sent(self, comm):
webnotes.conn.set(self.doc, 'status', 'Waiting for Customer')
- if comm.lead and not self.doc.lead:
- webnotes.conn.set(self.doc, 'lead', comm.lead)
- if comm.contact and not self.doc.contact:
- webnotes.conn.set(self.doc, 'contact', comm.contact)
+
+
+ def set_lead_contact(self, email_id):
+ import email.utils
+ email_id = email.utils.parseaddr(email_id)
+ if email_id:
+ if not self.doc.lead:
+ self.doc.lead = webnotes.conn.get_value("Lead", {"email_id": email_id})
+ if not self.doc.contact:
+ self.doc.contact = webnotes.conn.get_value("Contact", {"email_id": email_id})
+
+ if not self.doc.company:
+ self.doc.company = webnotes.conn.get_value("Lead", self.doc.lead, "company") or \
+ webnotes.conn.get_default("company")
def on_trash(self):
webnotes.conn.sql("""update `tabCommunication` set support_ticket=NULL
@@ -82,7 +96,7 @@ def get_tickets():
webnotes.session.user, as_dict=1)
return tickets
-def get_website_args():
+def get_website_args():
bean = webnotes.bean("Support Ticket", webnotes.form_dict.name)
if bean.doc.raised_by != webnotes.session.user:
return {
diff --git a/support/doctype/support_ticket/support_ticket.txt b/support/doctype/support_ticket/support_ticket.txt
index f058a9e1562..50e547ece7a 100644
--- a/support/doctype/support_ticket/support_ticket.txt
+++ b/support/doctype/support_ticket/support_ticket.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-01-10 16:34:31",
+ "creation": "2013-02-01 10:36:25",
"docstatus": 0,
- "modified": "2013-01-31 22:17:24",
+ "modified": "2013-05-21 16:27:46",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -196,6 +196,15 @@
"oldfieldtype": "Time",
"read_only": 1
},
+ {
+ "doctype": "DocField",
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "label": "Company",
+ "options": "Company",
+ "print_hide": 1,
+ "reqd": 0
+ },
{
"depends_on": "eval:!doc.__islocal",
"doctype": "DocField",
@@ -241,15 +250,6 @@
"hidden": 1,
"label": "Content Type"
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"cancel": 0,
"doctype": "DocPerm",
diff --git a/support/page/support_home/support_home.js b/support/page/support_home/support_home.js
index d397daa6ce4..bde5e5c00ad 100644
--- a/support/page/support_home/support_home.js
+++ b/support/page/support_home/support_home.js
@@ -72,6 +72,18 @@ wn.module_page["Support"] = [
},
]
},
+ {
+ title: wn._("Reports"),
+ right: true,
+ icon: "icon-list",
+ items: [
+ {
+ "label":wn._("Maintenance Schedules"),
+ route: "query-report/Maintenance Schedules",
+ doctype: "Maintenance Schedule"
+ }
+ ]
+ }
]
pscript['onload_support-home'] = function(wrapper) {
diff --git a/support/report/__init__.py b/support/report/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/support/report/maintenance_schedules/__init__.py b/support/report/maintenance_schedules/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/support/report/maintenance_schedules/maintenance_schedules.txt b/support/report/maintenance_schedules/maintenance_schedules.txt
new file mode 100644
index 00000000000..525f4834ba8
--- /dev/null
+++ b/support/report/maintenance_schedules/maintenance_schedules.txt
@@ -0,0 +1,22 @@
+[
+ {
+ "creation": "2013-05-06 14:25:21",
+ "docstatus": 0,
+ "modified": "2013-05-06 14:32:47",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "name": "__common__",
+ "query": "SELECT\n ms_item.scheduled_date as \"Schedule Date:Date:120\",\n\tms_item.item_code as \"Item Code:Link/Item:120\",\n\tms_item.item_name as \"Item Name::120\",\n\tms_item.serial_no as \"Serial No::120\",\n\tms_item.incharge_name as \"Incharge::120\",\n\tms.customer_name as \"Customer:Link/Customer:120\",\n\tms.address_display as \"Customer Address::120\",\n\tms.sales_order_no as \"Sales Order:Link/Sales Order:120\",\n\tms.company as \"Company:Link/Company:120\"\n\t\nFROM\n\t`tabMaintenance Schedule` ms, `tabMaintenance Schedule Detail` ms_item\nWHERE\n\tms.name = ms_item.parent and ms.docstatus = 1\nORDER BY\n\tms_item.scheduled_date asc, ms_item.item_code asc",
+ "ref_doctype": "Maintenance Schedule",
+ "report_name": "Maintenance Schedules",
+ "report_type": "Query Report"
+ },
+ {
+ "doctype": "Report",
+ "name": "Maintenance Schedules"
+ }
+]
\ No newline at end of file
diff --git a/support/search_criteria/__init__.py b/support/search_criteria/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/support/search_criteria/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/support/search_criteria/amc_summary/__init__.py b/support/search_criteria/amc_summary/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/support/search_criteria/amc_summary/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/support/search_criteria/amc_summary/amc_summary.js b/support/search_criteria/amc_summary/amc_summary.js
deleted file mode 100644
index 0ce3619c698..00000000000
--- a/support/search_criteria/amc_summary/amc_summary.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.hide_all_filters();
- this.mytabs.items['Select Columns'].hide();
- this.mytabs.items['More Filters'].hide()
- this.filter_fields_dict['Serial No'+FILTER_SEP +'Territory'].df.filter_hide = 0;
- this.filter_fields_dict['Serial No'+FILTER_SEP +'Item Group'].df.filter_hide = 0;
- this.filter_fields_dict['Serial No'+FILTER_SEP +'Territory'].df.in_first_page = 1;
- this.filter_fields_dict['Serial No'+FILTER_SEP +'Item Group'].df.in_first_page = 1;
-}
\ No newline at end of file
diff --git a/support/search_criteria/amc_summary/amc_summary.py b/support/search_criteria/amc_summary/amc_summary.py
deleted file mode 100644
index 926da017a35..00000000000
--- a/support/search_criteria/amc_summary/amc_summary.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# 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 .
-
-# ADD NEW COLUMNS
-from __future__ import unicode_literals
-row_list = [['Item Group','Data','150px',''],
- ['Out of AMC','Int','150px',''],
- ['Under AMC','Int','150px',''],
- ['Out of Warranty','Int','150px',''],
- ['Under Warranty','Int','150px',''],
- ['Total','Int','150px','']
- ]
-
-for r in row_list:
- colnames.append(r[0])
- coltypes.append(r[1])
- colwidths.append(r[2])
- coloptions.append(r[3])
- col_idx[r[0]] = len(colnames)-1
-
-
-#ADD VALUES TO THE COLUMN
-out=[]
-oa,ua,ow,uw,sum=0,0,0,0,0
-nowdate = nowdate()
-for r in res:
- cc = r[col_idx['Territory']]
- item_groups = sql("select distinct item_group from `tabSerial No` where territory = '%s' and item_group like '%%%s'" %(cc,filter_values.get('item_group')))
-
- for col in range(len(colnames)-1): # this would make all first row blank. just for look
- r.append('')
- out.append(r)
-
- # Add Totals for each Territory
- # -----------------------------
- det = sql("select COUNT(CASE WHEN amc_expiry_date > '%s' THEN name ELSE NULL END), COUNT(CASE WHEN amc_expiry_date <= '%s' THEN name ELSE NULL END), COUNT(CASE WHEN warranty_expiry_date > '%s' THEN name ELSE NULL END), COUNT(CASE WHEN warranty_expiry_date <= '%s' THEN name ELSE NULL END) from `tabSerial No` where territory = '%s' and item_group like '%%%s'" %(nowdate,nowdate,nowdate,nowdate,cc,filter_values.get('item_group')))
- r[col_idx['Item Group']] = ''
-
- r[col_idx['Out of AMC']] = cstr(det[0][0])
- r[col_idx['Under AMC']] = cstr(det[0][1])
- r[col_idx['Out of Warranty']] = cstr(det[0][2])
- r[col_idx['Under Warranty']] = cstr(det[0][3])
- tot = cint(det[0][0]) + cint(det[0][1]) + cint(det[0][2]) + cint(det[0][3])
- r[col_idx['Total']] = cstr(tot)
-
-
- oa += cint(det[0][0])
- ua += cint(det[0][1])
- ow += cint(det[0][2])
- uw += cint(det[0][3])
- sum += tot
-
-
- # Add Brand Details belonging to Territory
- # ----------------------------------------
- for br in item_groups:
- br_det = sql("select COUNT(CASE WHEN amc_expiry_date > '%s' THEN name ELSE NULL END), COUNT(CASE WHEN amc_expiry_date <= '%s' THEN name ELSE NULL END), COUNT(CASE WHEN warranty_expiry_date > '%s' THEN name ELSE NULL END), COUNT(CASE WHEN warranty_expiry_date <= '%s' THEN name ELSE NULL END) from `tabSerial No` where territory = '%s' and item_group = '%s'"%(nowdate,nowdate,nowdate,nowdate,cc,br[0]))
- t_row = ['' for i in range(len(colnames))]
- t_row[col_idx['Item Group']] = br[0]
-
- t_row[col_idx['Out of AMC']] = cint(br_det[0][0])
- t_row[col_idx['Under AMC']] = cint(br_det[0][1])
- t_row[col_idx['Out of Warranty']] = cint(br_det[0][2])
- t_row[col_idx['Under Warranty']] = cint(br_det[0][3])
- tot = cint(br_det[0][0]) + cint(br_det[0][1]) + cint(br_det[0][2])+ cint(br_det[0][3])
- t_row[col_idx['Total']] = tot
- out.append(t_row)
-
-
-#ADD NEW ROW
-# ----------
-newrow=['','TOTAL',oa,ua,ow,uw,sum]
-out.append(newrow)
-res=out
\ No newline at end of file
diff --git a/support/search_criteria/amc_summary/amc_summary.txt b/support/search_criteria/amc_summary/amc_summary.txt
deleted file mode 100644
index a83e0d345ea..00000000000
--- a/support/search_criteria/amc_summary/amc_summary.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:50",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:50"
- },
- {
- "module": "Support",
- "standard": "Yes",
- "sort_order": "ASC",
- "filters": "{'Serial No\u0001Saved':1,'Serial No\u0001Status':''}",
- "doc_type": "Serial No",
- "name": "__common__",
- "add_cond": "`tabSerial No`.`territory` is not null\n`tabSerial No`.`territory` != ''\n`tabSerial No`.`status` not in ('In Store', 'Scrapped')",
- "doctype": "Search Criteria",
- "sort_by": "`tabSerial No`.`cost_center`",
- "group_by": "`tabSerial No`.`cost_center`",
- "page_len": 50,
- "criteria_name": "AMC Summary",
- "columns": "Serial No\u0001Territory"
- },
- {
- "name": "amc_summary",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/support/search_criteria/customer_issues/__init__.py b/support/search_criteria/customer_issues/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/support/search_criteria/customer_issues/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/support/search_criteria/customer_issues/customer_issues.js b/support/search_criteria/customer_issues/customer_issues.js
deleted file mode 100644
index 8eaf6f62b06..00000000000
--- a/support/search_criteria/customer_issues/customer_issues.js
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.filter_fields_dict['Customer Issue'+FILTER_SEP +'Status'].df.in_first_page = 1;
- this.filter_fields_dict['Customer Issue'+FILTER_SEP +'Allocated To'].df.in_first_page = 1;
- this.filter_fields_dict['Customer Issue'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
-}
-
-this.mytabs.items['Select Columns'].hide()
\ No newline at end of file
diff --git a/support/search_criteria/customer_issues/customer_issues.txt b/support/search_criteria/customer_issues/customer_issues.txt
deleted file mode 100644
index caa07754310..00000000000
--- a/support/search_criteria/customer_issues/customer_issues.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:51"
- },
- {
- "module": "Support",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Customer Issue\u0001Saved':1,'Customer Issue\u0001Submitted':1,'Customer Issue\u0001Status':'','Customer Issue\u0001Fiscal Year':''}",
- "doctype": "Search Criteria",
- "doc_type": "Customer Issue",
- "name": "__common__",
- "sort_by": "`tabCustomer Issue`.`name`",
- "page_len": 50,
- "criteria_name": "Customer Issues",
- "columns": "Customer Issue\u0001ID,Customer Issue\u0001Status,Customer Issue\u0001Complaint Date,Customer Issue\u0001Complaint,Customer Issue\u0001Item Code,Customer Issue\u0001Item Name,Customer Issue\u0001Allocated To,Customer Issue\u0001Allocated On,Customer Issue\u0001Resolved By,Customer Issue\u0001Resolution Date,Customer Issue\u0001Customer Name,Customer Issue\u0001Fiscal Year"
- },
- {
- "name": "customer_issues",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/support/search_criteria/maintenance_orderwise_pending_amount_to_bill/__init__.py b/support/search_criteria/maintenance_orderwise_pending_amount_to_bill/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/support/search_criteria/maintenance_orderwise_pending_amount_to_bill/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/support/search_criteria/maintenance_orderwise_pending_amount_to_bill/maintenance_orderwise_pending_amount_to_bill.js b/support/search_criteria/maintenance_orderwise_pending_amount_to_bill/maintenance_orderwise_pending_amount_to_bill.js
deleted file mode 100644
index 1b3837a4ed7..00000000000
--- a/support/search_criteria/maintenance_orderwise_pending_amount_to_bill/maintenance_orderwise_pending_amount_to_bill.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
- this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
-}
\ No newline at end of file
diff --git a/support/search_criteria/maintenance_orderwise_pending_amount_to_bill/maintenance_orderwise_pending_amount_to_bill.txt b/support/search_criteria/maintenance_orderwise_pending_amount_to_bill/maintenance_orderwise_pending_amount_to_bill.txt
deleted file mode 100644
index ad9fe08dd0c..00000000000
--- a/support/search_criteria/maintenance_orderwise_pending_amount_to_bill/maintenance_orderwise_pending_amount_to_bill.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-[
- {
- "owner": "ashwini@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:51"
- },
- {
- "add_col": "SUM((`tabSales Order Item`.`qty` - `tabSales Order Item`.`billed_qty`) * `tabSales Order Item`.`basic_rate`) AS 'Pending Amount'",
- "parent_doc_type": "Sales Order",
- "module": "Support",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Sales Order\u0001Saved':1,'Sales Order\u0001Submitted':1,'Sales Order\u0001Status':'','Sales Order\u0001Fiscal Year':''}",
- "doc_type": "Sales Order Item",
- "name": "__common__",
- "add_cond": "`tabSales Order`.status != 'Stopped'\n`tabSales Order`.order_type='Maintenance'",
- "doctype": "Search Criteria",
- "sort_by": "`tabSales Order`.`name`",
- "page_len": 50,
- "criteria_name": "Maintenance Orderwise Pending Amount To Bill",
- "columns": "Sales Order\u0001ID,Sales Order\u0001Customer,Sales Order\u0001Customer Name,Sales Order\u0001Customer Address,Sales Order\u0001Status,Sales Order\u0001% Billed,Sales Order\u0001Sales Order Date"
- },
- {
- "name": "maintenance_orderwise_pending_amount_to_bill",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/support/search_criteria/maintenance_schedule_details/__init__.py b/support/search_criteria/maintenance_schedule_details/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/support/search_criteria/maintenance_schedule_details/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/support/search_criteria/maintenance_schedule_details/maintenance_schedule_details.js b/support/search_criteria/maintenance_schedule_details/maintenance_schedule_details.js
deleted file mode 100644
index c4800eac04e..00000000000
--- a/support/search_criteria/maintenance_schedule_details/maintenance_schedule_details.js
+++ /dev/null
@@ -1,29 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
-
- this.filter_fields_dict['Maintenance Schedule Detail'+FILTER_SEP +'From Scheduled Date'].df.in_first_page = 1;
- this.filter_fields_dict['Maintenance Schedule Detail'+FILTER_SEP +'To Scheduled Date'].df.in_first_page = 1;
- this.filter_fields_dict['Maintenance Schedule Detail'+FILTER_SEP +'Incharge Name'].df.in_first_page = 1;
- this.filter_fields_dict['Maintenance Schedule'+FILTER_SEP +'Customer'].df.in_first_page = 1;
- this.filter_fields_dict['Maintenance Schedule'+FILTER_SEP +'Customer Name'].df.in_first_page = 1;
- this.filter_fields_dict['Maintenance Schedule'+FILTER_SEP +'Sales Order No'].df.in_first_page = 1;
- //this.filter_fields_dict['Maintenance Schedule'+FILTER_SEP +'Status'].df.in_first_page = 0;
- this.filter_fields_dict['Maintenance Schedule'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
-}
-
-this.mytabs.items['Select Columns'].hide()
\ No newline at end of file
diff --git a/support/search_criteria/maintenance_schedule_details/maintenance_schedule_details.txt b/support/search_criteria/maintenance_schedule_details/maintenance_schedule_details.txt
deleted file mode 100644
index f8a588255ab..00000000000
--- a/support/search_criteria/maintenance_schedule_details/maintenance_schedule_details.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "owner": "nabin@webnotestech.com",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:51",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:51"
- },
- {
- "parent_doc_type": "Maintenance Schedule",
- "module": "Support",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Maintenance Schedule\u0001Submitted':1,'Maintenance Schedule\u0001Status':''}",
- "doc_type": "Maintenance Schedule Detail",
- "name": "__common__",
- "doctype": "Search Criteria",
- "sort_by": "`tabMaintenance Schedule Detail`.`item_code`",
- "page_len": 50,
- "criteria_name": "Maintenance Schedule Details",
- "columns": "Maintenance Schedule Detail\u0001Item Code,Maintenance Schedule Detail\u0001Item Name,Maintenance Schedule Detail\u0001Serial No,Maintenance Schedule Detail\u0001Incharge Name,Maintenance Schedule Detail\u0001Scheduled Date,Maintenance Schedule\u0001Customer Name,Maintenance Schedule\u0001Address,Maintenance Schedule\u0001Sales Order No"
- },
- {
- "name": "maintenance_schedule_details",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/support/search_criteria/warranty_amc_expiry_details/__init__.py b/support/search_criteria/warranty_amc_expiry_details/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/support/search_criteria/warranty_amc_expiry_details/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/support/search_criteria/warranty_amc_expiry_details/warranty_amc_expiry_details.js b/support/search_criteria/warranty_amc_expiry_details/warranty_amc_expiry_details.js
deleted file mode 100644
index ad5ce260abe..00000000000
--- a/support/search_criteria/warranty_amc_expiry_details/warranty_amc_expiry_details.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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 .
-
-//this.mytabs.items['Select Columns'].hide();
-
-report.customize_filters = function() {
- this.filter_fields_dict['Serial No'+FILTER_SEP +'Status'].df.in_first_page = 0;
- this.filter_fields_dict['Serial No'+FILTER_SEP +'Customer'].df.in_first_page = 1;
- this.filter_fields_dict['Serial No'+FILTER_SEP +'Customer Name'].df.in_first_page = 1;
- this.filter_fields_dict['Serial No'+FILTER_SEP +'Maintenance Status'].df.in_first_page = 1;
-
-}
\ No newline at end of file
diff --git a/support/search_criteria/warranty_amc_expiry_details/warranty_amc_expiry_details.txt b/support/search_criteria/warranty_amc_expiry_details/warranty_amc_expiry_details.txt
deleted file mode 100644
index bad5c9f10a4..00000000000
--- a/support/search_criteria/warranty_amc_expiry_details/warranty_amc_expiry_details.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:53",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:53"
- },
- {
- "module": "Support",
- "standard": "Yes",
- "sort_order": "DESC",
- "filters": "{'Serial No\u0001Saved':1,'Serial No\u0001Status':'','Serial No\u0001Maintenance Status':''}",
- "doctype": "Search Criteria",
- "doc_type": "Serial No",
- "name": "__common__",
- "sort_by": "`tabSerial No`.`name`",
- "page_len": 50,
- "criteria_name": "Warranty/AMC Expiry Details",
- "columns": "Serial No\u0001ID,Serial No\u0001Item Code,Serial No\u0001Description,Serial No\u0001Status,Serial No\u0001Item Group,Serial No\u0001Purchase Receipt No,Serial No\u0001Delivery Note No,Serial No\u0001Customer,Serial No\u0001Customer Name,Serial No\u0001AMC Expiry Date,Serial No\u0001Warranty Expiry Date"
- },
- {
- "name": "warranty-amc_expiry_details",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/support/search_criteria/warranty_amc_summary/__init__.py b/support/search_criteria/warranty_amc_summary/__init__.py
deleted file mode 100644
index baffc488252..00000000000
--- a/support/search_criteria/warranty_amc_summary/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/support/search_criteria/warranty_amc_summary/warranty_amc_summary.js b/support/search_criteria/warranty_amc_summary/warranty_amc_summary.js
deleted file mode 100644
index 4ad5a767b92..00000000000
--- a/support/search_criteria/warranty_amc_summary/warranty_amc_summary.js
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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 .
-
-report.customize_filters = function() {
- this.hide_all_filters();
- this.mytabs.items['Select Columns'].hide();
- this.mytabs.items['More Filters'].hide();
- this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Territory'+NEWLINE+'Item Group',ignore:1,parent:'Serial No',in_first_page:1, report_default:'Item Group'});
-}
-
-report.aftertableprint = function(t) {
- $yt(t,'*',1,{whiteSpace:'pre'});
-}
\ No newline at end of file
diff --git a/support/search_criteria/warranty_amc_summary/warranty_amc_summary.py b/support/search_criteria/warranty_amc_summary/warranty_amc_summary.py
deleted file mode 100644
index 8c102c38312..00000000000
--- a/support/search_criteria/warranty_amc_summary/warranty_amc_summary.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-
-from __future__ import unicode_literals
-opt = filter_values.get('based_on')
-opt_dict = {'Territory':'territory', 'Item Group':'item_group'}
-
-# ADD NEW COLUMNS
-row_list = [[opt,'Data','150px',''],
- ['Out of AMC','Int','150px',''],
- ['Under AMC','Int','150px',''],
- ['Out of Warranty','Int','150px',''],
- ['Under Warranty','Int','150px',''],
- ['Total','Int','150px','']]
-
-for r in row_list:
- colnames.append(r[0])
- coltypes.append(r[1])
- colwidths.append(r[2])
- coloptions.append(r[3])
- col_idx[r[0]] = len(colnames)-1
-
-
-#ADD VALUES TO THE COLUMN
-out=[]
-oa,ua,ow,uw,sum=0,0,0,0,0
-nowdate = nowdate()
-for r in res:
- lft_rgt = sql("select lft, rgt from `tab%s` where name = '%s'" % (opt,r[col_idx[opt]].strip()))
-
-
- det = sql("select COUNT(CASE WHEN t1.amc_expiry_date < '%s' THEN t1.name ELSE NULL END), COUNT(CASE WHEN t1.amc_expiry_date >= '%s' THEN t1.name ELSE NULL END), COUNT(CASE WHEN t1.warranty_expiry_date < '%s' THEN t1.name ELSE NULL END), COUNT(CASE WHEN t1.warranty_expiry_date >= '%s' THEN t1.name ELSE NULL END) from `tabSerial No` t1, `tab%s` t2 where t1.%s = t2.name and t2.lft>= '%s' and t2. rgt <= '%s' and t1.status = 'Delivered' and ifnull(item_group,'')!='' and ifnull(territory,'')!=''" %(nowdate,nowdate,nowdate,nowdate,opt, opt_dict[opt], lft_rgt[0][0], lft_rgt[0][1]))
-
- r.append(cint(det[0][0]))
- r.append(cint(det[0][1]))
- r.append(cint(det[0][2]))
- r.append(cint(det[0][3]))
- tot = cint(det[0][0]) + cint(det[0][1]) + cint(det[0][2]) + cint(det[0][3])
- r.append(tot)
- out.append(r)
diff --git a/support/search_criteria/warranty_amc_summary/warranty_amc_summary.sql b/support/search_criteria/warranty_amc_summary/warranty_amc_summary.sql
deleted file mode 100644
index ebd7ae845fe..00000000000
--- a/support/search_criteria/warranty_amc_summary/warranty_amc_summary.sql
+++ /dev/null
@@ -1 +0,0 @@
-SELECT CONCAT(REPEAT(' ', COUNT(parent.name) - 1), node.name) AS name FROM `tab%(based_on)s` AS node,`tab%(based_on)s` AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt AND node.docstatus !=2 GROUP BY node.name ORDER BY node.lft
\ No newline at end of file
diff --git a/support/search_criteria/warranty_amc_summary/warranty_amc_summary.txt b/support/search_criteria/warranty_amc_summary/warranty_amc_summary.txt
deleted file mode 100644
index 098b5d6dac1..00000000000
--- a/support/search_criteria/warranty_amc_summary/warranty_amc_summary.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2012-04-03 12:49:53",
- "modified_by": "Administrator",
- "modified": "2012-04-03 12:49:53"
- },
- {
- "module": "Support",
- "sort_order": "DESC",
- "filters": "{'Serial No\u0001Saved':1,'Serial No\u0001Status':''}",
- "standard": "Yes",
- "doc_type": "Serial No",
- "name": "__common__",
- "doctype": "Search Criteria",
- "sort_by": "name",
- "page_len": 50,
- "criteria_name": "Warranty/AMC Summary"
- },
- {
- "name": "warranty-amc_summary",
- "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/utilities/cleanup_data.py b/utilities/cleanup_data.py
index ed04a94bfaa..df7f4be1593 100644
--- a/utilities/cleanup_data.py
+++ b/utilities/cleanup_data.py
@@ -20,14 +20,16 @@ import webnotes
def delete_transactions():
print "Deleting transactions..."
- trans = ['Timesheet', 'Task', 'Support Ticket', 'Stock Reconciliation', 'Stock Ledger Entry',
+ trans = ['Task', 'Support Ticket', 'Stock Reconciliation', 'Stock Ledger Entry',
'Stock Entry', 'Sales Order', 'Salary Slip','Sales Invoice', 'Quotation',
'Quality Inspection', 'Purchase Receipt', 'Purchase Order', 'Production Order',
'POS Setting', 'Period Closing Voucher', 'Purchase Invoice', 'Maintenance Visit',
'Maintenance Schedule', 'Leave Application', 'Leave Allocation', 'Lead', 'Journal Voucher',
'Installation Note', 'Material Request', 'GL Entry', 'Expense Claim', 'Opportunity',
'Delivery Note', 'Customer Issue', 'Bin', 'Authorization Rule', 'Attendance', 'C-Form',
- 'Appraisal', 'Installation Note', 'Communication']
+ 'Appraisal', 'Installation Note', 'Communication', "Supplier Quotation", "Newsletter",
+ "Job Applicant", "Web Page", "Website Slideshow", "Blog Post", "Blog Category", "Blogger",
+ "Time Log", "Time Log Batch", "Workflow"]
for d in trans:
for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d):
webnotes.conn.sql("delete from `tab%s`" % (t))
@@ -66,6 +68,7 @@ def delete_masters():
'Item Group': ['All Item Groups', 'Default'],
'Item': '',
'Holiday List': '',
+ 'Activity Type': '',
'Grade': '',
'Feed': '',
'Expense Claim Type': ['Travel', 'Medical', 'Calls', 'Food', 'Others'],
diff --git a/utilities/doctype/address/address.py b/utilities/doctype/address/address.py
index 243bbdd7e3c..cfcbea582fa 100644
--- a/utilities/doctype/address/address.py
+++ b/utilities/doctype/address/address.py
@@ -18,6 +18,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes import msgprint
+from webnotes.utils import cstr
class DocType:
def __init__(self, doc, doclist=[]):
@@ -29,7 +30,7 @@ class DocType:
self.doc.address_title = self.doc.customer or self.doc.supplier or self.doc.sales_partner
if self.doc.address_title:
- self.doc.name = self.doc.address_title + "-" + self.doc.address_type
+ self.doc.name = cstr(self.doc.address_title).strip() + "-" + cstr(self.doc.address_type).strip()
else:
webnotes.msgprint("""Address Title is mandatory.""", raise_exception=True)
diff --git a/utilities/doctype/address/test_address.py b/utilities/doctype/address/test_address.py
new file mode 100644
index 00000000000..eddd9c754de
--- /dev/null
+++ b/utilities/doctype/address/test_address.py
@@ -0,0 +1,14 @@
+test_records = [
+ [{
+ "doctype": "Address",
+ "customer": "_Test Customer",
+ "customer_name": "_Test Customer",
+ "address_type": "Office",
+ "address_title": "_Test Address",
+ "address_line1": "_Test Address Line 1",
+ "city": "_Test City",
+ "country": "India",
+ "phone": "+91 0000000000",
+ "is_primary_address": 1
+ }],
+]
\ No newline at end of file
diff --git a/utilities/doctype/contact/contact.py b/utilities/doctype/contact/contact.py
index bceee7d6a14..a19501f100b 100644
--- a/utilities/doctype/contact/contact.py
+++ b/utilities/doctype/contact/contact.py
@@ -16,7 +16,7 @@
from __future__ import unicode_literals
import webnotes
-
+from webnotes.utils import cstr
from utilities.transaction_base import TransactionBase
@@ -32,15 +32,16 @@ class DocType(TransactionBase):
webnotes.conn.set(self.doc, 'status', 'Replied')
def autoname(self):
- if self.doc.customer:
- self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.customer
- elif self.doc.supplier:
- self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.supplier
- elif self.doc.sales_partner:
- self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.sales_partner
- else:
- self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '')
-
+ # concat first and last name
+ self.doc.name = " ".join(filter(None,
+ [cstr(self.doc.fields.get(f)).strip() for f in ["first_name", "last_name"]]))
+
+ # concat party name if reqd
+ for fieldname in ("customer", "supplier", "sales_partner"):
+ if self.doc.fields.get(fieldname):
+ self.doc.name = self.doc.name + "-" + cstr(self.doc.fields.get(fieldname)).strip()
+ break
+
def validate(self):
self.validate_primary_contact()
diff --git a/utilities/doctype/question/question.txt b/utilities/doctype/question/question.txt
index b064e331054..fbd7b75341b 100644
--- a/utilities/doctype/question/question.txt
+++ b/utilities/doctype/question/question.txt
@@ -1,75 +1,76 @@
[
{
- "owner": "Administrator",
+ "creation": "2013-01-02 17:08:46",
"docstatus": 0,
- "creation": "2012-07-03 13:30:42",
+ "modified": "2013-01-01 18:58:55",
"modified_by": "Administrator",
- "modified": "2013-01-01 18:58:55"
+ "owner": "Administrator"
},
{
- "read_only": 1,
- "in_create": 1,
+ "allow_attach": 0,
"autoname": "QUES.#######",
- "name": "__common__",
- "module": "Utilities",
"doctype": "DocType",
- "allow_attach": 0
+ "in_create": 1,
+ "module": "Utilities",
+ "name": "__common__",
+ "read_only": 1
},
{
- "name": "__common__",
- "parent": "Question",
"doctype": "DocField",
+ "name": "__common__",
+ "parent": "Question",
+ "parentfield": "fields",
"parenttype": "DocType",
- "permlevel": 0,
- "parentfield": "fields"
+ "permlevel": 0
},
{
- "parent": "Question",
- "read": 1,
- "report": 1,
"cancel": 1,
- "name": "__common__",
"create": 1,
"doctype": "DocPerm",
- "write": 1,
+ "name": "__common__",
+ "parent": "Question",
+ "parentfield": "permissions",
"parenttype": "DocType",
- "role": "All",
"permlevel": 0,
- "parentfield": "permissions"
+ "read": 1,
+ "report": 1,
+ "role": "All",
+ "submit": 0,
+ "write": 1
},
{
- "name": "Question",
- "doctype": "DocType"
+ "doctype": "DocType",
+ "name": "Question"
},
{
- "oldfieldtype": "Text",
"doctype": "DocField",
+ "fieldname": "question",
+ "fieldtype": "Text",
"label": "Question",
"oldfieldname": "question",
- "fieldname": "question",
- "fieldtype": "Text"
+ "oldfieldtype": "Text"
},
{
"doctype": "DocField",
- "label": "Points",
"fieldname": "points",
"fieldtype": "Int",
- "hidden": 1
+ "hidden": 1,
+ "label": "Points"
},
{
- "oldfieldtype": "Text Editor",
"doctype": "DocField",
+ "fieldname": "answer",
+ "fieldtype": "Text Editor",
"label": "Answer",
"oldfieldname": "answer",
- "fieldname": "answer",
- "fieldtype": "Text Editor"
+ "oldfieldtype": "Text Editor"
},
{
"doctype": "DocField",
- "label": "User Tags",
"fieldname": "_user_tags",
"fieldtype": "Data",
- "hidden": 1
+ "hidden": 1,
+ "label": "User Tags"
},
{
"doctype": "DocField",
@@ -77,15 +78,6 @@
"fieldtype": "Text",
"label": "Users Voted"
},
- {
- "oldfieldtype": "Text",
- "doctype": "DocField",
- "label": "File List",
- "oldfieldname": "file_list",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1
- },
{
"doctype": "DocPerm"
}
diff --git a/utilities/doctype/rename_tool/rename_tool.py b/utilities/doctype/rename_tool/rename_tool.py
index 2e368ced709..5accf3c6b77 100644
--- a/utilities/doctype/rename_tool/rename_tool.py
+++ b/utilities/doctype/rename_tool/rename_tool.py
@@ -34,7 +34,8 @@ def upload(select_doctype=None, rows=None):
rename_log = []
for row in rows:
- if len(row) > 2:
+ # if row has some content
+ if len(row) > 1 and row[0] and row[1]:
try:
if rename_doc(select_doctype, row[0], row[1]):
rename_log.append(_("Successful: ") + row[0] + " -> " + row[1])
@@ -45,5 +46,5 @@ def upload(select_doctype=None, rows=None):
rename_log.append("" + \
_("Failed: ") + row[0] + " -> " + row[1] + "")
rename_log.append("" + repr(e) + "")
-
+
return rename_log
\ No newline at end of file
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index 4b34ba1286c..03321853a7f 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -22,6 +22,23 @@ from webnotes.model.doc import addchild
from webnotes.model.controller import DocListController
class TransactionBase(DocListController):
+ def get_default_address_and_contact(self, party_type):
+ """get a dict of default field values of address and contact for a given party type
+ party_type can be one of: customer, supplier"""
+ ret = {}
+
+ # {customer: self.doc.fields.get("customer")}
+ args = {party_type: self.doc.fields.get(party_type)}
+
+ address_text, address_name = self.get_address_text(**args)
+ ret.update({
+ # customer_address
+ (party_type + "_address"): address_name,
+ "address_display": address_text
+ })
+ ret.update(self.get_contact_text(**args))
+ return ret
+
# Get Customer Default Primary Address - first load
def get_default_customer_address(self, args=''):
address_text, address_name = self.get_address_text(customer=self.doc.customer)
@@ -73,7 +90,7 @@ class TransactionBase(DocListController):
details = webnotes.conn.sql("select name, address_line1, address_line2, city, country, pincode, state, phone, fax from `tabAddress` where %s and docstatus != 2 order by is_shipping_address desc, is_primary_address desc limit 1" % cond, as_dict = 1)
else:
details = webnotes.conn.sql("select name, address_line1, address_line2, city, country, pincode, state, phone, fax from `tabAddress` where %s and docstatus != 2 order by is_primary_address desc limit 1" % cond, as_dict = 1)
-
+
extract = lambda x: details and details[0] and details[0].get(x,'') or ''
address_fields = [('','address_line1'),('\n','address_line2'),('\n','city'),('\n','state'),(' ','pincode'),('\n','country'),('\nPhone: ','phone'),('\nFax: ', 'fax')]
address_display = ''.join([a[0]+extract(a[1]) for a in address_fields if extract(a[1])])
@@ -251,4 +268,43 @@ class TransactionBase(DocListController):
def validate_posting_time(self):
if not self.doc.posting_time:
self.doc.posting_time = now_datetime().strftime('%H:%M:%S')
-
\ No newline at end of file
+
+ def add_calendar_event(self, opts, force=False):
+ if self.doc.contact_by != cstr(self._prev.contact_by) or \
+ self.doc.contact_date != cstr(self._prev.contact_date) or force:
+
+ self.delete_events()
+ self._add_calendar_event(opts)
+
+ def delete_events(self):
+ webnotes.delete_doc("Event", webnotes.conn.sql_list("""select name from `tabEvent`
+ where ref_type=%s and ref_name=%s""", (self.doc.doctype, self.doc.name)))
+
+ def _add_calendar_event(self, opts):
+ opts = webnotes._dict(opts)
+
+ if self.doc.contact_date:
+ event_doclist = [{
+ "doctype": "Event",
+ "owner": opts.owner or self.doc.owner,
+ "subject": opts.subject,
+ "description": opts.description,
+ "starts_on": self.doc.contact_date + " 10:00:00",
+ "event_type": "Private",
+ "ref_type": self.doc.doctype,
+ "ref_name": self.doc.name
+ }]
+
+ if webnotes.conn.exists("Profile", self.doc.contact_by):
+ event_doclist.append({
+ "doctype": "Event User",
+ "parentfield": "event_individuals",
+ "person": self.doc.contact_by
+ })
+
+ webnotes.bean(event_doclist).insert()
+
+
+def delete_events(ref_type, ref_name):
+ webnotes.delete_doc("Event", webnotes.conn.sql_list("""select name from `tabEvent`
+ where ref_type=%s and ref_name=%s""", (ref_type, ref_name)), for_reload=True)
\ No newline at end of file
diff --git a/website/doctype/about_us_settings/about_us_settings.txt b/website/doctype/about_us_settings/about_us_settings.txt
index b846d2bc6c2..baf9cc0af8c 100644
--- a/website/doctype/about_us_settings/about_us_settings.txt
+++ b/website/doctype/about_us_settings/about_us_settings.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-07 15:53:15",
+ "creation": "2013-03-19 12:02:15",
"docstatus": 0,
- "modified": "2013-03-12 14:48:34",
+ "modified": "2013-05-03 11:01:30",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -10,7 +10,7 @@
"allow_attach": 1,
"description": "Settings for the About Us Page",
"doctype": "DocType",
- "document_type": "Master",
+ "document_type": "Other",
"issingle": 1,
"module": "Website",
"name": "__common__"
@@ -21,7 +21,8 @@
"parent": "About Us Settings",
"parentfield": "fields",
"parenttype": "DocType",
- "permlevel": 0
+ "permlevel": 0,
+ "read_only": 0
},
{
"create": 1,
@@ -102,15 +103,6 @@
"fieldtype": "Text Editor",
"label": "Footer"
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"doctype": "DocPerm"
}
diff --git a/website/doctype/blog_post/blog_post.py b/website/doctype/blog_post/blog_post.py
index 05236a1ca25..62cc910860d 100644
--- a/website/doctype/blog_post/blog_post.py
+++ b/website/doctype/blog_post/blog_post.py
@@ -76,10 +76,12 @@ class DocType:
self.doc.full_name = get_fullname(self.doc.owner)
self.doc.updated = global_date_format(self.doc.published_on)
self.doc.content_html = self.doc.content
+
if self.doc.blogger:
self.doc.blogger_info = webnotes.doc("Blogger", self.doc.blogger).fields
self.doc.description = self.doc.blog_intro or self.doc.content[:140]
+ self.doc.meta_description = self.doc.description
self.doc.categories = webnotes.conn.sql_list("select name from `tabBlog Category` order by name")
diff --git a/website/doctype/blog_post/blog_post.txt b/website/doctype/blog_post/blog_post.txt
index 4144e401343..07c53926a91 100644
--- a/website/doctype/blog_post/blog_post.txt
+++ b/website/doctype/blog_post/blog_post.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-03-08 11:36:50",
+ "creation": "2013-03-28 10:35:30",
"docstatus": 0,
"modified": "2013-03-18 13:55:53",
"modified_by": "Administrator",
@@ -114,15 +114,6 @@
"hidden": 1,
"label": "Email Sent"
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"create": 1,
"doctype": "DocPerm",
diff --git a/website/doctype/blogger/blogger.txt b/website/doctype/blogger/blogger.txt
index f56df1f2b38..da065c52f6b 100644
--- a/website/doctype/blogger/blogger.txt
+++ b/website/doctype/blogger/blogger.txt
@@ -82,15 +82,6 @@
"label": "Posts",
"read_only": 1
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"create": 1,
"doctype": "DocPerm",
diff --git a/website/doctype/style_settings/style_settings.txt b/website/doctype/style_settings/style_settings.txt
index df266a5992c..e31713aa5ff 100644
--- a/website/doctype/style_settings/style_settings.txt
+++ b/website/doctype/style_settings/style_settings.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-03-08 11:36:53",
+ "creation": "2013-03-25 16:01:33",
"docstatus": 0,
"modified": "2013-03-14 11:57:20",
"modified_by": "Administrator",
@@ -184,15 +184,6 @@
"label": "Custom CSS",
"read_only": 1
},
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
{
"create": 1,
"doctype": "DocPerm",
diff --git a/website/doctype/web_page/web_page.py b/website/doctype/web_page/web_page.py
index d43bcb4e3d7..6d0cafaf6af 100644
--- a/website/doctype/web_page/web_page.py
+++ b/website/doctype/web_page/web_page.py
@@ -44,3 +44,5 @@ class DocType():
if self.doc.slideshow:
from website.helpers.slideshow import get_slideshow
get_slideshow(self)
+
+ self.doc.meta_description = self.doc.description
diff --git a/website/doctype/web_page/web_page.txt b/website/doctype/web_page/web_page.txt
index eed7d2b63b4..effe06433d9 100644
--- a/website/doctype/web_page/web_page.txt
+++ b/website/doctype/web_page/web_page.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-02-12 13:19:11",
+ "creation": "2013-03-28 10:35:30",
"docstatus": 0,
"modified": "2013-03-11 17:41:11",
"modified_by": "Administrator",
@@ -24,14 +24,12 @@
"permlevel": 0
},
{
- "amend": 0,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Web Page",
"parentfield": "permissions",
"parenttype": "DocType",
"read": 1,
- "report": 1,
"role": "Website Manager",
"submit": 0
},
@@ -139,26 +137,18 @@
"options": "CSS"
},
{
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
- },
- {
- "cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
+ "report": 1,
"write": 1
},
{
+ "amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "permlevel": 1,
- "write": 0
+ "match": "",
+ "permlevel": 1
}
]
\ No newline at end of file
diff --git a/website/doctype/website_settings/website_settings.txt b/website/doctype/website_settings/website_settings.txt
index 0ebc75b2eb7..9c15480f07a 100644
--- a/website/doctype/website_settings/website_settings.txt
+++ b/website/doctype/website_settings/website_settings.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-26 06:51:18",
+ "creation": "2013-04-30 12:58:46",
"docstatus": 0,
- "modified": "2013-04-17 11:51:24",
+ "modified": "2013-05-02 15:51:14",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -219,22 +219,16 @@
"reqd": 0
},
{
- "description": "Enter domain names associated to this website, each on a new line",
"doctype": "DocField",
- "fieldname": "domain_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "Domain List",
- "reqd": 0
+ "fieldname": "column_break_28",
+ "fieldtype": "Column Break"
},
{
+ "description": "Disable Customer Signup link in Login page",
"doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
+ "fieldname": "disable_signup",
+ "fieldtype": "Check",
+ "label": "Disable Signup"
},
{
"create": 1,
diff --git a/website/doctype/website_slideshow/website_slideshow.py b/website/doctype/website_slideshow/website_slideshow.py
index 928aa9ff9f2..86bd2a0433a 100644
--- a/website/doctype/website_slideshow/website_slideshow.py
+++ b/website/doctype/website_slideshow/website_slideshow.py
@@ -5,4 +5,9 @@ import webnotes
class DocType:
def __init__(self, d, dl):
- self.doc, self.doclist = d, dl
\ No newline at end of file
+ self.doc, self.doclist = d, dl
+
+ def on_update(self):
+ # a slide show can be in use and any change in it should get reflected
+ from webnotes.webutils import clear_cache
+ clear_cache()
\ No newline at end of file
diff --git a/website/doctype/website_slideshow/website_slideshow.txt b/website/doctype/website_slideshow/website_slideshow.txt
index 4caa617f311..2887d4b464c 100644
--- a/website/doctype/website_slideshow/website_slideshow.txt
+++ b/website/doctype/website_slideshow/website_slideshow.txt
@@ -1,84 +1,78 @@
[
{
- "owner": "Administrator",
+ "creation": "2013-03-07 14:48:40",
"docstatus": 0,
- "creation": "2012-12-25 16:47:53",
+ "modified": "2012-12-25 16:56:34",
"modified_by": "Administrator",
- "modified": "2012-12-25 16:56:34"
+ "owner": "Administrator"
},
{
"allow_attach": 1,
"autoname": "field:slideshow_name",
- "name": "__common__",
- "module": "Website",
+ "description": "Slideshow like display for the website",
"doctype": "DocType",
- "max_attachments": 10,
"document_type": "Transaction",
- "description": "Slideshow like display for the website"
+ "max_attachments": 10,
+ "module": "Website",
+ "name": "__common__"
},
{
- "name": "__common__",
- "parent": "Website Slideshow",
"doctype": "DocField",
+ "name": "__common__",
+ "parent": "Website Slideshow",
+ "parentfield": "fields",
"parenttype": "DocType",
- "permlevel": 0,
- "parentfield": "fields"
+ "permlevel": 0
},
{
- "parent": "Website Slideshow",
- "read": 1,
- "report": 1,
"cancel": 1,
- "name": "__common__",
"create": 1,
"doctype": "DocPerm",
- "write": 1,
+ "name": "__common__",
+ "parent": "Website Slideshow",
+ "parentfield": "permissions",
"parenttype": "DocType",
- "role": "Website Manager",
"permlevel": 0,
- "parentfield": "permissions"
+ "read": 1,
+ "report": 1,
+ "role": "Website Manager",
+ "submit": 0,
+ "write": 1
},
{
- "name": "Website Slideshow",
- "doctype": "DocType"
+ "doctype": "DocType",
+ "name": "Website Slideshow"
},
{
- "read_only": 0,
"doctype": "DocField",
- "label": "Slideshow Name",
"fieldname": "slideshow_name",
"fieldtype": "Data",
+ "label": "Slideshow Name",
+ "read_only": 0,
"reqd": 1
},
{
"depends_on": "eval:!doc.__islocal",
"doctype": "DocField",
- "label": "Slideshow Items",
"fieldname": "sb0",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "label": "Slideshow Items"
},
{
"depends_on": "eval:!doc.__islocal",
"doctype": "DocField",
- "label": "Slideshow Items",
"fieldname": "slideshow_items",
"fieldtype": "Table",
+ "label": "Slideshow Items",
"options": "Website Slideshow Item"
},
{
- "description": "This goes above the slideshow.",
"depends_on": "eval:!doc.__islocal",
+ "description": "This goes above the slideshow.",
"doctype": "DocField",
- "label": "Header",
"fieldname": "header",
- "fieldtype": "Text Editor"
- },
- {
- "doctype": "DocField",
- "label": "File List",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1
+ "fieldtype": "Text Editor",
+ "label": "Header"
},
{
"doctype": "DocPerm"
diff --git a/website/doctype/website_slideshow_item/website_slideshow_item.txt b/website/doctype/website_slideshow_item/website_slideshow_item.txt
index aa98745451f..53aa628bde6 100644
--- a/website/doctype/website_slideshow_item/website_slideshow_item.txt
+++ b/website/doctype/website_slideshow_item/website_slideshow_item.txt
@@ -1,6 +1,6 @@
[
{
- "creation": "2013-02-22 01:28:09",
+ "creation": "2013-03-07 12:26:33",
"docstatus": 0,
"modified": "2013-03-07 07:03:34",
"modified_by": "Administrator",
@@ -48,14 +48,5 @@
"label": "Description",
"print_width": "200px",
"width": "200px"
- },
- {
- "doctype": "DocField",
- "fieldname": "file_list",
- "fieldtype": "Text",
- "hidden": 1,
- "label": "File List",
- "no_copy": 1,
- "print_hide": 1
}
]
\ No newline at end of file
diff --git a/website/helpers/blog_feed.py b/website/helpers/blog_feed.py
index 41c203e0ada..c79c5cc3bb3 100644
--- a/website/helpers/blog_feed.py
+++ b/website/helpers/blog_feed.py
@@ -49,9 +49,10 @@ rss_item = u"""
def generate():
"""generate rss feed"""
- import webnotes, os
+ import os, urllib
+ import webnotes
from webnotes.model.doc import Document
- from website.helpers.blog import get_blog_content
+ from webnotes.utils import escape_html
host = (os.environ.get('HTTPS') and 'https://' or 'http://') + os.environ.get('HTTP_HOST')
@@ -62,7 +63,8 @@ def generate():
order by published_on desc limit 20""", as_dict=1)
for blog in blog_list:
- blog.link = host + '/' + blog.name + '.html'
+ blog.link = urllib.quote(host + '/' + blog.name + '.html')
+ blog.content = escape_html(blog.content or "")
items += rss_item % blog
diff --git a/website/helpers/product.py b/website/helpers/product.py
index d6f16fb7530..a107d9b02ba 100644
--- a/website/helpers/product.py
+++ b/website/helpers/product.py
@@ -4,10 +4,9 @@
from __future__ import unicode_literals
import webnotes
-from webnotes.utils import cstr
+from webnotes.utils import cstr, cint
from webnotes.webutils import build_html, delete_page_cache
-
@webnotes.whitelist(allow_guest=True)
def get_product_info(item_code):
"""get product price / stock info"""
@@ -20,10 +19,20 @@ def get_product_info(item_code):
in_stock = in_stock[0][0] > 0 and 1 or 0
else:
in_stock = -1
+
+ price = price_list and webnotes.conn.sql("""select ref_rate, ref_currency from
+ `tabItem Price` where parent=%s and price_list_name=%s""",
+ (item_code, price_list), as_dict=1) or []
+
+ price = price and price[0] or None
+
+ if price:
+ price["ref_currency"] = not cint(webnotes.conn.get_default("hide_currency_symbol")) \
+ and (webnotes.conn.get_value("Currency", price.ref_currency, "symbol") or price.ref_currency) \
+ or ""
+
return {
- "price": price_list and webnotes.conn.sql("""select ref_rate, ref_currency from
- `tabItem Price` where parent=%s and price_list_name=%s""",
- (item_code, price_list), as_dict=1) or [],
+ "price": price,
"stock": in_stock
}
diff --git a/website/helpers/sitemap.py b/website/helpers/sitemap.py
index c8b6fd0a53b..3956da1a709 100644
--- a/website/helpers/sitemap.py
+++ b/website/helpers/sitemap.py
@@ -2,6 +2,7 @@
# License: GNU General Public License (v3). For more information see license.txt
from __future__ import unicode_literals
+
frame_xml = """
%s
"""
@@ -32,10 +33,11 @@ def generate(domain):
for p in pages:
if count >= max_items: break
- page_url = os.path.join(domain, urllib.quote(p[0]))
- modified = p[1].strftime('%Y-%m-%d')
- site_map += link_xml % (page_url, modified)
- count += 1
+ if p[0]:
+ page_url = os.path.join(domain, urllib.quote(p[0]))
+ modified = p[1].strftime('%Y-%m-%d')
+ site_map += link_xml % (page_url, modified)
+ count += 1
if count >= max_items: break
diff --git a/website/templates/css/product_page.css b/website/templates/css/product_page.css
index 566b6b57aab..71be9ee56b0 100644
--- a/website/templates/css/product_page.css
+++ b/website/templates/css/product_page.css
@@ -7,4 +7,7 @@
font-size: 18px;
line-height: 200%;
}
+ .item-price {
+ margin-top: 20px;
+ }
\ No newline at end of file
diff --git a/website/templates/html/product_group.html b/website/templates/html/product_group.html
index b3c851197e5..0ad4048cdac 100644
--- a/website/templates/html/product_group.html
+++ b/website/templates/html/product_group.html
@@ -1,8 +1,6 @@
{% extends "app/website/templates/html/page.html" %}
{% block content %}
-{% include 'app/website/templates/html/product_search_box.html' %}
-{% include 'app/website/templates/html/product_breadcrumbs.html' %}
{% if slideshow %}
{% include "app/website/templates/html/slideshow.html" %}
@@ -12,6 +10,10 @@
{% else %}
{{ name }}
{% endif %}
+
+{% include 'app/website/templates/html/product_search_box.html' %}
+{% include 'app/website/templates/html/product_breadcrumbs.html' %}
+
{% if sub_groups %}
diff --git a/website/templates/html/product_page.html b/website/templates/html/product_page.html
index 23091ad435b..3fda8cd271c 100644
--- a/website/templates/html/product_page.html
+++ b/website/templates/html/product_page.html
@@ -35,23 +35,25 @@
{{ web_long_description or web_short_description or
"[No description given]" }}
- {% if obj.doclist.get({"doctype":"Item Website Specification"}) %}
+
+
+
+
+ {% if obj.doclist.get({"doctype":"Item Website Specification"}) -%}
+
+
Specifications
{% for d in obj.doclist.get(
- {"doctype":"Item Website Specification"}) %}
+ {"doctype":"Item Website Specification"}) -%}
| {{ d.label }} |
{{ d.description }} |
- {% endfor %}
+ {%- endfor %}
- {% endif %}
-
-
+ {%- endif %}
{% endblock %}
\ No newline at end of file
diff --git a/website/templates/html/slideshow.html b/website/templates/html/slideshow.html
index e0e9038d9fd..b26338c5e59 100644
--- a/website/templates/html/slideshow.html
+++ b/website/templates/html/slideshow.html
@@ -8,7 +8,7 @@
{% if slide.heading or slide.description %}
{% if slide.heading %}
{{ slide.heading }}
{% endif %}
- {% if slide.heading %}
{{ slide.description }}
{% endif %}
+ {% if slide.description %}
{{ slide.description }}
{% endif %}
{% endif %}
diff --git a/website/templates/js/product_page.js b/website/templates/js/product_page.js
index 653cfa32390..69e9cd52feb 100644
--- a/website/templates/js/product_page.js
+++ b/website/templates/js/product_page.js
@@ -26,8 +26,8 @@ $(document).ready(function() {
success: function(data) {
if(data.message) {
if(data.message.price) {
- $("").html(data.message.price[0].ref_currency + " "
- + data.message.price[0].ref_rate).appendTo(".item-price");
+ $("").html(data.message.price.ref_currency + " "
+ + data.message.price.ref_rate).appendTo(".item-price");
$(".item-price").toggle(true);
}
if(data.message.stock==0) {