mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
[merge] merge with master
This commit is contained in:
@@ -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(" - ")
|
||||
|
||||
|
||||
@@ -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"""
|
||||
|
||||
@@ -29,7 +29,7 @@ class DocType(DocTypeNestedSet):
|
||||
def autoname(self):
|
||||
company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s",
|
||||
self.doc.company_name)[0][0]
|
||||
self.doc.name = self.doc.cost_center_name + ' - ' + company_abbr
|
||||
self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr
|
||||
|
||||
def validate_mandatory(self):
|
||||
if not self.doc.group_or_ledger:
|
||||
@@ -87,7 +87,7 @@ class DocType(DocTypeNestedSet):
|
||||
self.validate_mandatory()
|
||||
self.validate_budget_details()
|
||||
|
||||
def on_rename(self, new, old):
|
||||
def on_rename(self, new, old, merge=False):
|
||||
company_abbr = webnotes.conn.get_value("Company", self.doc.company_name, "abbr")
|
||||
parts = new.split(" - ")
|
||||
|
||||
|
||||
@@ -34,11 +34,6 @@ class DocType(AccountsController):
|
||||
self.credit_days_global = -1
|
||||
self.is_approving_authority = -1
|
||||
|
||||
def autoname(self):
|
||||
if not self.doc.naming_series:
|
||||
webnotes.msgprint("""Naming Series is mandatory""", raise_exception=1)
|
||||
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
|
||||
|
||||
def validate(self):
|
||||
if not self.doc.is_opening:
|
||||
self.doc.is_opening='No'
|
||||
|
||||
@@ -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)
|
||||
]
|
||||
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-04-30 12:58:25",
|
||||
"creation": "2013-05-09 13:16:11",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-03 14:36:24",
|
||||
"modified": "2013-05-23 12:52:09",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -213,6 +213,14 @@
|
||||
"options": "link:Print Heading"
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "System Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Accounts Manager",
|
||||
|
||||
@@ -464,15 +464,17 @@ class DocType(BuyingController):
|
||||
# if auto inventory accounting enabled and stock item,
|
||||
# then do stock related gl entries
|
||||
# expense will be booked in sales invoice
|
||||
|
||||
stock_item_and_auto_inventory_accounting = True
|
||||
|
||||
valuation_amt = (flt(item.amount, self.precision.item.amount) +
|
||||
flt(item.item_tax_amount, self.precision.item.item_tax_amount) +
|
||||
flt(item.rm_supp_cost, self.precision.item.rm_supp_cost))
|
||||
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": stock_account,
|
||||
"against": self.doc.credit_to,
|
||||
"debit": flt(item.valuation_rate) * flt(item.conversion_factor) \
|
||||
* flt(item.qty),
|
||||
"debit": valuation_amt,
|
||||
"remarks": self.doc.remarks or "Accounting Entry for Stock"
|
||||
})
|
||||
)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-04-09 10:18:10",
|
||||
"creation": "2013-05-07 13:50:30",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-03-22 18:17:14",
|
||||
"modified": "2013-05-13 11:12:56",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -30,7 +30,9 @@
|
||||
"parent": "Purchase Invoice",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"read": 1
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
@@ -41,6 +43,7 @@
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"oldfieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -54,6 +57,7 @@
|
||||
"oldfieldtype": "Select",
|
||||
"options": "BILL\nBILLJ",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
@@ -68,6 +72,7 @@
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Account",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
@@ -80,7 +85,8 @@
|
||||
"oldfieldname": "supplier",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Supplier",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -131,6 +137,7 @@
|
||||
"fieldname": "column_break1",
|
||||
"fieldtype": "Column Break",
|
||||
"oldfieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"reqd": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
@@ -146,6 +153,7 @@
|
||||
"oldfieldname": "posting_date",
|
||||
"oldfieldtype": "Date",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
@@ -159,6 +167,7 @@
|
||||
"oldfieldname": "bill_no",
|
||||
"oldfieldtype": "Data",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
@@ -171,6 +180,7 @@
|
||||
"oldfieldname": "bill_date",
|
||||
"oldfieldtype": "Date",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
@@ -179,7 +189,8 @@
|
||||
"fieldname": "items",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Items",
|
||||
"oldfieldtype": "Section Break"
|
||||
"oldfieldtype": "Section Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 1,
|
||||
@@ -189,25 +200,29 @@
|
||||
"label": "Entries",
|
||||
"oldfieldname": "entries",
|
||||
"oldfieldtype": "Table",
|
||||
"options": "Purchase Invoice Item"
|
||||
"options": "Purchase Invoice Item",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break0",
|
||||
"fieldtype": "Section Break"
|
||||
"fieldtype": "Section Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "recalculate",
|
||||
"fieldtype": "Button",
|
||||
"label": "Recalculate",
|
||||
"oldfieldtype": "Button"
|
||||
"oldfieldtype": "Button",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_17",
|
||||
"fieldtype": "Section Break",
|
||||
"options": "Simple"
|
||||
"options": "Simple",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Select Items from Purchase Order",
|
||||
@@ -218,7 +233,8 @@
|
||||
"oldfieldname": "purchase_order_main",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Purchase Order",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Select Items from Purchase Receipt",
|
||||
@@ -229,7 +245,8 @@
|
||||
"oldfieldname": "purchase_receipt_main",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Purchase Receipt",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -237,13 +254,15 @@
|
||||
"fieldtype": "Button",
|
||||
"label": "Get Items",
|
||||
"oldfieldtype": "Button",
|
||||
"options": "pull_details"
|
||||
"options": "pull_details",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "currency_price_list",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Currency & Price List"
|
||||
"label": "Currency & Price List",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -253,7 +272,8 @@
|
||||
"oldfieldname": "currency",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "Currency",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
@@ -264,12 +284,14 @@
|
||||
"label": "Exchange Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"oldfieldtype": "Currency",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break2",
|
||||
"fieldtype": "Column Break"
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
|
||||
@@ -278,7 +300,8 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "Price List",
|
||||
"options": "Price List",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "price_list_name",
|
||||
@@ -287,7 +310,8 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "Price List Currency",
|
||||
"options": "Currency",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "price_list_name",
|
||||
@@ -295,7 +319,8 @@
|
||||
"fieldname": "plc_conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"label": "Price List Exchange Rate",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Add / Edit Taxes and Charges",
|
||||
@@ -303,7 +328,8 @@
|
||||
"fieldname": "taxes",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Taxes",
|
||||
"oldfieldtype": "Section Break"
|
||||
"oldfieldtype": "Section Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -313,7 +339,8 @@
|
||||
"oldfieldname": "purchase_other_charges",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Purchase Taxes and Charges Master",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -322,7 +349,8 @@
|
||||
"label": "Get Tax Detail",
|
||||
"oldfieldtype": "Button",
|
||||
"options": "get_purchase_tax_details",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -331,7 +359,8 @@
|
||||
"label": "Purchase Taxes and Charges",
|
||||
"oldfieldname": "purchase_tax_details",
|
||||
"oldfieldtype": "Table",
|
||||
"options": "Purchase Taxes and Charges"
|
||||
"options": "Purchase Taxes and Charges",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -339,7 +368,8 @@
|
||||
"fieldtype": "Button",
|
||||
"label": "Calculate Tax",
|
||||
"oldfieldtype": "Button",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -347,7 +377,8 @@
|
||||
"fieldtype": "HTML",
|
||||
"label": "Tax Calculation",
|
||||
"oldfieldtype": "HTML",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -364,7 +395,8 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "contact_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Contact Info"
|
||||
"label": "Contact Info",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.supplier",
|
||||
@@ -372,12 +404,14 @@
|
||||
"fieldname": "supplier_address",
|
||||
"fieldtype": "Link",
|
||||
"label": "Supplier Address",
|
||||
"options": "Address"
|
||||
"options": "Address",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "col_break23",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -387,14 +421,16 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "Contact Person",
|
||||
"options": "Contact",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "totals",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Totals",
|
||||
"oldfieldtype": "Section Break"
|
||||
"oldfieldtype": "Section Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -497,6 +533,7 @@
|
||||
"fieldtype": "Column Break",
|
||||
"oldfieldtype": "Column Break",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -562,7 +599,8 @@
|
||||
"label": "Write Off Amount",
|
||||
"no_copy": 1,
|
||||
"options": "Company:company:default_currency",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:flt(doc.write_off_amount)!=0",
|
||||
@@ -572,7 +610,8 @@
|
||||
"label": "Write Off Account",
|
||||
"no_copy": 1,
|
||||
"options": "Account",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:flt(doc.write_off_amount)!=0",
|
||||
@@ -581,8 +620,9 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "Write Off Cost Center",
|
||||
"no_copy": 1,
|
||||
"options": "Account",
|
||||
"print_hide": 1
|
||||
"options": "Cost Center",
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -594,6 +634,7 @@
|
||||
"oldfieldname": "against_expense_account",
|
||||
"oldfieldtype": "Small Text",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
@@ -602,7 +643,8 @@
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Advances",
|
||||
"oldfieldtype": "Section Break",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -611,7 +653,8 @@
|
||||
"label": "Get Advances Paid",
|
||||
"oldfieldtype": "Button",
|
||||
"options": "get_advances",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -622,7 +665,8 @@
|
||||
"oldfieldname": "advance_allocation_details",
|
||||
"oldfieldtype": "Table",
|
||||
"options": "Purchase Invoice Advance",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -630,7 +674,8 @@
|
||||
"fieldtype": "Section Break",
|
||||
"label": "More Info",
|
||||
"oldfieldtype": "Section Break",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"default": "No",
|
||||
@@ -644,6 +689,7 @@
|
||||
"oldfieldtype": "Select",
|
||||
"options": "No\nYes",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
@@ -655,6 +701,7 @@
|
||||
"oldfieldname": "aging_date",
|
||||
"oldfieldtype": "Date",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
@@ -680,6 +727,7 @@
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Print Heading",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"report_hide": 1
|
||||
},
|
||||
{
|
||||
@@ -692,6 +740,7 @@
|
||||
"oldfieldname": "due_date",
|
||||
"oldfieldtype": "Date",
|
||||
"print_hide": 0,
|
||||
"read_only": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
@@ -701,12 +750,14 @@
|
||||
"label": "Mode of Payment",
|
||||
"oldfieldname": "mode_of_payment",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "link:Mode of Payment"
|
||||
"options": "link:Mode of Payment",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_63",
|
||||
"fieldtype": "Column Break"
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -718,6 +769,7 @@
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Company",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
@@ -730,6 +782,7 @@
|
||||
"oldfieldtype": "Select",
|
||||
"options": "link:Fiscal Year",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
@@ -753,81 +806,53 @@
|
||||
"oldfieldname": "remarks",
|
||||
"oldfieldtype": "Text",
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"match": "",
|
||||
"permlevel": 1,
|
||||
"report": 0,
|
||||
"role": "Accounts Manager",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"report": 1,
|
||||
"role": "Accounts Manager",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"match": "",
|
||||
"permlevel": 1,
|
||||
"report": 0,
|
||||
"role": "Accounts User",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"match": "",
|
||||
"permlevel": 1,
|
||||
"role": "Purchase User",
|
||||
"submit": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"match": "",
|
||||
"permlevel": 0,
|
||||
"report": 1,
|
||||
"role": "Purchase User",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"report": 1,
|
||||
"role": "Accounts User",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Purchase User",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"match": "supplier",
|
||||
"permlevel": 0,
|
||||
"report": 1,
|
||||
"role": "Supplier"
|
||||
"role": "Supplier",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Accounts Manager",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Auditor",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
}
|
||||
]
|
||||
@@ -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,
|
||||
|
||||
@@ -30,7 +30,6 @@ from webnotes import _, msgprint
|
||||
|
||||
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
|
||||
|
||||
|
||||
from controllers.selling_controller import SellingController
|
||||
|
||||
class DocType(SellingController):
|
||||
@@ -40,9 +39,6 @@ class DocType(SellingController):
|
||||
self.tname = 'Sales Invoice Item'
|
||||
self.fname = 'entries'
|
||||
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
|
||||
|
||||
def validate(self):
|
||||
super(DocType, self).validate()
|
||||
self.fetch_missing_values()
|
||||
@@ -78,9 +74,11 @@ class DocType(SellingController):
|
||||
self.set_aging_date()
|
||||
self.set_against_income_account()
|
||||
self.validate_c_form()
|
||||
self.validate_rate_with_refdoc()
|
||||
self.validate_time_logs_are_submitted()
|
||||
self.validate_recurring_invoice()
|
||||
|
||||
|
||||
def on_submit(self):
|
||||
if cint(self.doc.is_pos) == 1:
|
||||
if cint(self.doc.update_stock) == 1:
|
||||
@@ -195,11 +193,11 @@ class DocType(SellingController):
|
||||
self.doc.fields[fieldname] = pos.get(fieldname)
|
||||
|
||||
# set pos values in items
|
||||
for doc in self.doclist.get({"parentfield": "entries"}):
|
||||
if doc.fields.get('item_code'):
|
||||
for fieldname, val in self.apply_pos_settings(doc.fields).items():
|
||||
if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)):
|
||||
doc.fields[fieldname] = val
|
||||
for item in self.doclist.get({"parentfield": "entries"}):
|
||||
if item.fields.get('item_code'):
|
||||
for fieldname, val in self.apply_pos_settings(item.fields).items():
|
||||
if (not for_validate) or (for_validate and not item.fields.get(fieldname)):
|
||||
item.fields[fieldname] = val
|
||||
|
||||
# fetch terms
|
||||
if self.doc.tc_name and not self.doc.terms:
|
||||
@@ -217,8 +215,9 @@ class DocType(SellingController):
|
||||
if self.doc.customer:
|
||||
acc_head = webnotes.conn.sql("""select name from `tabAccount`
|
||||
where (name = %s or (master_name = %s and master_type = 'customer'))
|
||||
and docstatus != 2""",
|
||||
(cstr(self.doc.customer) + " - " + self.get_company_abbr(), self.doc.customer))
|
||||
and docstatus != 2 and company = %s""",
|
||||
(cstr(self.doc.customer) + " - " + self.get_company_abbr(),
|
||||
self.doc.customer, self.doc.company))
|
||||
|
||||
if acc_head and acc_head[0][0]:
|
||||
return acc_head[0][0]
|
||||
@@ -555,6 +554,21 @@ class DocType(SellingController):
|
||||
|
||||
webnotes.conn.set(self.doc, 'c_form_no', '')
|
||||
|
||||
def validate_rate_with_refdoc(self):
|
||||
"""Validate values with reference document with previous document"""
|
||||
for d in self.doclist.get({"parentfield": "entries"}):
|
||||
if d.so_detail:
|
||||
self.check_value("Sales Order", d.sales_order, d.so_detail,
|
||||
d.export_rate, d.item_code)
|
||||
if d.dn_detail:
|
||||
self.check_value("Delivery Note", d.delivery_note, d.dn_detail,
|
||||
d.export_rate, d.item_code)
|
||||
|
||||
def check_value(self, ref_dt, ref_dn, ref_item_dn, val, item_code):
|
||||
ref_val = webnotes.conn.get_value(ref_dt + " Item", ref_item_dn, "export_rate")
|
||||
if flt(ref_val, 2) != flt(val, 2):
|
||||
msgprint(_("Rate is not matching with ") + ref_dt + ": " + ref_dn +
|
||||
_(" for item: ") + item_code, raise_exception=True)
|
||||
|
||||
def update_current_stock(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-04-10 08:35:44",
|
||||
"creation": "2013-04-19 11:00:07",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-04-17 14:05:20",
|
||||
"modified": "2013-05-22 12:06:15",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -305,6 +305,7 @@
|
||||
"fieldtype": "Link",
|
||||
"in_filter": 1,
|
||||
"label": "Sales Order",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "sales_order",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Sales Order",
|
||||
@@ -319,6 +320,7 @@
|
||||
"hidden": 1,
|
||||
"in_filter": 1,
|
||||
"label": "SO Detail ",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "so_detail",
|
||||
"oldfieldtype": "Data",
|
||||
"print_hide": 1,
|
||||
@@ -331,6 +333,7 @@
|
||||
"fieldtype": "Link",
|
||||
"in_filter": 1,
|
||||
"label": "Delivery Note",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "delivery_note",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Delivery Note",
|
||||
@@ -345,6 +348,7 @@
|
||||
"hidden": 1,
|
||||
"in_filter": 1,
|
||||
"label": "DN Detail",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "dn_detail",
|
||||
"oldfieldtype": "Data",
|
||||
"print_hide": 1,
|
||||
|
||||
@@ -36,7 +36,7 @@ def execute(filters=None):
|
||||
# invoice details
|
||||
sales_order = ", ".join(invoice_so_dn_map.get(inv.name, {}).get("sales_order", []))
|
||||
delivery_note = ", ".join(invoice_so_dn_map.get(inv.name, {}).get("delivery_note", []))
|
||||
# webnotes.errprint(customer_map.get(inv.customer, []))
|
||||
|
||||
row = [inv.name, inv.posting_date, inv.customer, inv.debit_to,
|
||||
account_map.get(inv.debit_to), customer_map.get(inv.customer), inv.project_name,
|
||||
inv.remarks, sales_order, delivery_note]
|
||||
|
||||
Reference in New Issue
Block a user